How can i use SVN as Maven Repository - maven

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

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.

Maven repository that sometimes works

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)

How can I add maven artifact into an existing maven project

How can I add maven artifact into an existing maven project.I understand that I can build a jar locally and use file: protocol but this is possible using maven also.
For example I have a basic maven project
https://maven.apache.org/guides/getting-started/index.html#How_do_I_make_my_first_Maven_project and the artifact:
<repositories>
<repository>
<id>myrepo.org</id>
<name>MyRepository</name>
<url>http://mywork.com/repository</url>
</repository>
</repositories>
<dependency>
<groupId>org.ethereum</groupId>
<artifactId>ethereumj-core</artifactId>
<version>1.1.0-RELEASE</version>
I tried adding the code above to the project pom.xml fails because dependency is not in central maven repo.
mvn clean install
I then tried editing my settings.xml by adding the tag, that also failed because dependency was not found.
Im overlooking something pretty basic here.
Maven works on the concept of local and remote repositories.
The local repository refers to a copy on your own installation that is a cache of the remote downloads, and also contains the temporary build artifacts that you have not yet released.
Remote repository is repository you access the artifacts via file or http / ftp protocols , it can be an internal repo or a remote public hosted.
When you add dependency maven search that artifact in local if not found then remote repo will be searched. Still not found then error is reported.
https://maven.apache.org/guides/introduction/introduction-to-repositories.html
In your case, 'ethereumj-core' can not be located neither of location, you need find this jar and do a manual install to local repo.
mvn install:install-file -Dfile=< folder >\ethereumj-core.1.1.0-RELEASE.jar -DgroupId=org.ethereum
-DartifactId=ethereumj-core -Dversion=1.1.0-RELEASE -Dpackaging=jar
once properly installed maven should be able find this artifact when you add this as dependency to any of the projects (in pom.xml).
<dependency>
<groupId>org.ethereum</groupId>
<artifactId>ethereumj-core</artifactId>
<version>1.1.0-RELEASE</version>
</dependency>

Should I write repositories in my pom.xml?

I am new to Maven. If I start new project with Maven, should I know any repository URLs for it to work?
For example, this Hibernate tutorial http://docs.jboss.org/hibernate/core/3.3/reference/en/html/tutorial.html says about how to create a sample project with pom.xml text. But this pom.xml does not contain any repositories.
So, my m2eclipse plugin says, for example Project build error: 'dependencies.dependency.version' for org.hibernate:hibernate-core:jar is missing., for all dependency tag in pom.xml
Is this because of repositories absence?
Where to know repositories URLs? Is there one big repository? Why doesn't it included by default?
UPDATE 1
It is said here, that Maven should use "central" repository by default: http://maven.apache.org/guides/introduction/introduction-to-repositories.html
I have searched there for hibernate-code artifact and found it. So, this artifact IS in central repository. By my maven says dependency not found. Hence it doesn't use it's central repository. Why?
Apparently your Hibernate dependency is missing <version> tag:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.6.9.Final</version> <!-- this line is missing -->
</dependency>
Note that you don't have to specify version of dependencies previously declared in <dependencyManagement>.
Old answer:
Every build script (not only with Maven) should be reproducible and independent from environment. Standard pom.xml (called super pom), which every pom.xml inherits from, already defines main Maven central repository:
<repositories>
<repository>
<id>central</id>
<name>Maven Repository Switchboard</name>
<layout>default</layout>
<url>https://repo1.maven.org/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
You don't have to define this repository, and you don't have to define any others if all your dependencies are there. On the other hand if you are using some external repositories, you must add them to pom.xml, so that every developer is always able to build.
The bottom line is: if you can build the project having a completely empty repository, your pom.xml is fine.
It's not advisable to define repositories in POM files as that causes a lot of issues (Maven will search those repositories for ANY artifact even the ones available at Central, poor portability, ...)
Best approach: Setup a repository manager (Artifactory, Nexus) and edit your settings.xml file to use the repo manager as a mirror.
Second best approach: Define the required repositories in your settings.xml file, not in your pom.xml files.
Repositories in poms is a bad idea.

Maven Thrift repository

Does anyone know if the Thrift libraries are in any Maven repository?
0.6.1 artifacts now available from main apache repo (http://repo1.maven.org/maven2)
<dependency>
<groupId>org.apache.thrift</groupId>
<artifactId>libthrift</artifactId>
<version>0.6.1</version>
</dependency>
https://issues.apache.org/jira/browse/THRIFT-363
I'm not sure what the Thrift libraries are (next time, maybe add a link) but according to Maven Browser, there is a thrift artifact in the scala-tools repository:
<repositories>
<repository>
<id>scala-tools</id>
<url>http://scala-tools.org/repo-releases/</url>
</repository>
</repositories>
Update: I can't say much about the version (and the content) hosted in the scala-tools repository but this is very likely an artifact made available by the scala folks for their own needs. Actually, the Apache Thrift project is using Ivy and publishing the java library to a maven repository (it will be the Apache snapshots repository, see THRIFT-363) is something on which they didn't work until recently. But the issue is closed now and my understanding is that they will publish an artifact with the next release.
As of now there are not any available, you will have to include the jar in your local repository.
You can set up something like Artefactory, a local repository and add the libthrift.jar there.
http://mvnrepository.com/artifact/org.apache.thrift/libthrift
You can search Maven repository from there.

Resources