简体   繁体   中英

Can I build a war in the base pom of a multi-module project?

So I have deployment guys who don't know maven and shouldn't have to know it. All they need is a fresh build of the war. With our systems, I seriously doubt we could use anything like automated deployment using a plugin, so the Tomcat plugin is out. Also I can't simply have a project that depends on other projects since our SCM is unsupported... unless this can be done when the project is in a local sub-directory. On top of that I don't have write access to the organizational repo, either. Likely that means I can't do releases the maven way or if I can, it would render such pointless.

What I want to know, is if there is a component (module?) build structure that has the resulting archive in the base of the project so that they don't have to look for it amongst a confusing plethora of components, assemblies, profiles, etc.

You can probably use the maven-dependency-plugin . After your build, the resulting war file will be copied to the folder of your choice.

For example, let's assume that you have the following file structure (it can easily be adapted):

- parent folder
   |- child one (jar)
   |- child two (war)

To copy the child two war file into the parent folder/target directory, you could have the following declaration in the pom of the child two module.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>2.5</version>
    <executions>
      <execution>
        <id>copy</id>
        <phase>install</phase>
        <goals>
          <goal>copy</goal>
        </goals>
        <configuration>
          <artifactItems>
            <artifactItem>
              <groupId>${groupId}</groupId>
              <artifactId>${artifactId}</artifactId>
              <version>${version}</version>
              <overWrite>true</overWrite>
              <outputDirectory>${basedir}/../target</outputDirectory>
              <destFileName>${artifactId}.jar</destFileName>
            </artifactItem>
          </artifactItems>
        </configuration>
      </execution>
   </executions>
</plugin>

The plugin is quite handy since you can even specify a completely different destination folder (not part of the hierarchy).

与其在您的POM中反映这一点,不如在您的构建工具(例如Jenkins)中将复制作为构建后的动作来进行。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM