0

I am converting a Java project from an any build process to Maven.

Maven can currently compile the jars from the project but to fully replace Ant I need to do two additional steps:

  1. Create a file tree
  2. Copy the compiled jars and other files stored in the project into desired directories created in step 1.

This tree needs to mirror the structure that both jars and resource files will appear in installed machine.

e.g. the contents of srs/foo/bar/scripts might need to be moved to /usr/local/myFoo/spam/bar/scripts

while jars might need to go from ./myPjroject/target/*.jar to /usr/local/tomcat/webaps/fooApp/WEB-IBF/lib

ect

this tree does not then get zipped but processed by a subsequent program.

I have read that that install mojo can copy the jars but I have not seen any documentation showing that it can also copy the other files I need to move.

RichardFeynman
  • 478
  • 1
  • 6
  • 16
  • Does this answer your question? [Make Maven to copy dependencies into target/lib](https://stackoverflow.com/questions/97640/make-maven-to-copy-dependencies-into-target-lib) or [this one](https://stackoverflow.com/q/6689511/10952503) – Elikill58 Apr 19 '23 at 14:03
  • Use the maven-assembly-plugin to create the structure and package that into tar.gz/tar/zip file if really needed.... – khmarbaise Apr 19 '23 at 14:16

1 Answers1

1

I'm not sure about your question but if you only want to copy files creating target directories on the fly you can use the maven-antrun-plugin.

Something like

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
    <execution>
        <id>copywar</id>
        <phase>install</phase>
        <goals>
            <goal>run</goal>
        </goals>
        <configuration>
            <target name="copy war into install folder">
                <copy 
                    file="target/my.war"
                    tofile="/install/my/${maven.build.timestamp}/my.war" />
            </target>
        </configuration>
    </execution>
</executions>
</plugin>       

Is this what you are looking for?

Marcos
  • 36
  • 2
  • I am not 100% familiar with all the Maven plugins but maven-resources-plugin seems to be working for what I need. Due to legacy requirements after building the jars, the jars along with an extensive list of resources needs to be copied into a series of directories which is used by the next part of the build process. it is not packaged into a war at all. –  RichardFeynman Apr 25 '23 at 12:56