mvn eclipse:eclipse没有将SNAPSHOT JAR添加到classpath

时间:2012-01-07 01:36:52

标签: maven jar classpath snapshot maven-eclipse-plugin

我最近决定尝试将我的Maven项目用作另一个项目的依赖项。我构建了项目并将其安装到我的本地存储库:

The snapshot in my local repository

然后我设置另一个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。

干杯。

2 个答案:

答案 0 :(得分:1)

如果引用的项目存在于同一个根目录下,它将添加对依赖项目的引用,而不是对快照jar文件的依赖项。有关详细信息,请访问此URL

答案 1 :(得分:0)

你有没有尝试过mvn eclipse:clean然后是mvn eclipse:eclipse。此外,这可能是显而易见的,但如果您在eclipse中查看它,则必须刷新文件。