Get a Hudson build with Maven - eclipse

I have moved to Maven recently, and since it works fine for resources up to date in some repositories, it's not obvious for non-maven ones.
I have something very simple to achieve (in the idea), but that I am unable to express so far:
I need to compile my code with a jar that can be found here:
https://hudson.eclipse.org/hudson/view/WTP/job/cbi-wtp-wst.xsl.psychopath/ws/sourceediting/plugins/org.eclipse.wst.xml.xpath2.processor/target/
What do I have to put in my pom.xml to make Maven downloading the .jar + the java source + the javadoc, and eventually the other dependencies (actually IBM ICU, Xerces, JavaCup) that are mentionned in the supplied MANIFEST ?
I have read lots of documents, including those with a plugin called Tycho, but nothing helpfull for that simple task.
Thanks for your help.

Maven only works well if all artifacts needed for a build are contained in the local or a configured remote repository. So you have to do the following jobs:
Find out if eclipse plugins are deployed in a Maven2-style repository, and what the URL of that repository is.
Then find out which version of that plugin (artifact) you need.
Maven allows you to configure what will be copied locally: jar file, sources and api doc if you want to.
Maven should then be responsible to download as well all needed artifacts for the plugin you want to use.
After looking at the contents of the URL you gave us (especially the file p2content.xml), it looks like there should be a repository. I searched for the maven repository for org.eclipse.wst.xml.xpath2 and found the URL http://maven.eclipse.org/nexus/content/repositories/testing/org/eclipse/wst/org.eclipse.wst.xml.xpath2/1.1.0/org.eclipse.wst.xml.xpath2-1.1.0.pom
So the repository you are searching for is located at http://maven.eclipse.org/nexus. Just open it, search for example for xpath2, and Nexus, the repository software used there will you show the available artifacts. Depending on what was deployed to that repository, it may contain only the library, or have even sources and JavaDoc bundled with it. For the example above (xpath2), there seems to be only the POM itself and the library (the jar). If you take as example junit, you will find all versions and variants, even with sources.jar and javadoc.jar.
After you have found the needed artifact, you can include it in the dependency section of your POM. And you have to add http://maven.eclipse.org/nexus as a remote repository in the configuration of your Maven installation.
The question and its answer Get source JARs from Maven repository explain how to fetch sources and JavaDoc (if they are available).

You need a maven repository which contains this artifacts (i don't know, if Eclipse hosts a repository for their projects). You can also deploy manually the artifacts to a local repository on your computer.

Related

Attach sources in Eclipse Plug-in Dependencies container

We use eclipse and m2e to work with a tycho-based plugin.
Our problem is the sources of the dependencies are not attached:
Is there any way to make PDE/m2e download sources automatically and attach them to the dependencies?
You can try to install this pde.source.lookup plugin, that will look for matching source bundles in the available p2 repositories of your Eclipse installation, just like m2e does for Maven dependencies.
If the source jar exists in one the p2 repositories and it doesn't work for you (really it should), please open a bug to its issue tracker.
Now, if that doesn't work, i.e. the jar doesn't come from a p2 repository, another alternative is to install JBoss Tools' Maven source lookup feature, which is very similar to m2e's mechanism, but a bit more robust and more complete, as it'll look for sources in Maven Central and different Nexus repository managers, based on the SHA1 checksum of your jar. It's downside is it'll bring down a bunch of dependencies in Eclipse you don't necessarily need (JBoss Servers stuff)
When PDE creates the Plug-in Dependencies classpath container, source attachments are added based on what is known to org.eclipse.pde.internal.core.SourceLocationManager. While older source models are still supported (extension point), source is now typically delivered via source bundle. A source bundle will have a manifest entry describing what it provides source for.
Eclipse-SourceBundle: org.apache.ant;version="1.9.2.v201307241445";roo
ts:="libsrc"
If a source bundle is available for what you need source for, you can add that source bundle to your target platform and PDE will attach the source when creating the classpath container.
Alternatively, you can temporarily attach a source zip/folder to the entry.
PDE does not provide a service to search for source. One other option could be the "Add Artifact to Target Platform" dialog (Ctrl+Alt+Shift+A), which can search through known p2 repositories for the needed source bundle and add it to your target platform.

Not able to understand How maven works with Spring MVC

I made a Hello word example in springMVC.Following are my steps.
1.Installed maven-eclipse integeration in eclipse.
2.Download maven and set environment variables,JAVA_HOME etc.
3.Check to see if maven is running via cmd and it is.
4.Create new maven project and in pom.xml,set spring core,web,web-mvc dependencies.
5.Create new Dynamic web project and under its properties->Deployment assembly I have added maven project.
6.Added spring jars core,mvc,web,context etc in dynamic web project lib folder.
It's all working now but I am not able to understand the working.
Before,I was trying to make it work without maven by copy and paste jars into lib,classpath,by makiing user library and adding jars to it and then add it to current project but every time it was giving some error.Sometimes it was classnotfound,sometimes it was context related.
Finally i tried this maven thing by searching some online tutorials and it works now.
But I am not able get it.Can anybody explain me in detail that how those spring jars getting picked during development and deployment.What exactly is maven doing that I was not doing before.I am in the state of total confusion.I know the flow of my mvc project(controllers,views etc.).
Maven searches the libraries (they are also called artifacts in the Maven language) in repositories. In the Maven Central Repository many libraries are hosted - http://search.maven.org/. After Maven finds the libraries in a repository, it caches them in your local repository. It is in ${userDir}/.m2 The next time, Maven will look in your local repository, instead of downloading again from the Central Repository.
P.S You can specify many other repositories different than the Central Repository. This is done in the <repositories> tag in your pom.xml. The Central Repository is always searched by default.
if you don't want use maven you have change your project setup. remove the pom.xml and copy all needed jar into the webapp/WEB-INF/libs folder.
Copy the jar from the a maven build(target folder). in this case you have all together without grabbing them one by one over then.

is there a way to generate a pom.xml with dependencies from an eclipse project?

I have inherited a big project with several subprojects.
all of them use several jar files, all of them located under each project's lib directory. I want to take all the projects and migrate them to maven, but dependencies are a problem (too many of them), some of them are commonly used libraries (apache projects, xerces, jms, etc) and others are not.
is there a way to autogenerate maven dependencies for those jars that can be found on public maven repositories. for example, see that my project use the spice-jndikit-1.2.jar file and automatically get the appropiate depedency with group, artifact and (if possible) version?
thank you
I wrote a groovy script to generate a starting set of Apache ivy files.
https://github.com/myspotontheweb/ant2ivy
In my case, I wanted to "Maven-ize" my ANT builds without switching completely away from ANT.
It is feasible to extend this code to generate a Maven POM, if people were interested in this feature.
You can convert a project to Maven using the m2e plugin, but this erases your jar references, and should not be used.
I doubt that such a thing exists since typical jars (unless themselves built with Maven) don't have the necessary information to correlate the groupId, artifactId and version back to a repository to get the proper path.
You might be able to write something that parses the file name for the name and version, but you still have the package-based path to figure out.
If you're building using Ant, you might also consider using Apache Ivy, and its file-system based resolution (very fast and easy to configure), to get you started, and slowly role over to the Maven repos for the artifacts, this way you're not spending a lot of time up-front finding Maven dependencies.

How can I automatically build multiple Eclipse Plug-In Projects as one Jenkins project?

we're using Jenkins as our build server. We have a Project which is built out of Eclipse Plug-Ins, a core project and several other plugins. Building the Core on Jenkins and using Sonar on it is relatively.
Now we want to create a Jenkins build where the whole Project is being automatically built and tested by Sonar. Internet research showed to change the packaging to "pom", which can't be done because the Tycho plugin needs to have packaging set to "eclipse-plugin".
What are we doing wrong and how do you setup a project like this in Jenkins?
If any additional information is needed, please do tell.
You should create an "umbrella" Maven project with pom packaging and make all of your other project modules of this aggregator. In addition however the whole group of projects need to be accessible from your SCM tool as a single entity. If you are using Subversion this is easily achievable by means of svn:externals, with other tools I suspect you'd have to alter your configuration. I suggest you also check out whether there's any Jenkins plugins that might be of help.
For git, you can use the submodules feature to achieve the same as with svn:externals. See for example mylyn, which probably comes close to what you are trying to achieve:
git clone git://git.eclipse.org/gitroot/mylyn/org.eclipse.mylyn.git
Given this example directory layout:
+ParentDir
-pom.xml
+ProjectA
-pom.xml
+ProjectB
+SubDirB
-pom.xml
Contents of pom.xml in ParentDir should include the following:
<packaging>pom</packaging>
<modules>
<module>ProjectA/pom.xml</module>
<module>ProjectB/SubDirB/pom.xml</module>
</modules>
And when you invoke Maven on this top-level POM, it will add ProjectA and ProjectB to the reactor list to be built.
This can be adapted for similar projects, and the <module> tag accepts relative paths, for example ../../SomeProject/pom.xml.

Local Project Dependencies and Maven

I'm converting an ant backed Netbeans project into an Maven project. I've got most of the third party libraries set up in the POM, however now I've run into problems with setting up the local dependencies.
With the previous Netbeans way of doing things, it just added a project reference [with links to the source and jar location, rebuilt the dependency if the depedency's source had been changed and hadn't been compiled]. However I'm not sure how to setup up Maven to emulate this behavior. Is it possible?
Example:
Projects/SharedLibrariesResource [Ant based project]
Projects/WebSite [this is a maven based project]
Projects/Client
In this example the website and client projects don't connect to each other, but they do share the SharedLibrariesResource. Website should compile to produce a War with links to the SharedLibrariesResource
The way I understand the question, the Website maven project depends on the ant SharedLibrariesResource project. When Website is built, it should include the SharedLibrariesResource artifacts. The assumption is SharedLibrariesResources produces a jar artifact.
One way to achieve this is to
install SharedLibrariesResource to your local maven repository each time ant builds it
specify this as a dependency in Website pom.
We can use maven ant tasks to achieve the first.