开发者

Which maven2 lifecycle-phase to choose?

开发者 https://www.devze.com 2023-01-07 10:07 出处:网络
I have a Java EE-web-application and for using my project with oc4j application se开发者_如何学Gorver it must be patched in my build-lifecycle to avoid several issues. Actually i do this via maven-ant

I have a Java EE-web-application and for using my project with oc4j application se开发者_如何学Gorver it must be patched in my build-lifecycle to avoid several issues. Actually i do this via maven-antrun-plugin which works great. I have to remove, copy some special libraries into WEB-INF/lib and edit the web.xml, to avoid clashes with EL functions and classloading issues.

According to the maven lifecycle phases i chosed the phase prepare-package: this phase is executed before the war file is packaged, but unfortunately also before the (re-)sources are copied into the temporary working dir. I dislike working on the source folders because they're under version control and i don't want to have my coworkers to accidently commit them in cause the build-tool modified them.

So maven copies all the (re-)source stuff to target/__finalName__ where i want to fix the project for the use with oc4j. because this folder is temporary and will be packaged into the war file. Unfortunately the copying and packaging is isolated done in lifecycle package.

So how can i get between the copying of the sources and resources and the real packaging?

Example with prepare-package


This example doesn't work because the ${project.build.directory}/${build.finalName} doesn't exists and the ojdbc14.jar wasn't copied there in this phase.

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-antrun-plugin</artifactId>
  <version>1.4</version>
  <executions>
    <execution>
      <id>patch-oc4j</id>
      <phase>prepare-package</phase>
      <goals>
        <goal>run</goal>
      </goals>
      <configuration>
        <tasks>
         <echo>Patching distribution for OC4J</echo>
         <echo>Deleting the obsolete OJDBC library</echo>
         <delete file="${project.build.directory}/${build.finalName}
                       /WEB-INF/lib/ojdbc14.jar" />
         [... more patching ...]
        </tasks>
      </configuration>
    </execution>
  </executions>
</plugin>


Couldn't you use a profile for this? Maybe something like this:

<profiles>
  <profile>
    <id>oc4j</id>
    <dependencies>
      <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc14</artifactId>
        <version>10.2.0.4.0</version>
        <scope>provided</scope>
      </dependency>
    </dependencies>
  </profile>
</profiles>


I have to remove, copy some special libraries into WEB-INF/lib and edit the web.xml, to avoid clashes with EL functions and classloading issues.

Sounds like you could, in part at least, do this with Build Profiles instead.. Your motivation for the problem above is a bit short, but if you elaborate we can judge this better..

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号