How do I let jenkins and m2eclipse share the same maven repository - eclipse

How do I configure m2eclipse ( maven plugin for eclipse ) to use a centralized maven repository that is also used in jenkins.
The default user settings in m2eclipse is something like "home/user/.m2"
How can we do something like "ssh user#192.168.1.200:/var/lib/jenkins/.m2"?

A neat and easy way to do it is to use a repository manager. Sonatype's Nexus seems to be the most popular, but there are others (e.g. JFrog Artifactory and Apache Archiva). They run as HTTP servers, and you can change your Maven configuration (both locally and for Jenkins) to use it as a mirror for any Maven repository (e.g. the Central Maven repo), or use it to host your own repositories.

There is no need to do that. Your POM files list dependencies and they list repositories. Maven will then resolve your dependencies against all known repositories (the listed ones and the "build-in" ones, like Maven central).
Maven will do this in m2eclipse, when running a Maven build. Maven will also do that when running the build on Jenkins. So if both machines can connect to all the repositories listed in your POM files, both will retrieve the same artifacts and both will do the same builds.
You should really not try to share the local copy of the artifacts. That is as bad as if I and you try to share our Maven artifacts using a network share. Maven is designed to find and manage those artifacts and you are trying to do its job with this question.

Related

How to backup and access jbpm 7.3 maven artifactory and git repository

We want use JBPM 7.3 for business rules development and testing. However for execution we will execute kie-base in our application, which is in java. For this we require access to JBPM maven repository.
How to fetch kjar from jbpm maven repository in my development environment using pom.xml. I mean, can i access jbpm 7.3 maven repository, if yes what is repository url.
JBPM 7.3 doesn't provide backup option for git repository and maven artifactory. Is there any recommendation, if yes. how to setup that Or it is not require, JBPM will auto take care of this. ( JBPM doesn't provide any setting option for maven and git repo.)
Please let me know, if more detail require.
This section of the official documentation shows you how to clone a project from the Kie Workbench into your local environment and to run some tests using maven. It also shows you how to get the repository's URL.
As you can see, each project in the Kie Workbench belongs to a single maven repository containing a maven project inside.
As far as I know, there is no automatic backup feature. There is another part of the documentation that explains how to configure a VFS Cluster. You can use this as a way of keeping 2 git repositories in sync. But that is probably too much work. For a simple backup mechanism you can create a CRON job that keeps a backup repository always in sync with the repository in your Kie Workbench.
Hope it helps,

SBT library dependency on Github released JAR

I have a project on Github and I have set a release with a Jar for that project. I want to include this Jar in another project as an SBT dependency. How do I set up the resolvers to look for my jar in the github repo.
You want to release your jar into a repository. One option I would recommend is bintray, see bintray-sbt which is an sbt plugin for publishing to bintray, and details how to setup your second project to fetch the publish artifact.

Combining Gradle with Ivy and sources for eclipse

We use Gradle to build our projects and to manage our dependencies. We want to reuse our legacy Ivy repository which is filesystem based. Our convention was to have several artifacts per module - one of them being a source artifact.
The normal jars are perfectly managed by the Gradle Eclipse integration. But we are not shown the source artifacts. Are there any conventions for this kind of setting, e.g. name of the source artifacts?
artifactName-sources.jar should work, as should defining a configuration named sources (and assigning sources artifacts to that configuration) in the iyy.xml.

Maven/Tycho/Eclipse : how to use published P2 Repo published in Maven repo?

I wonder how to make married eclipse development target definition and maven/tycho repository.
Suppose two teams A and B. The team A develops a target platform for team B.
In pure maven development without the help of Eclipse as development environment, the maven repository is the ideal tool to make communicate the both teams : when A releases a bundle, this one is published in the maven repository and available for team B when starting his maven generation.
But there is a problem for team B developping under Eclipse. Bundles published in repository by team A cannot be seen by Eclipse. The result is Eclipse cannot compile and link correctly... In fact, Eclipse becomes inefficient as a development environment.
I know that Tycho publishes P2 repository into Maven repository. But, how to use this published P2 repo ??? As far as I know, it is not possible de define an Eclipse Target Definition pointing to this published P2 Repository...
Any solutions ? Do you have the same problem ?
Thanks a lot for your help.
It should be possible to use the generated P2 repository. Did you create features for your bundles? Eclipse only recognizes features, if you want to configure your target platform.
If you use Nexus as repository manager and the OSGI metadata plugins for Nexus, then it isn't directly possible, because the metadata plugin for Nexus doesn't generate metadata for features. But there is development going on to bring that to the plugin.
This question is a lot like Handling non-OSGi dependencies when integrating Maven, Tycho and Eclipse
I use nexus with its p2 plugins, which provide both a maven and p2 repository. (You can pay to run nexus with p2 or you can install the older beta plugins, which work well enough.)
It's important to:
Use maven and p2 repositories
Properly setup your pom.xml files
Use the maven tycho plugin
The link above includes a discussion on how to do this.
FYI, it is possible to point to nexus p2 in you Target Platform definition.
Open your Target Definition
In Locations, select Add, and then select your nexus p2 update site

Tool for managing/hosting own p2 repositories?

Our company uses Maven. We use the Nexus repository manager in order to store our snapshots and releases.
Currently, we are developing a product based on Eclipse. We use Tycho to do that.
The problem is the following: In our Eclipse-based product we have many features. Our idea is build each feature (or group of features) separately and put them in internal p2 repositories. When one features requires another feature, we point the target platform to necessary internal p2 repository.
Currently, we build application with Tycho. We make our features "deployable", so Tycho produces a P2 site in target. We push that P2 site to our server and then run Eclipse FeaturesAndBundlesPublisher, which merges that recently-built feature with a P2 repository. As a result, we have a internal P2 repository having all the versions of required feature.
We find that this process is too cumbersome. Is there a tool like Nexus, which would be more convenient?
UPD.:There is a discussion on Tycho Users list
With the Unzip Repository Nexus Plugin, you can use Nexus for exchanging binary artifacts between Tycho builds.
Tycho project A publishes its artifacts like a normal Maven project: The project is built with mvn clean deploy, which uploads the project's artifacts into your deploy Maven repository on the Nexus. The only special requirement is that the project builds a p2 repository. The recommended way to do this is an eclipse-repository module, but a "deployable feature" should also work in most cases.
On your Nexus, you only need the following one-time configuration: For the deploy Maven repository (or a "Repository Group" which includes that repository), you need to add a virtual repository of type "Unzip Repository". This virtual repository shows zip artifacts from the deploy repository in unpacked form.
Example: If the p2 repository zip of project A is in the deploy Maven repository at http://nexus.corp/nexus/repositories/build.milestones/corp/example/project-a/project-a-repo/1.0.0/project-a-repo-1.0.0.zip, it will be available in standard p2 repository format in the Unzip Repository at http://nexus.corp/nexus/repositories/build.milestones.unzip/corp/example/project-a/project-a-repo/1.0.0/project-a-repo-1.0.0.zip-unzip/.
Tycho project B can reference the artifacts from project A by adding the latter URL to its target platform, e.g. in a target definition file.
In the above example, project B references a release version of project A. The same approach also works for snapshots because the Unzip Repository has support for "symbolic" versions, like 1.1.0-SNAPSHOT for the last deployed 1.1.0-SNAPSHOT or even just SNAPSHOT for the overall highest version. Using these symbolic versions, Project B can then, for example in its own CI build, reference the CI build results project A by adding the resulting (stable!) p2 repository URLs in its target platform.
Disclaimer: The Unzip Repository Nexus Plugin is part of the Tycho project, of which I'm a committer.
Maybe this is a bit late, but I am currently working on an open source (EPL) repository manager which supports the workflow of deploying to a repository with maven and tycho, and consuming it as P2 repository.
It is also possible to deploy bundles created by maven (not maven tycho) and the P2 metadata will be generated automatically.
The project is called "Package Drone" and hosted on github. There is also a short introduction video.