Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

maven deploy additional jar file

Tags:

I have an artifact which is being built and deployed in a particular way (not as a jar file). In the course of deployment, a war file is built.

How can I configure the pom so that the artifact is also deployed as a jar file, to a different location?

like image 447
Joshua Swink Avatar asked Apr 15 '09 23:04

Joshua Swink


People also ask

How do I add third party jar dependency in POM XML?

If the jars are available in Maven Central repo then all you hvae to do is add dependency under dependencies section in your pom. xml file. Set the scope as required, like you said jars don't needed to be packaged in WAR file as they might be available on server then you can set scope to provided.

Can I add jars to Maven 2 build classpath without installing them?

Maven install plugin has command line usage to install a jar into the local repository, POM is optional but you will have to specify the GroupId, ArtifactId, Version and Packaging (all the POM stuff). -1, sometimes you just want to add a jar file without the trouble of installing it.

Can Nexus repository store third party jars?

Nexus has very low resource requirements, and it is something you can run on an existing workgroup collaboration machine or locally. When you upload a 3rd-party JAR to your own Nexus instance, it will immediately be integrated with Nexus search capabilities and be available to your organization's builds.


1 Answers

Maven deploy means deploy artifact to a Maven Repository, not an application server.

Configure additional JAR artifact like this:

<plugin>     <groupId>org.apache.maven.plugins</groupId>     <artifactId>maven-jar-plugin</artifactId>     <executions>         <execution>             <id>make-a-jar</id>             <phase>compile</phase>             <goals>                 <goal>jar</goal>             </goals>         </execution>     </executions> </plugin> 

Attach this new artifact to your project:

<plugin>     <groupId>org.codehaus.mojo</groupId>     <artifactId>build-helper-maven-plugin</artifactId>     <version>1.7</version>     <executions>         <execution>             <id>attach-artifacts</id>             <phase>package</phase>             <goals>                 <goal>attach-artifact</goal>             </goals>             <configuration>                 <artifacts>                     <artifact>                         <file>${project.build.directory}/${project.artifactId}-${project.version}.jar</file>                         <!-- <file>${project.build.directory}/${project.build.finalName}.jar</file> - if finalName is defined -->                         <type>jar</type>                                                </artifact>                 </artifacts>             </configuration>         </execution>     </executions> </plugin> 
like image 182
MariuszS Avatar answered Sep 27 '22 15:09

MariuszS