Maven是否可以在maven项目中使用jar作为依赖

时间:2014-10-29 10:02:31

标签: java maven jar

我想使用maven为gwt项目添加一个源jar。

我尝试这样做(它只是管理源依赖项的poc)

source jar pom:

<?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>test-source-dependencies</artifactId>
    <groupId>com.niflheimcorp</groupId>
    <version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>test-source-jar</artifactId>
<packaging>jar</packaging>
<version>1.0</version>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <version>2.4</version>
            <executions>
                <execution>
                    <id>attach-sources</id>
                    <phase>verify</phase>
                    <goals>
                        <goal>jar-no-fork</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>

</build>
</project>

使用jar pom:

<?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>com.niflheimcorp</groupId>
<artifactId>test-utilisateur-jar</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

 <dependencies>
    <dependency>
        <groupId>com.niflheimcorp</groupId>
        <artifactId>test-source-jar</artifactId>
        <classifier>source</classifier>
    </dependency>
</dependencies> 
</project>

启动mvn clean install时出现以下错误:

[ERROR] Failed to execute goal on project test-utilisateur-jar: Could not resolv
e dependencies for project com.niflheimcorp:test-utilisateur-jar:jar:1.0-SNAPSHO
T: Could not find artifact com.niflheimcorp:test-source-jar:jar:source:1.0-SNAPS
HOT -> [Help 1]

但是神器是由maven在前一步

安装的
[INFO] Installing C:\Users\CRSD2193\psf\G4R0C3_portaFixe\test-sources-dependenci

es \ test-source-jar \ target \ test-source-jar-1.0-sources.jar to C:\ Users \ CRSD2193。 平方米\库\ COM \ niflheimcorp \测试 - 源罐\ 1.0 \测试 - 源罐-1.0-sources.j AR

除非我们不能将源jar声明为构建代码,否则我无法看到错误的原因。

此致

报应

1 个答案:

答案 0 :(得分:0)

分类器来源上的愚蠢错字(最后忘了s: - /)。