Maven repository that sometimes works - maven

I hosted a java project on github.
The project is located here.
The project is really just a java library, and I wanted to create a maven repository for it. Because this is tricky, I followed a guide which explained me which project structure to follow. He applies a trick: create a 2nd branch named "repository". As you can see the jar files are in there.
That all went well, I made my first build, and then I created a java "Hello World" project to test if I could use this new maven dependency. So, I created a pom file with a dependency:
<dependency>
<groupId>brugo</groupId>
<artifactId>brugo</artifactId>
<version>0.1.0</version>
</dependency>
And to tell maven where to find this dependency, I added this one:
<repositories>
<repository>
<id>brugo</id>
<url>https://github.com/brugo/brugo/raw/repository/</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
The good thing: sometimes it works.
The bad thing: sometimes it does not work.
And I am trying to find out what could be wrong. This is what IntelliJ looks like when things go wrong:
And I've seen this error message showing up:
[ERROR] Failed to execute goal on project xxx:
Could not resolve dependencies for project xxx:
Could not find artifact brugo:brugo:jar:0.1.0 in
brugo (https://github.com/brugo/brugo/raw/repository/) -> [Help 1]
I tried an mvn clean install -U several times, but without success.
I had the same problem on a different computer yesterday, then suddenly I got it to work without really knowing how.

Special thanks to #wargre for pointing me in this direction.
It's indeed easier (and more convenient) to set it up to be directly in the central maven repository.
http://central.sonatype.org/pages/ossrh-guide.html explains all the required steps. Here follows a summary.
First release:
Create a JIRA account and a project
Add plugins to the pom.xml file
Add more meta to the pom.xml
Download/install GPG and create keys
Create a settings.xml which contains your credentials.
Run mvn clean deploy
Verify the result in the staging repository
Release when happy, drop and retry while unsatisfied.
Post a comments on the JIRA ticket
Admire the result in the maven central repository.
Consecutive releases:
Update the version number in pom.xml
Run mvn clean deploy
Release (manual/automatic)

Related

Running Maven for Gephi

I would like to create a plugin for Gephi but I got an error when running Maven and the project is not supported since 4 years... I already posted my question as an issue but I think no one will answer me now.
I forked the git and tried to follow instructions in the README to create my own plugin, but when I run this command :
mvn clean package
I constantly get this error :
[ERROR] Failed to execute goal on project gephi-plugins: Could not resolve dependencies for project org.gephi:gephi-plugins:pom:0.9.2: Failed to collect dependencies at org.gephi:gephi:tar.gz:linux:0.9.2 -> org.netbeans.cluster:platform:pom:RELEASE82: Failed to read artifact descriptor for org.netbeans.cluster:platform:pom:RELEASE82: Could not transfer artifact org.netbeans.cluster:platform:pom:RELEASE82 from/to maven-default-http-blocker (http://0.0.0.0/): Blocked mirror for repositories: [netbeans (http://bits.netbeans.org/nexus/content/groups/netbeans/, default, releases)] -> [Help 1]
I'm new with Maven and issues #77 and #214 didn't help me, I just followed instructions in the README file.
I followed the link given by the error and a blank page with this text appeared :
Repository decommissioned. Please refer to https://netbeans.apache.org/about/oracle-transition.html for more information.
And after clicking the link above, I thought this part was interesting :
As of March the 6th, 2021, we’ll be standing on our own feet, and all the Apache NetBeans Project source and convenience binaries will be hosted by the Apache Infra Team.
And then, a "new" code for handling netbeans repository
<build>
<repositories>
<repository>
<id>netbeans</id>
<name>NetBeans</name>
<url>http://netbeans.apidesign.org/maven2/</url>
</repository>
</repositories>
<build>
Is that possible that the pom.xml file is not up to date ? Or am I missing something ?
I spoke with someone who already used Maven at the office and he said that none of gephi repositories are working with Maven, all of them display the error.
Thanks for the help !
Finally the solution was quite simple :
The NetBeans repositories have indeed changed, so, in modules/pom.xml :
<repository>
<id>netbeans</id>
<name>NetBeans</name>
<url>http://bits.netbeans.org/nexus/content/groups/netbeans/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
We have to change the <url> tag to :
<url>http://netbeans.apidesign.org/maven2/</url>
I did that and it didn't work because my Maven version didn't support non secure url repositories (http) and I need to add a "s" in order to make it works.
<url>https://netbeans.apidesign.org/maven2/</url>
For a reason that I don't know, the project still not compile and we have to go to the parent pom.xml on the root folder and add the same NetBeans repository than above.
After doing that it compile.
I don't know if this is normal, but I'm new to Maven and I didn't know : if you want to use some gephi packages in your module (and wou want) you have to add them into module/YourModule/pom.xml in the <dependencies> tag ! Like that :
<dependencies>
<dependency>
<groupId>org.gephi</groupId>
<artifactId>layout-api</artifactId>
<version>0.9.2</version>
</dependency>
<dependency>
<groupId>org.gephi</groupId>
<artifactId>graph-api</artifactId>
<version>0.9.2</version>
</dependency>
<!-- ... -->
</dependencies>
I tested it with the GridLayout plugin from the Gephi Plugins Bootcamp and it worked.

Downloading jar from github repo fails while using maven compile

I am new to Maven. Using the instructions mentioned here: http://activeintelligence.org/blog/archive/hosting-maven-repository-for-third-party-jars-on-git-bitbucketgithub/, I created a github maven repo for third-party jar. I can see the jar (and the corresponding pom) here: https://github.com/sushilmittal/wiki-keyword-extraction/tree/master/repository/com/rapid_i/rapidminer/5.3.006
My pom.xml has these two entries corresponding to the above jar:
<dependency>
<groupId>com.rapid_i</groupId>
<artifactId>rapidminer</artifactId>
<version>5.3.006</version>
</dependency>
and
<repositories>
<repository>
<id>wiki-keyword-extraction</id>
<url>https://github.com/sushilmittal/wiki-keyword-extraction/tree/master/repository/</url>
</repository>
</repositories>
When I do mvn compile, I get the following warning:
Downloading: https://github.com/sushilmittal/wiki-keywordextraction/tree/master/repository/com/rapid_i/rapidminer/5.3.006/rapidminer-5.3.006.pom
[WARNING] Checksum validation failed, expected https://github.com/sushilmittal/wiki-keyword-extraction/tree/master/repository/com/rapid_i/rapidminer/5.3.006/rapidminer-5.
3.006.pom
which further leads to the following error:
[ERROR] Failed to execute goal on project DataIndex: Could not resolve dependencies for project DataIndex:DataIndex:jar:0.0.1-SNAPSHOT: Could not find artifact com.rapid_i:rapidminer:jar:5.3.006 in wiki-keyword-extraction (https://github.com/sushilmittal/wiki-keyword-extraction/master/repository/) -> [Help 1]
If I manually go to the location https://github.com/sushilmittal/wiki-keywordextraction/tree/master/repository/com/rapid_i/rapidminer/5.3.006/, I can see the files. So I fail to understand why maven is unable to download the jar/pom from that location.
Any ideas?
First off, please read this post
Second, using a source control system as a Maven Repository is a really bad plan. The recommended thing to do is use a Maven Repository Manager. There are at least three implementations available and there is even an on-line hosting service.
Thirdly, if you insist on following this misguided plan, you need to tell Maven the https path to the raw files in the GitHub repo, not the HTML rendering of the file content with line numbers etc

How can i use SVN as Maven Repository

I am working on project which has multiple dependencies. Most of the dependencies are available at our centralized maven repository. My project includes some JARs which only specific to my application and unavailable at our Maven repo. Due to some policy/restriction i cant deploy that jars to our maven repository.
When i install these jars in my local repository(i.e.UserHome/.m2/repository) and compile the code its working fine.
Now i want these dependencies in SVN so that we can build the application package using Continuum.(We cant refer local dependency from Continuum server.)
Just to achieve these i copied the locally installed dependency from .m2/repository and committed it in SVN. Then i declared repository in pom.xml like..
<repositories>
<repository>
<id>repo.pu</id>
<name>repo.pu</name>
<url>https://URL/migration2/APP1/src/main/lib/</url>
<layout>default</layout>
</repository>
</repositories>
Now to use dependency from above repo i added code like...
<dependencies>
<dependency>
<groupId>repo.pu</groupId>
<artifactId>Ptestval</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
When i type mvn verify i am getting the below error..
[ERROR] Failed to execute goal on project APP1: Could not resolve dependencies f
or project fileservices.migration2:APP1:jar:1.0: Failed to collect dependencies
for [repo.pu:Ptestval:jar:1.0 (compile)]: Failed to read artifact descriptor for
repo.pu:Ptestval:jar:1.0: Could not transfer artifact repo.pu:Ptestval:pom:1.0
from/to repo.pu (https://URL/migration2/APP1/src/main/lib/): Access denied to:
https://URL/migration2/APP1/src/main/lib/repo/pu/Ptestv
al/1.0/Ptestval-1.0.pom -> [Help 1]
Could you please someone help me to resolve these issue?
EDIT: I created a repository like ..
<repositories>
<repository>
<id>repo.pu</id>
<name>repo.pu</name>
<url>https://SVNUserName:SVNPassword#SVN_URL/BaseProj/ProjA/src/main/lib</url>
<layout>default</layout>
</repository>
</repositories>
This technique works perfectly at my Personal laptop. Maven downloads the listed dependency from repo.
But when tries to use the same in my project on company network it is not working .. It gives the same error which i was getting before using this approach.
Can anyone help me please? What would be problem? Is it a network issue?
Set up a repository manager like Nexus and don't abuse Subversion for something it was not designed for. This is unfortunately done in Google Code.
You must configure your project to use wagon-scm.
See http://maven.apache.org/wagon/wagon-providers/wagon-scm/usage.html

Jenkins builds not honoring third party repositories?

I'm hosting ojdbc14.jar on my network nexus instance, but only local builds seem to pass.
I have this in my pom:
<repositories>
<repository>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
<id>thirdparty</id>
<url>http://server/nexus/content/repositories/thirdparty</url>
</repository>
</repositories>
After completing removing ~/.m2/, a local mvn package will find ojdbc14.jar on nexus. My jenkins builds, conversely, consistently fail on this:
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal
org.csodehaus.mojo:sql-maven-plugin:1.3:execute (sql-ddl) on project mongo-dbunit: Execution
sql-ddl of goal org.codehaus.mojo:sql-maven-plugin:1.3:execute failed: Plugin
org.codehaus.mojo:sql-maven-plugin:1.3 or one of its dependencies could not be resolved: Could not find artifact com.oracle:ojdbc14:jar:10.2.0.4.0 in central
Why?
(http://repo1.maven.org/maven2)
Before you do anything, install Config File Provider Plugin
Then,
Go to Jenkins root page
Choose 'Manage Jenkins'
Choose 'Configuration files'
Choose type 'Maven settings.xml file'
Name it 'custom-maven-settings' and cut and paste contents of your ~/.m2/settings.xml file
Now back to your Maven2/3 job.
In the Build section click Advanced button
In the Maven Settings Configs drop down box choose custom-maven-settings
This setup works with our custom repository.
You have a <repositories> section in your POM, but not a <pluginRepositories>. Maven used to be a lot more sloppy about the difference between compile-time artifact dependencies and plugin dependencies, but in newer versions of Maven they're completely separate.
As others have pointed out, it might be easier to troubleshoot this by running Maven from the command line, outside of Jenkins. Just doing a build on a different machine than the one you are typically developing on will usually bring a lot issues to light.
Here's some documentation on the POM that may or may not be helpful.
I'd check and make sure that the Maven settings are the same on both machines.
Jenkins by default uses the file in $HOME/.m2/settings.xml. It's also possible for a Jenkins job to override this default.

How can I figure out where Maven got an artifact from?

I just spent half an hour working with a colleague to figure out why I could build a project when he (working from the exact same source) could not. Common start to a story about Maven, I know. Anyway, it turns out that we had a dependency on something like org.apache.commons:commons-pool, while the repo we pointed to only supplied commons-pool:commons-pool. We both overlooked the difference for a long time until we finally caught on. I must have been able to "see" the former, while he obviously could not.
So my question is: how can I ask Maven "where are you getting X:Y from"?
Bonus questions: If it's only showing up in the local cache, is there any way to tell how it got there? Can I tell Maven "just this once, make sure everything you're using in the build is also available from my remote repo"?
Maybe you have repositories available on your settings.xml that your friend don't.
As Ed Staub said you can try to clean your local repository by executing:
mvn dependency:purge-local-repository
After that try to download all your project dependencies by running:
mvn dependency:go-offline
Now if you have a problem with the last goal saying it could not find for example the artifact org.apache.commons:commons-pool you can try to find its repository going to http://www.mvnbrowser.com and searching for this artifact, then on the results page you can select the tab Repositories to see where you can find this artifact (for example JBoss maven repo).
After getting the artifact group, id, version you can add the repository where it's located to your project by adding the current content to your pom.xml:
<repositories>
<repository>
<id>repository.jboss.org-public</id>
<name>JBoss repository</name>
<url>https://repository.jboss.org/nexus/content/groups/public</url>
</repository>
</repositories>
Then if you try to download the dependencies again it now should work.
mvn dependency:go-offline

Resources