2

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>

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>

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]
likeGreen
  • 1,001
  • 1
  • 20
  • 40

2 Answers2

1

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

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.

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]

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

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.

Ryan J
  • 8,275
  • 3
  • 25
  • 28
  • I put the jar of "abc-lt-core 5.1.4" as suggested by you. But still i am getting the same error. The issue here is that maven should replace the placeholder ${masterVersionNumber} in parent pom to the number 5.1.4 as specified in the parent pom. But it is not doing so. – likeGreen Nov 10 '14 at 21:59
  • You can see it is looking for dependencies on repo.maven... as it can't find it on local repo..."Downloading: http://repo.maven.apache.org/maven2/com/abc/lt/abc-lt/${masterVersionNumber}/abc-lt-${masterVersionNumber}" – likeGreen Nov 10 '14 at 22:08
  • If it can't find it in the local repo, it means it wasn't installed properly. What command did you use to install it? – Ryan J Nov 10 '14 at 23:12
  • In Eclipse I am using Run As--> Maven Build (install) – likeGreen Nov 10 '14 at 23:19
  • You need to install the 3rd party jar manually. Your project install installs your project locally, which it won't be able to do. Download the jar and follow the instructions [here](http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html) – Ryan J Nov 11 '14 at 00:13
  • Its not a third party jar. The current project is just dependent on other projects of the org. on which I don't have any control but I am able to build the dependent projects in my eclipse. The current project is working fine. But it is just not possible to create the jar with the existing scenario. – likeGreen Nov 11 '14 at 00:28
  • If the parent POM is not under your control, and it's preventing you from building your project, you should submit a bug to the team that maintains it. Otherwise, you treat the dependency as a 3rd party JAR and install it locally to get by. – Ryan J Nov 11 '14 at 01:43
0

If you need create a jar with dependences you could using the single goal of maven-assembly-plugin.

...

<build>
...
    <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <configuration>
                <archive>
                    <manifest>

                        <mainClass>MAIN_CLASS</mainClass>
                    </manifest>
                </archive>
                <!-- <finalName>JAR_NAME/finalName> -->
                <descriptorRefs>

                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
            </configuration>
            <executions>
                <execution>
                    <id>make-assembly</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
    </plugin>
...
</build>
...

This plugin is added to packaging phase of the lifecicle of maven (<phase>package</phase>). The jar-with-dependencies generates an only jar which contains all the dependencies.

kiuby_88
  • 334
  • 1
  • 6
  • 18
  • I removed the maven-shade-plugin and used maven-assembly-plugin just by putting my main class name ...... com.abc.Caller Caller But still I am getting the same error – likeGreen Nov 07 '14 at 19:01
  • You could use ``mvn -U clean install`` for forcing the re-downloaded of the dependencies. – kiuby_88 Nov 08 '14 at 09:59
  • @kiuby_88 not if it can't resolve the download URL, which is what is happening. – Ryan J Nov 08 '14 at 17:14