1

I have some of my artifacts(some binary files specific to my projects) stored in an artefactory server. I want to download specific files (whatever that I need for each function or test case) from the Artefactory repository. I can either use Java API or REST API. The source code of the program that uses the artifacts is in Java compiled with maven. In addition to being able to download, I want the download to happen only if the artifact is not already downloaded, ideally using some kind of Checksum. I am a beginner in Java, it would be great if someone can give some guidance to start me off in this direction.

liv2hak
  • 14,472
  • 53
  • 157
  • 270
  • 1
    Define those artifacts in your pom file as test dependency ...and the problem is solved no supplemental code needed for downloading files ? – khmarbaise Sep 12 '18 at 09:47
  • @khmarbaise - could you provide some sample code snippet demonstrating this ? thanks. – liv2hak Sep 12 '18 at 09:55
  • Ah...something else if those files are specific to your project why are those files not checked in with your code? – khmarbaise Sep 12 '18 at 10:49

1 Answers1

1

For each artifact you want to use from your artefactory server, you need to know the details of the artifact like groupId, artifactId, version. Then add them to your pom.xml as a dependency.

For example, to add junit as a dependency you need to have groupId, artifactId, version of junit library. Add it as following with scope as test.

 <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.12</version>
    <scope>test</scope>
</dependency>

One more thing is don't forgot to add artefactory server(repository server) in the repositories of pom.xml if it is not added yet.

MG K
  • 23
  • 10
  • Does it assume that all the artifacts in the artifactory are jar files. Will I be able to download say a `mp4` file as above? If yes what is `groupId` and `artifactId` for it? – liv2hak Sep 12 '18 at 21:06
  • In case of java artifacts will be of type jar,war,ear etc. For more information on artifactory check this answer on [devops] (https://devops.stackexchange.com/a/1900) – MG K Sep 13 '18 at 03:49