简体   繁体   中英

Download Maven2 dependency from non-standard layout repository

I need to download a file from a non-standard layout repository.

The standard repository layout is groupId>/<artifactId>/<version>/<artifactId>-<version>.<packaging> however, I need to download the following file:

http://hudson.myserver.com:10000/repo/ocp-services/schemas/trunk/201/archive/schemas/dist/schemas.jar

where ocp-services is effectively the groupId, schemas is the artifactId and 201 is the version.

How would I add a dependency to this file and get it downloaded into my project and local repository?

This is a Hudson file repository if this is of any help, but it is a third parties so difficult to get them to change any location.

One option would be to register a custom ArtifactRepositoryLayout implementation and to declare a repository using this custom layout. I've never done that but it should be possible, check this blog post .

A second option would be to configure Maven to go through some kind of custom proxy (eg a Servlet) and to rewrite the URL on the fly for this particular dependency.

In both cases, I'm afraid Maven will complain about missing metadata (" A dependency in Maven isn't just a JAR file ", see 3.5.5. Maven's Dependency Management ) because the hudson file repository is just not a Maven repository. Maybe this can be handled programmatically though. But as I said, I've never done this.

A third option would be to ask the project building the JAR you need to deploy it (in the maven sense). That would be of course the best solution.

A last one option would be to just download this JAR and to install it manually in your local repository. If this is an option, go for it.

Have you tried adding this to your pom.xml :

<dependencies>
            <dependency>
                <groupId>ocp-services</groupId>
                <artifactId>schemas</artifactId>
                <version>201</version>
                <type>jar</type>
            </dependency>
        </dependencies>

or if that don't work as Pascal says install it manually

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM