Copy runnable jar after install

116 views Asked by At

I need to copying a runnable jar in a network folder during the install lifecycle. Now I try to add more detail at my problem. I'm developing a java program using maven like tool of building. After

Now I created some profiles inside my pom and after installation I need to move my runnable jar file inside a network directory. For example I hava:

  1. My jar file in target/myJar.jar
  2. Network folder is in \192.168.0.11\export\jars

To do this I'm using maven-upload-plugin with the following configuration:

        <plugin>
            <groupId>com.atlassian.maven.plugins</groupId>
            <artifactId>maven-upload-plugin</artifactId>
            <version>1.1</version>
                <configuration>
                    <serverId>MyServer</serverId>
                    <resourceSrc>${project.build.directory}\${project.build.finalName}.${project.packaging}</resourceSrc>
                    <resourceDest>/home/export/jars</resourceDest>
                    <url>\\192.168.0.11\export\jars</url>
                </configuration>
        </plugin> 

I'm not able to find much documentation about this plugin, and I would want some information about resourceSRC,resourceDest,url.

Where i run the command mvn upload:upload -P Production, i get anything is copied in my remote folder.

Where am I doing wrong?

2

There are 2 answers

0
Alex On BEST ANSWER

This is Java, not Windows. Try to use Java form for the url. I believe in your case url would be like this:

file://192.168.0.11/export/jars
0
Sarfaraz Khan On

Since you're using maven-upload-plugin so according to the doc it should be something like this

<url>file://192.168.0.11/export/jars</url>

but here is another post with some success

If you can try some other plugin here is another solution with different plugin which is more common

<profiles>   
<profile>
<id>publish</id>
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-antrun-plugin</artifactId>
  <executions>
    <execution>
      <id>ftp</id>
      <phase>install</phase>
      <configuration>
        <tasks>
          <ftp action="send" 
              server="${ftp.host}" remotedir="${ftp.remotedir}" 
              userid="${ftp.userid}" password="${ftp.password}" 
              depends="${ftp.depends}" verbose="${ftp.verbose}">
            <fileset dir="${project.build.directory}">
              <include 
                name="${project.build.finalName}.${project.packaging}"/>
            </fileset>
          </ftp>
        </tasks>
      </configuration>
      <goals>
        <goal>run</goal>
      </goals>
    </execution>
  </executions>
  <dependencies>
    <dependency>
      <groupId>commons-net</groupId>
      <artifactId>commons-net</artifactId>
      <version>1.4.1</version>
    </dependency>
    <dependency>
      <groupId>ant</groupId>
      <artifactId>ant-commons-net</artifactId>
      <version>1.6.5</version>
    </dependency>
    <dependency>
      <groupId>ant</groupId>
      <artifactId>ant-nodeps</artifactId>
      <version>1.6.5</version>
    </dependency>
  </dependencies>
</plugin>
<properties>
  <ftp.host>hostname</ftp.host>
  <ftp.remotedir>/opt/path/to/install</ftp.remotedir>
  <ftp.userid>user</ftp.userid>
  <ftp.password>mypassword</ftp.password>
  <ftp.depends>yes</ftp.depends>
  <ftp.verbose>no</ftp.verbose>          
</properties>   
 </profile> 
</profiles>