Publishing local libraries to remote maven repository - java

I have a set of libraries which I want to publish into our organization's remote maven repository. Right now I have created a local directory and put all the libraries there.
I have specified this local directory as the repository using the below :
<repositories>
<repository>
<id>project-repo</id>
<name>custom repo</name>
<url>file://${project.baseUri}/../repository</url>
</repository>
</repositories>
I want to migrate all the libraries under this repo to our organization's central repo located at http://mvn.app.xyz.repo.com.
How do I achieve it? How can I copy the libraries from the "project-repo" to the central repo?
I'm using maven version 3.1-1

Try the Maven Deploy Plugin: mvn deploy:deploy-file.

Related

Maven tycho to point to local p2 eclipse repository

I have a set of plugins in eclipse with a product. My goal is to automate the deliveries: passing automatically test, creating automatically features and update sites...I found tutorials like this one http://www.vogella.com/tutorials/EclipseTycho/article.html#exercisetycho_configuration_parent and it works great on my personal laptop where I have internet but not on my work computer because I don't have access to internet. The part that is the problem is the configuration of the properties for the build:
<properties>
<tycho.version>0.25.0</tycho.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<mars-repo.url>http://download.eclipse.org/releases/mars</mars-repo.url>
</properties>
<repositories>
<repository>
<id>mars</id>
<url>${mars-repo.url}</url>
<layout>p2</layout>
</repository>
</repositories>
I want to point my url to my p2 repositories in eclipse repository and not on the internet. Is there a way to do it?
Thanks a lot for the help
Build the features locally using mvn clean install in the features directory. This should generate /target/repository.
Then, in your product pom.xml, you can update the repository to point to this local repo:
<repositories>
<repository>
<id>mars</id>
<url>file:/C:/path-to-target/target/repository</url>
<layout>p2</layout>
</repository>
</repositories>
A mvn clean package in the products directory should give you an assembly using the local features.
There are also a couple slight variations of this answer in the answers section over here: Build local eclipse plugins using tycho pointing to local p2 repository

Using Dropbox as Maven Repository

Since the Github plugin for hosting maven repositories within Github is not working anymore, I am trying to find some other quick way to host a maven artifact.
One way I am thinking is to use my Dropbox 'Public' folder (since I still have it active now) and host the artifact from there.
What could be the approach to use Dropbox as maven repository?
Is there a plugin to use Dropbox as maven repository?
For people who share a common Dropbox folder, you can set it up as a Maven repository using this configuration in your project/pom.xml or maven/conf/settings.xml:
<repositories>
<repository>
<id>localDropbox</id>
<url>file://[path to Dropbox folder]</url>
</repository>
</repositories>
And to use mvn deploy to send artifacts there:
<distributionManagement>
<repository>
<id>localDropbox</id>
<url>file://[path to Dropbox folder]</url>
</repository>
</distributionManagement>
If the folder is publicly available, people who want access to that could have a http URL instead of filesystem URL in their <repository> declaration.

blacklisting a maven repository

When I run an integration test for my project, it is trying to search in a repo that is being pulled transitively and I need to wait for time out. I blacklisted that repo like this.
<repository>
<id>seacrh-snapshots</id>
<name>Exodus Snapshot Repository</name>
<url>http://repo URL/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
but it is still pulling this repo when I run the IT test:
Downloading: URL repo/maven-metadata.xml
Is there anything else that need to be changed?
I strongly recommend to use a Maven Repository Manager such as Nexus. It will help you to get stable and reproducible builds with Maven. You can disable Repositories there (or Nexus can handle this for you as well).
http://www.sonatype.com/books/nexus-book/reference/maven-sect-single-group.html
http://maven.apache.org/repository-management.html
Normally, when maven runs it goes to fetch artifacts in the following order
it check your local .m2/repositories folder
if it can't find the artifact then it reads your pom / parent pom/ super Pom / user level setting.xml/ global setting.xml - in that order to find external repositories to download the artifacts from, usually these repo are either directly from the internet (like the pre-configured default maven repositories) or local private repo managers(like nexus, Artifactory).
Maven will execute the repo as in the order in which they are declared.
First of all, check your project effective-pom that nothing else is overriding your configuration. either in the terminal by typing mvn help:effective-pom on the project root dir or easily in eclipse "effective pom" view of your pom.
Otherwise, it's a good use-case for you to consider installing local repository manager as you would not always need to fetch externally your third party dependencies everytime you run maven.
i would recommend Artifactory much better than the nexus.

Maven coordinates for vert.x?

I am trying to add vert.x in a maven project, but it seems like it is not in the central repository. Am I wrong?
If it is available from Maven, what are the dependency coordinates? Thanks.
We haven't uploaded vert.x into Maven Central yet, but it is near the top of the TODO list.
I'll update this post when it's done.
[UPDATE]
The next release is imminent and will feature a Gradle-based build and Mavenised modular components, amongst other things.
The Maven co-ordinates will be: "org.vert-x:vertx-%stuff%:%version%".
(Note the dash: The project doesn't currently own the org.vertx domain, so Maven wouldn't let us use it.)
[UPDATE2]
vert.x 1.2.1.final was released into Maven Central, with coordinates as above.
In Gradle for example:
repositories {
mavenCentral()
}
dependencies {
compile "org.vert-x:vertx-core:1.2.1.final"
compile "org.vert-x:vertx-platform:1.2.1.final"
}
See http://github.com/vert-x for examples of how we're using Gradle to build modules.
If there are no vert.x artifacts in public Maven repos you can distribute the library with your project using a local (project based) repo using:
<repositories>
<repository>
<id>local-project-repo</id>
<url>file:${basedir}/lib/repository</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
After that, you only need to recreate a Maven repo structure (groupId, artifactId, version) in /lib/repository.
This approach will prevents you the need to install the vert.x dependency in each environment you want to compile the project.
I couldn't see a "pom.xml" file in the vert.x source code rep, or a Maven artifact in Maven Central, so I think you are out of luck ... for now.
You could always download the vert.x sources, do a local build, slap together a minimal POM file (with your own invented group/id/version) and install it into your local repo. That will tide you over until the developers complete the Maven-ization and publication.

Please help get started with creating a simple project using eclipse, spring, maven

I installed maven and configured based on their 5 minute tutorial
Created a eclipse project using Maven
Installed Maven Integration for eclipse by going to eclipse market place
Added dependencies (spring, log4j) to pom.xml by getting the xml snippet from mvnrepository.com
right click on pom.xml and run as Maven Install.
I was not able to use the new jar files immediately, had to do mvn install several times and finally all the jar files are showed up in the project.
what could be the problem? Is it not updating the class path correctly?
My questions are:
Are my steps above correct?
I see all the dependent jar files in the main folder. I want to place these jar files under lib folder. How do i do that?
How can i add external jar file to the repository, these are not in mvnrepository
How do i generate ear file to be deployed to weblogic?
Edit: Attached the screenshot of the repository
Edit2: i picked the wrong project type. Once i picked webapp archetype, it puts all dependencies in "Maven Dependencies". This is related to my second question.
For your question 3 : You can add any public maven repositories in to your pom file which contains your required jar files.
http://forum.springsource.org/showthread.php?63612-Maven-repository-location
or else if you have that jar file in your local machine you can manually install it into maven repository.
mvn install:install-file -Dfile=<path-to-file> -DgroupId=group-id
-DartifactId=artifact-id -Dversion=version -Dpackaging=packaging
As per the Guide to installing 3rd party JARs.
For your 2nd question you can use:
http://maven.apache.org/plugins/maven-dependency-plugin/
If you are using m2eclipse, be sure to right click on the project, select Maven and then "Update project configuration". That should be enough. I assume that you added the Maven project nature already.
After you create project use can use this command
mvn eclipse:eclipse -Dwtpversion=2.0
then install m2eclipse from eclipse marketplace. What I am doing generally is right click eclipse, import/import new maven project and choose my new maven project. Afer import if you dont see your jar folder under Libraries node of project tree, then right click build path/libraries/add class path and choose related folder.
If your library not available in current repository you can use another external repository with below tag: (jboss and java.net repos are very common)
<repositories>
<repository>
<id>java.net2</id>
<url>https://repository.jboss.org/nexus.</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<enabled>false</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</snapshots>
</repository>
</repositories>

Categories