Reputation: 109
So I wanted to add few modules to my project. But when I try to add new module, I have information that "The project must have a packaging type of POM". And when I change it to POM, I have error: "Could not find or load main class pl.marek.countriesmapper.CountriesDirectoryMake".
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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>pl.marek</groupId>
<artifactId>countries-mapper</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>CountriesMapper</name>
<packaging>pom</packaging> <----- Here when I have jar is all ok, when POM - error.
<properties>
<version.jacoco>0.7.5.201505241946</version.jacoco>
</properties>
<repositories>
<repository>
<id>codehaus</id>
<url>http://repository.codehaus.org/org/codehaus</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.2.10-b140310.1920</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>net.sf.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>2.3</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.13</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>3.3</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.10.19</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>1.5.7</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>1.19</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-json</artifactId>
<version>1.19</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<groupId>org.apache.maven.plugins</groupId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<artifactId>appassembler-maven-plugin</artifactId>
<groupId>org.codehaus.mojo</groupId>
<version>1.7</version>
<configuration>
<programs>
<program>
<mainClass>pl.marek.countriesmapper.CountriesDirectoryMake</mainClass>
<name>CountriesDirectoryMake</name>
</program>
</programs>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>assemble</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>pl.marek.countriesmapper.CountriesDirectoryMake</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${version.jacoco}</version>
<configuration>
<skip>${maven.test.skip}</skip>
</configuration>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<!--make sure it runs AFTER integration tests -->
<phase>verify</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
@edit
Now I created new POM Maven Project called mapper. The POM of new project looks like this:
<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>pl.marek</groupId>
<artifactId>mapper</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Mapper</name>
<modules>
<module>countries-maper</module>
</modules>
</project>
In pom.xml of countries-maper I changed begining. Now it's look like this:
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>pl.marek</groupId>
<artifactId>mapper</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>countries-mapper</artifactId>
<name>CountriesMapper</name>
<packaging>jar</packaging>
And now I have errors:
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project pl.marek:countries-mapper:0.0.1-SNAPSHOT (/home/mateusz/Dokumenty/GIT/Countries/countries-maper/pom.xml) has 1 error
[ERROR] Non-resolvable parent POM: Could not find artifact pl.marek:mapper:pom:0.0.1-SNAPSHOT in codehaus (http://repository.codehaus.org/org/codehaus) and 'parent.relativePath' points at wrong local POM @ line 4, column 10 -> [Help 2]
Upvotes: 0
Views: 474
Reputation: 615
In addition to the naming problem mentioned in the comments, it seems you tried to build the child module (countries-mapper) before building the parent.
You should run mvn command from the root (where the parent pom exists), and also define the "relativePath" tag in the parent definition of countries-mapper).
Upvotes: 1