Недавно я решил попытаться использовать свой проект Maven в качестве зависимости от другого проекта. Я собрал проект и установил его в локальный репозиторий:
Затем я настроил другой проект Maven для использования этой зависимости (см. Первую зависимость в блоке зависимостей):
<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>koselig.games</groupId>
<artifactId>esw</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<finalName>${project.artifactId}-${project.version}.jar</finalName>
<main.class>main.Application</main.class>
<natives>${basedir}/target/natives/</natives>
<release.natives>natives/</release.natives>
</properties>
<repositories>
<repository>
<id>nifty-maven-repo.sourceforge.net</id>
<url>http://nifty-gui.sourceforge.net/nifty-maven-repo</url>
</repository>
<repository>
<id>slick-maven-repo.cokeandcode.com</id>
<url>http://slick.cokeandcode.com/mavenrepo/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>koselig.games</groupId>
<artifactId>stamme</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.cokeandcode.slick</groupId>
<artifactId>Slick</artifactId>
<version>274</version>
<exclusions>
<exclusion>
<artifactId>lwjgl</artifactId>
<groupId>org.lwjgl</groupId>
</exclusion>
<exclusion>
<artifactId>lwjgl-jinput</artifactId>
<groupId>org.lwjgl</groupId>
</exclusion>
<exclusion>
<artifactId>lwjgl-native</artifactId>
<groupId>org.lwjgl</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.lwjgl.lwjgl</groupId>
<artifactId>lwjgl</artifactId>
<version>2.8.1</version>
</dependency>
<dependency>
<groupId>xpp3</groupId>
<artifactId>xpp3_min</artifactId>
<version>1.1.4c</version>
</dependency>
<dependency>
<groupId>lessvoid</groupId>
<artifactId>nifty</artifactId>
<version>1.3.1-SNAPSHOT</version>
<exclusions>
<exclusion>
<artifactId>slick</artifactId>
<groupId>slick</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>lessvoid</groupId>
<artifactId>nifty-slick-renderer</artifactId>
<version>1.3.1-SNAPSHOT</version>
<exclusions>
<exclusion>
<artifactId>slick</artifactId>
<groupId>slick</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>1.7.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.3</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
</dependency>
<dependency>
<groupId>com.google.code</groupId>
<artifactId>straightedge</artifactId>
<version>0.3</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.googlecode.mavennatives</groupId>
<artifactId>maven-nativedependencies-plugin</artifactId>
<version>0.0.5</version>
<executions>
<execution>
<id>unpacknatives</id>
<phase>generate-resources</phase>
<goals>
<goal>copy</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<archive>
<manifest>
<mainClass>${main.class}</mainClass>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<check>
<branchRate>85</branchRate>
<lineRate>85</lineRate>
<haltOnFailure>true</haltOnFailure>
<totalBranchRate>85</totalBranchRate>
<totalLineRate>85</totalLineRate>
<packageLineRate>85</packageLineRate>
<packageBranchRate>85</packageBranchRate>
</check>
</configuration>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>clean</goal>
<goal>cobertura</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.5.1</version>
</plugin>
</plugins>
</reporting>
Однако, когда я запустил mvn eclipse: eclipse (я пробовал -U, который не работал) во втором проекте, stamme-0.0.1-SNAPSHOT не был добавлен в файл .classpath:
<classpath>
<classpathentry kind="src" path="src/test/java" output="target/test-classes" including="**/*.java"/>
<classpathentry kind="src" path="src/test/resources" output="target/test-classes" excluding="**/*.java"/>
<classpathentry kind="src" path="src/main/java" including="**/*.java"/>
<classpathentry kind="output" path="target/classes"/>
<classpathentry kind="var" path="M2_REPO/javax/jnlp/jnlp/1.2/jnlp-1.2.jar"/>
<classpathentry kind="var" path="M2_REPO/commons-collections/commons-collections/3.2/commons-collections-3.2.jar" sourcepath="M2_REPO/commons-collections/commons-collections/3.2/commons-collections-3.2-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/apache/commons/commons-lang3/3.1/commons-lang3-3.1.jar" sourcepath="M2_REPO/org/apache/commons/commons-lang3/3.1/commons-lang3-3.1-sources.jar">
<attributes>
<attribute value="jar:file:/C:/Users/Admin/.m2/repository/org/apache/commons/commons-lang3/3.1/commons-lang3-3.1-javadoc.jar!/" name="javadoc_location"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="M2_REPO/org/bushe/eventbus/1.4/eventbus-1.4.jar" sourcepath="M2_REPO/org/bushe/eventbus/1.4/eventbus-1.4-sources.jar">
<attributes>
<attribute value="jar:file:/C:/Users/Admin/.m2/repository/org/bushe/eventbus/1.4/eventbus-1.4-javadoc.jar!/" name="javadoc_location"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="M2_REPO/com/google/code/gson/gson/1.7.1/gson-1.7.1.jar" sourcepath="M2_REPO/com/google/code/gson/gson/1.7.1/gson-1.7.1-sources.jar">
<attributes>
<attribute value="jar:file:/C:/Users/Admin/.m2/repository/com/google/code/gson/gson/1.7.1/gson-1.7.1-javadoc.jar!/" name="javadoc_location"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar" sourcepath="M2_REPO/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/ibxm/ibxm/unknown/ibxm-unknown.jar"/>
<classpathentry kind="var" path="M2_REPO/net/java/jinput/jinput/2.0.5/jinput-2.0.5.jar" sourcepath="M2_REPO/net/java/jinput/jinput/2.0.5/jinput-2.0.5-sources.jar">
<attributes>
<attribute value="jar:file:/C:/Users/Admin/.m2/repository/net/java/jinput/jinput/2.0.5/jinput-2.0.5-javadoc.jar!/" name="javadoc_location"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="M2_REPO/net/java/jinput/jinput-platform/2.0.5/jinput-platform-2.0.5-natives-linux.jar"/>
<classpathentry kind="var" path="M2_REPO/net/java/jinput/jinput-platform/2.0.5/jinput-platform-2.0.5-natives-osx.jar"/>
<classpathentry kind="var" path="M2_REPO/net/java/jinput/jinput-platform/2.0.5/jinput-platform-2.0.5-natives-windows.jar"/>
<classpathentry kind="var" path="M2_REPO/jcraft/jogg/0.0.7/jogg-0.0.7.jar"/>
<classpathentry kind="var" path="M2_REPO/jcraft/jorbis/0.0.15/jorbis-0.0.15.jar"/>
<classpathentry kind="var" path="M2_REPO/com/vividsolutions/jts/1.12/jts-1.12.jar" sourcepath="M2_REPO/com/vividsolutions/jts/1.12/jts-1.12-sources.jar">
<attributes>
<attribute value="jar:file:/C:/Users/Admin/.m2/repository/com/vividsolutions/jts/1.12/jts-1.12-javadoc.jar!/" name="javadoc_location"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="M2_REPO/junit/junit/4.10/junit-4.10.jar" sourcepath="M2_REPO/junit/junit/4.10/junit-4.10-sources.jar">
<attributes>
<attribute value="jar:file:/C:/Users/Admin/.m2/repository/junit/junit/4.10/junit-4.10-javadoc.jar!/" name="javadoc_location"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="M2_REPO/net/java/jutils/jutils/1.0.0/jutils-1.0.0.jar" sourcepath="M2_REPO/net/java/jutils/jutils/1.0.0/jutils-1.0.0-sources.jar">
<attributes>
<attribute value="jar:file:/C:/Users/Admin/.m2/repository/net/java/jutils/jutils/1.0.0/jutils-1.0.0-javadoc.jar!/" name="javadoc_location"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="M2_REPO/org/lwjgl/lwjgl/lwjgl/2.8.1/lwjgl-2.8.1.jar" sourcepath="M2_REPO/org/lwjgl/lwjgl/lwjgl/2.8.1/lwjgl-2.8.1-sources.jar">
<attributes>
<attribute value="jar:file:/C:/Users/Admin/.m2/repository/org/lwjgl/lwjgl/lwjgl/2.8.1/lwjgl-2.8.1-javadoc.jar!/" name="javadoc_location"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="M2_REPO/org/lwjgl/lwjgl/lwjgl-platform/2.8.1/lwjgl-platform-2.8.1-natives-linux.jar"/>
<classpathentry kind="var" path="M2_REPO/org/lwjgl/lwjgl/lwjgl-platform/2.8.1/lwjgl-platform-2.8.1-natives-osx.jar"/>
<classpathentry kind="var" path="M2_REPO/org/lwjgl/lwjgl/lwjgl-platform/2.8.1/lwjgl-platform-2.8.1-natives-windows.jar"/>
<classpathentry kind="var" path="M2_REPO/lessvoid/nifty/1.3.1-SNAPSHOT/nifty-1.3.1-SNAPSHOT.jar" sourcepath="M2_REPO/lessvoid/nifty/1.3.1-SNAPSHOT/nifty-1.3.1-SNAPSHOT-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/lessvoid/nifty-slick-renderer/1.3.1-SNAPSHOT/nifty-slick-renderer-1.3.1-SNAPSHOT.jar" sourcepath="M2_REPO/lessvoid/nifty-slick-renderer/1.3.1-SNAPSHOT/nifty-slick-renderer-1.3.1-SNAPSHOT-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/phys2d/phys2d/060408/phys2d-060408.jar"/>
<classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-api/1.6.3/slf4j-api-1.6.3.jar" sourcepath="M2_REPO/org/slf4j/slf4j-api/1.6.3/slf4j-api-1.6.3-sources.jar">
<attributes>
<attribute value="jar:file:/C:/Users/Admin/.m2/repository/org/slf4j/slf4j-api/1.6.3/slf4j-api-1.6.3-javadoc.jar!/" name="javadoc_location"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="M2_REPO/com/cokeandcode/slick/Slick/274/Slick-274.jar" sourcepath="M2_REPO/com/cokeandcode/slick/Slick/274/Slick-274-sources.jar"/>
<classpathentry kind="src" path="/stamme"/>
<classpathentry kind="var" path="M2_REPO/com/google/code/straightedge/0.3/straightedge-0.3.jar"/>
<classpathentry kind="var" path="M2_REPO/xerces/xercesImpl/2.4.0/xercesImpl-2.4.0.jar" sourcepath="M2_REPO/xerces/xercesImpl/2.4.0/xercesImpl-2.4.0-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/xpp3/xpp3/1.1.4c/xpp3-1.1.4c.jar" sourcepath="M2_REPO/xpp3/xpp3/1.1.4c/xpp3-1.1.4c-sources.jar">
<attributes>
<attribute value="jar:file:/C:/Users/Admin/.m2/repository/xpp3/xpp3/1.1.4c/xpp3-1.1.4c-javadoc.jar!/" name="javadoc_location"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="M2_REPO/xpp3/xpp3_min/1.1.4c/xpp3_min-1.1.4c.jar" sourcepath="M2_REPO/xpp3/xpp3_min/1.1.4c/xpp3_min-1.1.4c-sources.jar">
<attributes>
<attribute value="jar:file:/C:/Users/Admin/.m2/repository/xpp3/xpp3_min/1.1.4c/xpp3_min-1.1.4c-javadoc.jar!/" name="javadoc_location"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
</classpath>
Кто-нибудь знает, почему это может происходить? Я вполне счастлив - и смог гармонично управлять Maven - с моей версией Eclipse, поэтому я бы не стал использовать m2eclipse.
Приветствие.