I have been searching for few hours how to build .jar with maven.
Finnaly i got it.
But now i have to have sources in src/main/java.
How to 'include' src/main/groovy to my project?
I read solution here but I really don't want to change my pom.xml. I had so many troubles with this.
Here is my pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.thornydev</groupId>
<artifactId>script</artifactId>
<packaging>jar</packaging>
<version>1.0</version>
<name>script</name>
<url>http://maven.apache.org</url>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<compilerId>groovy-eclipse-compiler</compilerId>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>2.7.0-01</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>pl.jedro.Main</mainClass>
</transformer>
</transformers>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.0-beta-3</version>
</dependency>
</dependencies>
I tried with:
<sources>
<source>${basedir}/src/main/groovy</source>
</sources>
and
<build>
<resources>
<resource>
<directory>src/main/groovy</directory>
</resource>
</resources>
but still nothing.
I got :
Error: Could not find or load main class pl.jedro.Main
Finally got solution.
I added:
<sourceDirectory>src/main</sourceDirectory>
<resources>
<resource>
<directory>groovy</directory>
</resource>
</resources>
in <build> </build> section.
Related
I'm creating this gRPC project where I have to launch a server and register it on Zookeeper.
I should be able to launch multiple instances of the server, but every new instance needs to have a new port or else will conflict with the servers that are already registered.
I have this maven pom.xml file where I have a property value <ins.i>, that should be incremented by 1 for every instance that is running. This property turns to be the last digit of <server.port>. If i could increment this value by 1 it would solve my problem.
I've searched by similar questions and I couldn't find any similar.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<!-- Please replace 'CXX' below with your C (campus) with A (Alameda) /
T (Tagus); and your group number with two digits. Then delete this comment. -->
<groupId>pt.sayf.CXX</groupId>
<artifactId>SAYF</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>sentry-server</artifactId>
<packaging>jar</packaging>
<name>${project.artifactId}</name>
<properties>
<mainclass>pt.sayf.sentry.server.SentryServer</mainclass>
<!-- instance number -->
<ins.i>1</ins.i>
<!-- name and coordinates -->
<sentry_loc.name>IST_Taguspark</sentry_loc.name>
<sentry.xcoord>38.737613</sentry.xcoord>
<sentry.ycoord>-9.303164</sentry.ycoord>
<server.host>localhost</server.host>
<server.port>809${ins.i}</server.port>
<sentry.path>/grpc/sayf/${sentry.name}/${ins.i}</sentry.path>
</properties>
<dependencies>
<!-- contract brings gRPC dependencies with it -->
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>sentry-contract</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>depot-contract</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/test/resources</directory>
<filtering>true</filtering>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>${version.maven-resources-plugin}</version>
<configuration>
<nonFilteredFileExtensions>
<nonFilteredFileExtension>jks</nonFilteredFileExtension>
</nonFilteredFileExtensions>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>${version.exec-maven-plugin}</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- to prevent deprecation warning: -->
<killAfter>-1</killAfter>
<mainClass>${mainclass}</mainClass>
<arguments>
<argument>${zookeeper.url}</argument>
<argument>${server.host}</argument>
<argument>${server.port}</argument>
<argument>${sentry.path}</argument>
<argument>${sentry_loc.name}</argument>
<argument>${sentry.xcoord}</argument>
<argument>${sentry.ycoord}</argument>
</arguments>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>appassembler-maven-plugin</artifactId>
<version>${version.appassembler-maven-plugin}</version>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>assemble</goal>
</goals>
</execution>
</executions>
<configuration>
<programs>
<program>
<mainClass>${mainclass}</mainClass>
<id>${project.artifactId}</id>
</program>
</programs>
</configuration>
</plugin>
</plugins>
</build>
</project>
everyone!
I've tried to create .jar file by Maven with dependence on JavaFX according to this post. Unfortunately, attempts was failed. In folder targets creating two files:
MAVEN_UI_INTRO-1.0-SNAPSHOT.jar
original-MAVEN_UI_INTRO-1.0-SNAPSHOT.jar
With first file, I get this error:
Error: JavaFX runtime components are missing, and are required to run this application
With second file, this error:
no main manifest attribute, in target/original-MAVEN_UI_INTRO-1.0-SNAPSHOT.jar
Build by command mvn clean package
Start by command java -jar target/"someJarFile.jar"
Main question: What do I wrong?
UPD: My pom.xml file:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.novalab</groupId>
<artifactId>MAVEN_UI_INTRO</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>11.0.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>11</release>
</configuration>
</plugin>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.novalab.App</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.1</version>
<configuration>
<mainClass>com.novalab.App</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</project>
I'm using the latest gwt maven plugin (https://tbroyer.github.io/gwt-maven-plugin/index.html) to compile a multi module GWT project and deploy it to tomcat 9. I am also using intellij 14 as my IDE. It's a client app only ie. no server/servlet. When I build via the IDE gwt plugin and zip up and deploy that output to tomcat my app works fine.
However, using the maven plugin, everything compiles ok and the contents of the war look fine to me. The war deploys ok to tomcat, but I simply see a blank page when I try to load it on my browser (latest chrome edition).
I'm running dev tools and jscript console and there are no errors being reported, network view, shows the content downloading ok. I've set break points in my nocache js files and stepped through it with no problems. Below is my pom. I'd appreciated any insight / help with this as it's been bugging me for days..
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>guml-ui</artifactId>
<groupId>guml-ui</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dashboard</artifactId>
<!--<packaging>gwt-app</packaging>-->
<dependencies>
<dependency>
<groupId>guml-ui</groupId>
<artifactId>myworkspace</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>guml-ui</groupId>
<artifactId>project</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>guml-ui</groupId>
<artifactId>common</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/java/au/com/guml/ui/components/dashboard/public</directory>
</resource>
<resource>
<directory>war</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>net.ltgt.gwt.maven</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>1.0-rc-9</version>
<extensions>true</extensions>
<configuration>
<moduleName>au.com.guml.ui.components.dashboard.Dashboard</moduleName>
<moduleShortName>Dashboard</moduleShortName>
<warDir>${basedir}/../gumlui-war/target/gumlui-war-${project.version}</warDir>
<devmodeWorkDir>${basedir}/../gumlui-war/target/gumlui-war-${project.version}</devmodeWorkDir>
<webappDirectory>${basedir}/../gumlui-war/target/gumlui-war-${project.version}</webappDirectory>
<skipModule>true</skipModule>
<draftCompile>true</draftCompile>
<startupUrls>Dashboard.html</startupUrls>
</configuration>
<executions>
<execution>
<id>compile-module-common</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<moduleName>au.com.guml.ui.components.common.Common</moduleName>
<moduleShortName>Common</moduleShortName>
</configuration>
</execution>
<execution>
<id>compile-module-myworkspace</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<moduleName>au.com.guml.ui.components.myworkspace.MyWorkspace</moduleName>
<moduleShortName>MyWorkspace</moduleShortName>
</configuration>
</execution>
<execution>
<id>compile-module-project</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<moduleName>au.com.guml.ui.components.project.Project</moduleName>
<moduleShortName>Project</moduleShortName>
</configuration>
</execution>
<execution>
<id>compile-module-dashboard</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<moduleName>au.com.guml.ui.components.dashboard.Dashboard</moduleName>
<moduleShortName>Dashboard</moduleShortName>
</configuration>
</execution>
</executions>
</plugin>
<!-- copy the host html page -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
<executions>
<execution>
<id>copy-hosthtml</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/../gumlui-war/target/gumlui-war-${project.version}</outputDirectory>
<resources>
<resource>
<directory>war</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
<execution>
<id>copy-public</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/../gumlui-war/target/gumlui-war-${project.version}/Dashboard</outputDirectory>
<resources>
<resource>
<directory>src/main/java/au/com/guml/ui/components/dashboard/public</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Cheers,
Matt.
For anyone that is interested I got the maven build working on the multi module gwt project. See the following pom (dashboard) which is my app which inherits other modules.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>guml-ui</artifactId>
<groupId>guml-ui</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dashboard</artifactId>
<!--<packaging>gwt-app</packaging>-->
<dependencies>
<dependency>
<groupId>guml-ui</groupId>
<artifactId>myworkspace</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>guml-ui</groupId>
<artifactId>project</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>guml-ui</groupId>
<artifactId>common</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.1.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator-sources</artifactId>
<version>4.1.0.Final</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/webapp/WEB-INF/lib/hibernate-validator-4.1.0.Final-sources.jar</systemPath>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/java/au/com/guml/ui/components/dashboard/public</directory>
</resource>
<resource>
<directory>src/main/java</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>net.ltgt.gwt.maven</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>1.0-rc-9</version>
<extensions>true</extensions>
<configuration>
<moduleName>au.com.guml.ui.components.dashboard.Dashboard</moduleName>
<moduleShortName>Dashboard</moduleShortName>
<warDir>${basedir}/../gumlui-war/target/gumlui</warDir>
<devmodeWorkDir>${basedir}/../gumlui-war/target/gumlui</devmodeWorkDir>
<webappDirectory>${basedir}/../gumlui-war/target/gumlui</webappDirectory>
<skipModule>true</skipModule>
<startupUrls>Dashboard.html</startupUrls>
<!--<style>PRETTY</style>-->
</configuration>
<executions>
<execution>
<id>compile-module-common</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<moduleName>au.com.guml.ui.components.common.Common</moduleName>
<moduleShortName>Common</moduleShortName>
</configuration>
</execution>
<execution>
<id>compile-module-myworkspace</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<moduleName>au.com.guml.ui.components.myworkspace.MyWorkspace</moduleName>
<moduleShortName>MyWorkspace</moduleShortName>
</configuration>
</execution>
<execution>
<id>compile-module-project</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<moduleName>au.com.guml.ui.components.project.Project</moduleName>
<moduleShortName>Project</moduleShortName>
</configuration>
</execution>
<execution>
<id>compile-module-dashboard</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<moduleName>au.com.guml.ui.components.dashboard.Dashboard</moduleName>
<moduleShortName>Dashboard</moduleShortName>
</configuration>
</execution>
</executions>
</plugin>
<!-- copy the host html page -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
<executions>
<execution>
<id>copy-public</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/../gumlui-war/target/gumlui/Dashboard</outputDirectory>
<resources>
<resource>
<directory>src/main/java/au/com/guml/ui/components/dashboard/public</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
I have to include the build resources entries on this pom and my inherited projects to manually include the public directory, not sure why, this appears to a quirk with the plugin.
I'm modifying Weka, an open-source Maven project, and my modifications are running perfectly on eclipse. However, when I export to an executable jar file, I get a null pointer exception, because it's not able to find the images I created and added to the project upon getImage() calls.
It seems that this is a rather common problem with jar files, so I tried using the URL method to load, but upon further investigation, when I look into the jar file with SecureZIP, the images(.png) that I added to the project are not even in the jar (however, the images (.png) that were in the original open source distribution were, despite the fact that all the images were in the same folder and of the same type (.png) designated by the build path in the source). Is there something I'm forgetting to do? Why are my images not exporting to the jar, but the other images in the folder are?
Library Handling is: "Extract required libraries into generated JAR".
Images are in src/main/java/weka/gui.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>nz.ac.waikato.cms.weka</groupId>
<artifactId>weka-stable</artifactId>
<version>3.8.1-SNAPSHOT</version>
<!-- weka-version -->
<packaging>jar</packaging>
<name>weka-stable</name>
<description>The Waikato Environment for Knowledge Analysis (WEKA), a machine learning workbench. This is the stable version. Apart from bugfixes, this version does not receive any other updates.
</description>
<url>http://www.cms.waikato.ac.nz/ml/weka/</url>
<organization>
<name>University of Waikato, Hamilton, NZ</name>
<url>http://www.waikato.ac.nz/</url>
</organization>
<licenses>
<license>
<name>GNU General Public License 3</name>
<url>http://www.gnu.org/licenses/gpl-3.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<developers>
<developer>
<id>wekateam</id>
<name>The WEKA Team</name>
<email>wekalist#list.waikato.ac.nz</email>
</developer>
</developers>
<mailingLists>
<mailingList>
<name>wekalist</name>
<subscribe>https://list.waikato.ac.nz/mailman/listinfo/wekalist</subscribe>
<unsubscribe>https://list.waikato.ac.nz/mailman/listinfo/wekalist</unsubscribe>
<archive>https://list.waikato.ac.nz/mailman/htdig/wekalist/</archive>
</mailingList>
</mailingLists>
<parent>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
<version>7</version>
</parent>
<scm>
<connection>scm:svn:https://svn.cms.waikato.ac.nz/svn/weka/branches/stable-3-8/weka</connection>
<developerConnection>scm:svn:https://svn.cms.waikato.ac.nz/svn/weka/branches/stable-3-8/weka</developerConnection>
<url>https://svn.cms.waikato.ac.nz/svn/weka/branches/stable-3-8/weka</url>
</scm>
<profiles>
<profile>
<id>release-sign-artifacts</id>
<activation>
<property>
<name>performRelease</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<!-- used for skipping tests -->
<id>no-tests</id>
<properties>
<skipTests>true</skipTests>
</properties>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>nz.ac.waikato.cms.weka.thirdparty</groupId>
<artifactId>java-cup-11b</artifactId>
<version>2015.03.26</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>nz.ac.waikato.cms.weka.thirdparty</groupId>
<artifactId>java-cup-11b-runtime</artifactId>
<version>2015.03.26</version>
</dependency>
<dependency>
<groupId>nz.ac.waikato.cms.weka.thirdparty</groupId>
<artifactId>bounce</artifactId>
<version>0.18</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.10</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.googlecode.matrix-toolkits-java</groupId>
<artifactId>mtj</artifactId>
<version>1.0.4</version>
</dependency>
<dependency>
<groupId>net.sourceforge.f2j</groupId>
<artifactId>arpack_combined_all</artifactId>
<version>0.1</version>
</dependency>
<dependency>
<groupId>com.googlecode.netlib-java</groupId>
<artifactId>netlib-java</artifactId>
<version>1.1</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<weka.main.class>weka.gui.GUIChooser</weka.main.class>
</properties>
<build>
<directory>dist</directory>
<outputDirectory>build/classes</outputDirectory>
<testOutputDirectory>build/testcases</testOutputDirectory>
<resources>
<resource>
<targetPath>${project.build.outputDirectory}</targetPath>
<directory>${project.build.sourceDirectory}</directory>
<includes>
<include>**/*.arff</include>
<include>**/*.cost</include>
<include>**/*.cup</include>
<include>**/*.default</include>
<include>**/*.excludes</include>
<include>**/*.flex</include>
<include>**/*.gif</include>
<include>**/*.icns</include>
<include>**/*.ico</include>
<include>**/*.jflex</include>
<include>**/*.jpeg</include>
<include>**/*.jpg</include>
<include>**/*.kfml</include>
<include>**/*.matrix</include>
<include>**/*.png</include>
<include>**/*.properties</include>
<include>**/*.props</include>
<include>**/*.txt</include>
<include>**/*.xml</include>
<include>**/DatabaseUtils.props.*</include>
<include>weka/gui/beans/README</include>
</includes>
</resource>
<resource>
<targetPath>${project.build.testOutputDirectory}</targetPath>
<directory>${project.build.testSourceDirectory}</directory>
<includes>
<include>**/*.arff</include>
<include>**/*.cost</include>
<include>**/*.cup</include>
<include>**/*.default</include>
<include>**/*.excludes</include>
<include>**/*.flex</include>
<include>**/*.gif</include>
<include>**/*.icns</include>
<include>**/*.ico</include>
<include>**/*.jflex</include>
<include>**/*.jpeg</include>
<include>**/*.jpg</include>
<include>**/*.kfml</include>
<include>**/*.matrix</include>
<include>**/*.png</include>
<include>**/*.properties</include>
<include>**/*.props</include>
<include>**/*.txt</include>
<include>**/*.xml</include>
<include>**/DatabaseUtils.props.*</include>
<include>weka/gui/beans/README</include>
</includes>
</resource>
</resources>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.7.2</version>
<configuration>
<includes>
<include>**/*Test.java</include>
</includes>
<disableXmlReport>true</disableXmlReport>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<systemPropertyVariables>
<weka.test.Regression.root>src/test/resources/wekarefs</weka.test.Regression.root>
<weka.test.maventest>true</weka.test.maventest>
<user.timezone>Pacific/Auckland</user.timezone>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.1</version>
<configuration>
<tagBase>https://svn.cms.waikato.ac.nz/svn/weka/tags</tagBase>
<useReleaseProfile>false</useReleaseProfile>
<!-- tests are performed with the ant build file, hence skipped here. -->
<preparationGoals>clean verify -P no-tests</preparationGoals>
<goals>deploy -P no-tests</goals>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<filesets>
<fileset>
<directory>.</directory>
<includes>
<include>**/*~</include>
<include>**/.attach_pid*</include>
<include>**/hs_err_pid*</include>
</includes>
<followSymlinks>false</followSymlinks>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<archive>
<manifest>
<mainClass>${weka.main.class}</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.2</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<excludeResources>true</excludeResources>
</configuration>
</execution>
<execution>
<id>attach-test-sources</id>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.8.1</version>
<configuration>
<maxmemory>1000m</maxmemory>
<subpackages>weka:org</subpackages>
<show>public</show>
<outputDirectory>${project.basedir}/doc</outputDirectory>
<!-- when using Java 8, use this setting to avoid overly strict javadoclet -->
<!--additionalparam>-Xdoclint:none</additionalparam-->
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
I am creating a jar-with-dependencies in mvn 3.0.3. I have successfully done this in one project (using just mvn install) and created a complete jar-wth-dependencies. I copied the relevant chunk of POM code (<plugins>...</plugins>, which someone else wrote!) to the current project (which differs in that it has assemblies). It creates the normal snapshot jar (jumbo-converters-compchem-gaussian-0.3-SNAPSHOT.jar) but no jar-with-dependencies. How should I amend the POM?
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cml</groupId>
<artifactId>jumbo-converters</artifactId>
<version>0.3-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<artifactId>jumbo-converters-compchem-gaussian</artifactId>
<name>jumbo-converters-compchem-gaussian</name>
<dependencies>
<dependency>
<groupId>${jumbo.groupId}</groupId>
<artifactId>jumbo</artifactId>
</dependency>
<dependency>
<groupId>cml</groupId>
<artifactId>jumbo-converters-core</artifactId>
</dependency>
<dependency>
<groupId>cml</groupId>
<artifactId>jumbo-converters-compchem-common</artifactId>
<version>0.3-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cml</groupId>
<artifactId>jumbo-converters-templates</artifactId>
<version>0.3-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>cml</groupId>
<artifactId>jumbo-converters-testutils</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>cml</groupId>
<artifactId>jumbo-converters-compchem-testutils</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>org.xmlcml.cml.converters.compchem.gaussian.GaussianLogXML2CompchemConverter</mainClass>
</manifest>
</archive>
<excludes>
<exclude>.hgsub</exclude>
<exclude>**/.hg/</exclude>
<exclude>**/.project</exclude>
<exclude>**/external/</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>org.xmlcml.cml.converters.compchem.gaussian.GaussianLogXML2CompchemConverter</mainClass>
</manifest>
</archive>
<excludes>
<exclude>.hgsub</exclude>
<exclude>**/.hg/</exclude>
<exclude>**/.project</exclude>
<exclude>**/external/</exclude>
</excludes>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
First,
Use maven dependency plugin to retrieve/store the dependencies (more info here) to your project folder.
Ex: Say lib folder.
Now mark this lib folder as a "Resources" folder.
Like,
<resources>
<resource>
<directory>lib</directory>
<targetPath>lib</targetPath>
</resource>
</resources>
Now mvn install should include the dependencies in your final artifact.
(copying Shinchan's comment to here so it can be formatted:
Simple add this to ur pom.
<build>
<resources>
<resource>
<directory>lib</directory>
<targetPath>lib</targetPath>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>