2

We have several third-party lib jars, i would like to deploy to Artifactory with dependent jars!

Hence, when third party jar is referenced, all the dependent jars will be downloaded automatically by maven?

for example, xxy-company-api-9.0.jar, this jar may require abc-9.1.jar, commons-lang-1.0.jar etc. When POM references xxy-company artifact, would it should automatically get all dependent jars. Is it possible? how?

NOTE

we have third party JARs by themselves, we do not have source code projects associated with these jars. We get these jars from vendors, providers or other companies. When we receive these jars it comes along with dependent jars etc.

Currently, we load all these jars into libs-release-local. And our project POM have to reference main jar and each of the dependent jar into it.

Question: Is it possible to specify only main jar from repository, and maven will seek all dependent jars from Artifactory automatically without explicit specifying into POM???

i am looking into command mvn install:install-file how to specify dependent jars for install file?

gpa
  • 2,411
  • 6
  • 38
  • 68
  • You should look at the deploy plugin, not install. Install will only put it in your local repo, not artifactory. maven.apache.org/plugins/maven-deploy-plugin – Daniel Kaplan Jul 07 '14 at 18:06

3 Answers3

2

You can use the assembly-plugin:

How do I put all required JAR files in a library folder inside the final JAR file with Maven?

And another way it can be, defining the path in resources:

<resources>
>    <resource>
>         <directory>${WORKSPACE_PATH}/</directory>
>         <includes>
>              <include>*.jar</include>
>         </includes>
>         <targetPath>lib</targetPath>
>    </resource>
></resources>
Community
  • 1
  • 1
  • 1
    This is good answer for packaging third party jars, my question is with reference to compile project with POM – gpa Jun 10 '14 at 23:13
1

I'm surprised more people aren't interested in this question. I have to deal with this myself right now. Here's how I achieved it:

  1. Use the deploy-file mojo to manually deploy all the jars to the repository.

    I had 21 jars I needed to do this to so I dropped them into a folder and wrote a little program to generate the commands I'd need to run. Then I pasted this in a console.

  2. Create my own pom with a packaging of pom. Depend on all these files I just deployed. Deploy this pom.

  3. In my project, depend on this pom. It will transitively include all the other jars.

Community
  • 1
  • 1
Daniel Kaplan
  • 62,768
  • 50
  • 234
  • 356
0

Just configure Artifactory as a sole artifacts provider for your build. Once that done, run your build. All the dependencies will be downloaded through Artifactory and cached there.

JBaruch
  • 22,610
  • 5
  • 62
  • 90
  • URL you have specified doesn't work? also what does it mean by 'configure Artifactory as a sole artifacts provider for your build' ??? – gpa Jun 06 '14 at 21:11
  • The URL looks fine from here. What error do you get? "configure Artifactory as a sole artifacts provider for your build" means that when you run your Maven build it will download the artifacts from Artifactory only. Artifactory will cache all the artifacts from remote repositories (like JCenter or Maven Central) and this way you'll achieve what you desire - all the artifacts will be present in Artifactory. – JBaruch Jun 07 '14 at 11:38
  • My apologies, I think you have misunderstood the question, let me edit the question note – gpa Jun 10 '14 at 23:04