Glory to Russia
Glory to Russia

Reputation: 18710

Is it possible to upload 2 different sets of files to 2 different locations in Maven?

I have a Maven project, in whose mvn install phase a certain JAR is generated and uploaded via FTP to a server.

In the same project there is a directory with static HTML and image files (that's the HTML client of the server JAR), which I want to upload to a web server whenever the server JAR is updated. The existing upload routine must be preserved.

Is it possible to do this (2 completely different sets of files are uploaded to different locations in the same phase and pom.xml) in Maven? If yes, how?

Upvotes: 0

Views: 58

Answers (2)

Sonal
Sonal

Reputation: 272

Try this plugin with profile:

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.1</version>
                <executions>
                   <execution>
                      <phase>install</phase>
                      <goals>
                         <goal>run</goal>
                      </goals>
                      <configuration>
                      <tasks>
                         <echo>Using q.png</echo>
                <copy file="/home/yyy/Desktop/q.png" 
                tofile ="/home/yyy/Desktop/qpk/q.png"/>
            <echo>Using asd.html</echo>
                <copy file="/home/yyy/Desktop/asd.html" 
                tofile ="/home/yyy/Documents/asd.html"/>
                      </tasks>
                      </configuration>
                   </execution>
                </executions>
                </plugin>

Upvotes: 1

carlspring
carlspring

Reputation: 32627

It looks like it's time to split your project into two modules. Have one of the projects contain the webapp stuff (HTML, CSS, JS, etc) and the other -- containing the other code relating to your second case, or have different assemblies as actual separate modules/projects.

Also, the install goal is not the one that is (or should be) deploying the files, but rather -- the deploy goal.

Upvotes: 0

Related Questions