This week's book giveaway is in the Java in General forum.
We're giving away four copies of Event Streams in Action and have Alexander Dean & Valentin Crettaz on-line!
See this thread for details.
Win a copy of Event Streams in Action this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Dependency for Multiple Jars in Maven that are available locally - Built on Pipeline

 
Greenhorn
Posts: 6
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to build a Java project on Maven. I am working on a multi module Maven project that's built on the Jenkins Pipeline in the Nexus repository. I have few libraries that are not available on Nexus repository. I can't manually upload the libraries. I am building this project on a pipeline.

What I did:

I created a folder named jars in the project root of the Git hub repository and manually put all the jar files that are not available on Nexus. In the dependency, I referenced all these local jars as:

<dependency>
  GAV parameters
</dependency?


In the repositories, I gave the URL of the git hub repo as:

<repositories>
     <repository>
             <id>repo</id>
            <url> git hub link of the jars folder </url>
     </repository>
</repositories>


The Jenkins were not able to pick the libraries. I am getting the following error: dependency: dependency version - Build Error - Could not build for non released dependencies and  I am getting error for all the jars that are in the jars folder. I tried putting the jars folder in src/main/resources but still getting the same error.


How can I reference this jar folder so that the Jenkins Pipeline can take it? I don't have control over the Jenkins / Scripts that are involved. I am a developer just building it on the Pipeline.

P.S: I don't have access to internet at my company to post the POM or the Build Failure errors.

 
Sheriff
Posts: 21775
103
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

hawk base wrote:I tried putting the jars folder in src/main/resources but still getting the same error.


That's the worst possible location, because it means they get bundled inside your own JAR. They will not be picked up by the class loader though, so all they do is make your JAR file larger.

Check out http://workshop.alea.net/post/2016/11/maven-memo-local-jar/, that seems to have a few valid solutions. Don't go for the system dependency though (idea 1), because apparently that mechanism has been deprecated. I like idea 3 most. It looks like your initial idea, but it makes an actual repository (with the necessary meta-data), instead of just a bunch of files.
 
David Shawn
Greenhorn
Posts: 6
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I like idea 3 most. It looks like your initial idea, but it makes an actual repository (with the necessary meta-data), instead of just a bunch of files.



Thanks for the reply and for the link.I can't use the file parameter as the pipeline won't take it from the file parameter. I tried to keep the jars in the root of the project repository in the Git hub and it was able to build successfully. It builds during the Snapshot phase and there were no errors and artifact getting generated. As it builds on the pipeline, now it was failing to build during the Deployment phase. What might be the reason for this?
 
Bartender
Posts: 20924
127
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps you could clarify some things. Is this a personal project that only you need to build? A corporate/departmental project? An open-source project?

And while it would appear to be a stand-alone Java application and not a webapp or other specialized environment resource, could you explicitly tell us what it is?

You have JARs that are "not in Nexus". Do you mean a local Nexus repository, or are you looking at an Internet-wide public repository?

Now let's start from the ground up. If memory serves, the target command "mvn install" will build a Maven project and install it into your local Maven repository cache. So you don't need Nexus to resolve those artefacts. On the other hand, if Jenkins does the build, Jenkins has its own Maven repository cache. So to get those artefacts into that cache, you just have to make them Jenkins-managed products as well (with "install" goals), and setup Jenkins dependencies so that Jenkins will ensure that those artefacts have been built and installed before building your dependent project.

Which brings up another item. Is this copy of Jenkins something that you're running on your local machine, or is it a site-wide server? And if it's site-wide, can't you get permissions to install (via "mvn deploy") to the Nexus server? Seems like if you're expected to use the one, you should have some support for authorized use of the other as well. And incidentally, if there are versioning issues, don't forget that Nexus supports snapshot versions for development in addition to the formal versioning for official releases.

 
David Shawn
Greenhorn
Posts: 6
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tim Holloway wrote:Perhaps you could clarify some things. Is this a personal project that only you need to build? A corporate/departmental project? An open-source project?

And while it would appear to be a stand-alone Java application and not a webapp or other specialized environment resource, could you explicitly tell us what it is?

You have JARs that are "not in Nexus". Do you mean a local Nexus repository, or are you looking at an Internet-wide public repository?

Now let's start from the ground up. If memory serves, the target command "mvn install" will build a Maven project and install it into your local Maven repository cache. So you don't need Nexus to resolve those artefacts. On the other hand, if Jenkins does the build, Jenkins has its own Maven repository cache. So to get those artefacts into that cache, you just have to make them Jenkins-managed products as well (with "install" goals), and setup Jenkins dependencies so that Jenkins will ensure that those artefacts have been built and installed before building your dependent project.

Which brings up another item. Is this copy of Jenkins something that you're running on your local machine, or is it a site-wide server? And if it's site-wide, can't you get permissions to install (via "mvn deploy") to the Nexus server? Seems like if you're expected to use the one, you should have some support for authorized use of the other as well. And incidentally, if there are versioning issues, don't forget that Nexus supports snapshot versions for development in addition to the formal versioning for official releases.




Thanks for the reply. It's a corporate project. It's built on the Pipeline. There are two repos: Nexus 2 and Nexus 3. The particular libraries are not available on Nexus 3 and pipeline takes the build only on Nexus 3.

We have raised a request to upload those libraries but it's not going to happen anytime soon. The Jenkins Pipelines takes it's files from the Github repostiory and builds the Java proj using Maven. I don't have control to pipeline or any of the scripts in Jenkins.

We downloaded all the libraries that's not available and put that in a folder in git hub. There are 4 cycles in the Pipeline. Github Cycle / Jenkins Cycle / Deployment Cycle / Release Cycle.

Github Cycle: In this cycle, it follows three stages. It takes the code from the code, build it. It build the snapshot and upload it to Nexus repo. In these 2 stages, it was able to successfully build by taking the code from the github and builds it and artifact generated. Third stage : It's really strange as in this stage, it again builds and build getting failed in this stage citing code for Non Released Dependencies for the jars that's uploaded in the git hub.

What might be the reason for this : When it can build in the first two stages of the Github cycle and getting failed in the third stage for Build Failure for non-released dependencies.

Pipeline is designed in such a way that it looks only on Nexus 3 and build during each phase of the cycle.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!