从依赖于其他项目的maven项目构建jar [英] Build a jar from a maven project dependent on other project

查看:172
本文介绍了从依赖于其他项目的maven项目构建jar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在eclipse中有一个名为abc-caller的spring maven项目。我需要创建一个项目的jar。该项目取决于abc-lt-core。我对此依赖关系没有任何控制权

I have spring maven project in eclipse called abc-caller. I need to create a jar of the project. The project depends on abc-lt-core. I don't have any control on this dependency

<dependency>
    <groupId>com.abc.lt</groupId>
    <artifactId>abc-lt-core</artifactId>
    <version>5.1.4</version>
</dependency>

abc-caller的POM

POM of abc-caller

<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.abc</groupId>
    <artifactId>abc-caller</artifactId>
    <version>1.0</version>
    <name>caller</name>

    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <excludes>
                    <exclude>*.*</exclude>
                </excludes>
                <filtering>false</filtering>
            </resource>
        </resources>

         <defaultGoal>install</defaultGoal> 

    <plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <executions>
            <execution>
                <phase>package</phase>
                <goals>
                    <goal>shade</goal>
                </goals>
                <configuration>
                    <finalName>Caller</finalName>
                    <transformers>
                        <transformer
                            implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                            <manifestEntries>
                                <Main-Class>com.abc.Caller</Main-Class>
                                <Build-Number>1</Build-Number>
                            </manifestEntries>
                        </transformer>
                    </transformers>
                </configuration>
            </execution>
        </executions>
    </plugin>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <configuration>
            <source>1.7</source>
            <target>1.7</target>
        </configuration>
    </plugin>
</plugins>
</build>

    <dependencies>

        <dependency>
            <groupId>org.apache.activemq</groupId>
            <artifactId>activemq-all</artifactId>
            <version>5.8.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.activemq</groupId>
            <artifactId>activemq-pool</artifactId>
            <version>5.8.0</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jms</artifactId>
            <version>3.2.4.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>com.abc.lt</groupId>
            <artifactId>abc-lt-core</artifactId>
            <version>5.1.4</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>3.2.4.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jmx</artifactId>
            <version>2.0.8</version>
        </dependency>
    </dependencies>
</project>

在buildind maven项目中我收到以下错误

On buildind the maven project I am getting the following error

   Downloading: http://repo.maven.apache.org/maven2/com/abc/lt/abc-lt/${masterVersionNumber}/abc-lt-${masterVersionNumber}.pom
    Downloading: http://repo.opengeo.org/com/abc/lt/abc-lt/${masterVersionNumber}/abc-lt-${masterVersionNumber}.pom
    Downloading: http://www.hibernatespatial.org/repository/com/abc/lt/abc-lt/${masterVersionNumber}/abc-lt-${masterVersionNumber}.pom
    Downloading: http://repo1.maven.org/maven2/com/abc/lt/abc-lt/${masterVersionNumber}/abc-lt-${masterVersionNumber}.pom
---------
BUILD FAILURE
-----------------


 Failed to execute goal on project abc-lt-caller: Could not resolve dependencies for project com.abc:abc-lt-caller:jar:1.0: 
 Failed to collect dependencies for [org.apache.activemq:activemq-all:jar:5.8.0 (compile), 
 org.apache.activemq:activemq-pool:jar:5.8.0 (compile), org.springframework:spring-jms:jar:3.2.4.RELEASE (compile), 
 com.abc.lt:abc-lt-core:jar:5.1.4 (compile), org.springframework:spring-core:jar:3.2.4.RELEASE (compile), 
 org.springframework:spring-jmx:jar:2.0.8 (compile)]: 

 Failed to read artifact descriptor for com.abc.lt:abc-lt-core:jar:5.1.4: 
 Could not transfer artifact com.abc.lt:abc-lt:pom:${masterVersionNumber} 
 from/to central (http://repo.maven.apache.org/maven2): Illegal character in path at index 71:
 http://repo.maven.apache.org/maven2/com/abc/lt/abc-lt/
 ${masterVersionNumber}/abc-lt-${masterVersionNumber}.pom -> [Help 1]


推荐答案

你的问题不是你的问题项目,它似乎与依赖项目的POM。

Your problem isn't with your project, it seems to be with the POM of the dependent project.

你得到的错误告诉你在URL /路径上有一个非法字符阻止Maven解析依赖关系。

The error you are getting is telling you there's an illegal character on the URL/path that is preventing Maven from resolving the dependency.


无法读取
的工件描述符com.abc.lt:abc-lt-core:jar :5.1.4:无法将工件
com.abc.lt:abc-lt:pom:${masterVersionNumber}从/转移到
http://repo.maven.apache.org/maven2 ):路径中的非法字符
索引71:
http://repo.maven.apache.org/maven2 / com / abc / lt / abc-lt /
$ {masterVersionNumber} / abc-lt - $ {masterVersionNumber} .pom - > [帮助1]

Failed to read artifact descriptor for com.abc.lt:abc-lt-core:jar:5.1.4: Could not transfer artifact com.abc.lt:abc-lt:pom:${masterVersionNumber} from/to central (http://repo.maven.apache.org/maven2): Illegal character in path at index 71: http://repo.maven.apache.org/maven2/com/abc/lt/abc-lt/ ${masterVersionNumber}/abc-lt-${masterVersionNumber}.pom -> [Help 1]

参见粗体文字。它没有解析$ {masterVersionNumber}属性。我怀疑这是部署的问题。

See the bold text. It's not resolving the ${masterVersionNumber} property. I suspect it's a problem on the deployment.

如果您无法控制它,可以手动下载JAR并将其安装到本地m2 repo并构建那样?这应该允许你顺利,直到它被修复。

If you don't have control over it, can you download the JAR manually and install it to your local m2 repo and build that way? That should allow you to get by until it's fixed.

这篇关于从依赖于其他项目的maven项目构建jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆