-1

I have Java Maven project in Eclipse. Sometimes I need to copy binary with all libraries and configuration files to live system. Is it right place to ask Maven about it?

Should I use package goal for this reason. Should I use any plugin? Where I should define remote system sftp logins and paths?

vico
  • 17,051
  • 45
  • 159
  • 315

2 Answers2

0

For building a .jar with all dependencies and a main-class attribute, you can use the maven plugin maven-assembly-plugin

You can use it like this in your pom-file:

<plugin>                                                        
    <artifactId>maven-assembly-plugin</artifactId>              
    <configuration>                                             
        <archive>                                               
            <manifest>                                          
                <mainClass>package.mainClass</mainClass>           
            </manifest>                                         
        </archive>                                              
        <descriptorRefs>                                        
            <descriptorRef>jar-with-dependencies</descriptorRef>
        </descriptorRefs>                                       
    </configuration>                                            
    <executions>                                                
        <execution>                                             
            <id>make-assembly</id>                              
            <goals>                                             
                <goal>single</goal>                             
            </goals>                                            
            <phase>package</phase>                              
        </execution>                                            
    </executions>                                               
</plugin>    

Inside the <build> and plugins of course :)

edgelord
  • 43
  • 4
0

See How to Create an Executable JAR with Maven with pros & cons for the different options:

  • Manual Configuration
  • Apache Maven Assembly Plugin
  • Apache Maven Shade Plugin
  • One Jar Maven Plugin
  • Spring Boot Maven Plugin
  • Web Application with Executable Tomcat

Use the Wagon Maven Plugin to copy/upload the so created "executable" JAR wherever you want.

Gerold Broser
  • 14,080
  • 5
  • 48
  • 107