Add maven dependencies of OSGi bundles to the Eclipse target platform - eclipse

I have some OSGi-bundles (plain OSGi, no eclipse dependencies) and a maven build with pax runner that launches them in a Knopflerfish server.
The maven build and launching the bundles works perfectly fine but only via pax runner (mvn pax:provision).
For debugging the bundles it would be nice though to launch them directly from within eclipse, otherwise my breakpoints won't trigger (seems obvious, as pax:provision launches built jar-files that are not tied to eclipse anymore).
The MANIFEST.MF-file is built the usual maven-way, means using maven-bundle-plugin. Therefore launching the bundles directly from eclipse fails because the eclipse platform misses all that required external OSGi-bundles that maven gets doing it's maven magic.
Therefore I am looking for a way to set up my eclipse target platform somehow so that the OSGi-bundles from maven are automatically included and can be accessed from within the IDE for resolving the constraints at launch time.
I checked the target platform settings, but apparently one can only add specific jars and folders to it, not whole folder structures like it would require to use the whole local maven repository. If I need to update my target platform for every new dependency thats going to get really ugly (I'd wish I could do something like "add C:\Users\myprofile.m2\repository to target platform" and eclipse would just load what it needs).
While researching I found Eclipse Tycho but apparently this only compiles a target platform for building the bundles, but not for compiling and launching them from within the IDE. Next I found this site: http://andriusvelykis.github.io/pde-target-maven-plugin/ And this looks like exactly what I need. From the documentation it seems that this plugin is able to take the target platform that is compiled from eclipse tycho and write it to a file. Then I am able to import this file back into my IDE and use it as target platform.
The problem I have is, that the plugin quits with an error that I can't deduce (I turned on stacktraces for a more complete error message).
[ERROR] Failed to execute goal lt.velykis.maven:pde-target-maven-plugin:1.0.0:add-pom-dependencies (default-cli) on project orchestrator-parent: The parameters 'baseDefinition' for goal lt.velykis.maven:pde-target-maven-plugin:1.0.0:add-pom-dependencies are missing or invalid -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal lt.velykis.maven:pde-target-maven-plugin:1.0.0:add-pom-dependencies (default-cli) on project orchestrator-parent: The parameters 'baseDefinition' for goal lt.velykis.maven:pde-target-maven-plugin:1.0.0:add-pom-dependencies are missing or invalid
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:220)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
at org.codehaus.classworlds.Launcher.main(Launcher.java:46)
Caused by: org.apache.maven.plugin.PluginParameterException: The parameters 'baseDefinition' for goal lt.velykis.maven:pde-target-maven-plugin:1.0.0:add-pom-dependencies are missing or invalid
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.populatePluginFields(DefaultMavenPluginManager.java:581)
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:534)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:97)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 20 more
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginParameterException
This is the configuration for the plugin:
<plugin>
<groupId>lt.velykis.maven</groupId>
<artifactId>pde-target-maven-plugin</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<id>pde-target</id>
<goals>
<goal>add-pom-dependencies</goal>
</goals>
<configuration>
<baseDefinition>D:/platform.target</baseDefinition>
<outputFile>D:/platform-pde.target</outputFile>
</configuration>
</execution>
</executions>
</plugin>
I can see that the paths are correct because the platform-pde.target file is created, but it has the same content as the base file.
File content (just a standard target platform that I created and shared as the base file):
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde version="3.8"?><target name="OrchestratorPlatform" sequenceNumber="8">
<locations>
<location path="${eclipse_home}" type="Profile"/>
</locations>
<environment>
<os>win32</os>
<ws>win32</ws>
<arch>x86_64</arch>
<nl>en_US</nl>
</environment>
<launcherArgs>
<vmArgs>-Dosgi.requiredJavaVersion=1.6 -Xms40m -Xmx512m</vmArgs>
</launcherArgs>
</target>
What I am looking for are tips on how to configure the plugin correctly or any other ways I can bring my maven dependency bundles into my target platform so that I can launch the bundles directly from eclipse without having to maintain the dependencies somewhere in the depths of eclipse preferences again.

You can give a try to run PAX with defining vm options for your test container. By default the container is started in a separate JVM, and you can define command line options for it. In the documentation even you will find an example to start the tests in debug mode. Just define suspend=y, and you will have enough time to attach your Eclipse with a remote debugging session.
There is also an eclipse plugin for Pax Runner, you can try that.
EDIT:
With the launch config you sent me in the comment, you debugged the maven JVM, and not the OSGI container.
It is tricky to find documentation for pax:provision. I tried help:describe:
C:\>mvn help:describe -Dplugin=org.ops4j:maven-pax-plugin:1.5 -Dgoal=provision -Ddetail
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-help-plugin:2.2:describe (default-cli) # standalone-pom ---
[INFO] Mojo: 'pax:provision'
pax:provision
Description: Provision all local and imported bundles onto the selected
OSGi framework
mvn pax:provision [-Dframework=felix|equinox|kf|concierge] [-Dprofiles=log,war,spring,...]
If you don't have Pax-Runner in your local Maven repository this command
will automatically attempt to download the latest release. It will then
continue to use this locally installed version of Pax-Runner unless you add
-U to force it to check online for a later release, or -Drunner=version to
temporarily use a different version.
Implementation: org.ops4j.pax.construct.lifecycle.ProvisionMojo
Language: java
Available parameters:
args
User property: args
URL of file containing additional Pax-Runner arguments.
deploy (Default: true)
User property: deploy
When true, start the OSGi framework and deploy the provisioned bundles.
deployPoms
User property: deployPoms
Comma separated list of additional POMs with bundles as dependencies.
deployURLs
User property: deployURLs
Comma separated list of additional bundle URLs to deploy.
framework
User property: framework
Name of the OSGi framework to deploy onto.
noDependencies
User property: noDeps
Ignore bundle dependencies when deploying project.
profiles
User property: profiles
Comma separated list of additional Pax-Runner profiles to deploy.
provision
User property: provision
A set of provision commands for Pax-Runner.
runner (Default: RELEASE)
User property: runner
The version of Pax-Runner to use for provisioning.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.570s
[INFO] Finished at: Wed Feb 19 00:01:05 CET 2014
[INFO] Final Memory: 8M/109M
[INFO] ------------------------------------------------------------------------
So as it seems:
Create a file containing the following text:
--vmOptions=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8888
Run your build like this:
mvn pax:provision -Dargs=file:///c:/yourfilepath/thefilecontainingstuffabove.txt
I did not try it, but it can work. Suspends, port 8888, Eclipse Remote Debug :)

I am using remote debugging with Apache Karaf a lot. There karaf also loads the bundles from the maven repository.
Still eclipse finds the breakpoints and triggers them. So the same should work for pax runner.
What I do is to export KARAF_DEBUG=true and start karaf. This triggers the typical remote debugging settings which should also be available for pax runner. I then start a remote debug session from eclipse and simply add all necessary open eclipse projects to the sources of the remote debug session. This works almost all of the time. Sometimes my breaktpoints are also not triggered but it is very seldom and I did not find out why.
Btw. Karaf also allows to update bundles from the local maven repo while running. So if you change a project you can simply call mvn clean install on the single bundle project, do "update bundleid" on the shell and can continue to debug with the new version of the bundle. This is extremely helpful when you got a large project but only work at a small part while debugging.
So to resume you should be able to use pax runner with remote debugging without problems and it might also be interesting to take a look at apache karaf.

Related

Installation of custom eclipse plug-in available at github

I am trying to install a plug-in to eclipse from an update site. But, somehow that is not working (might be tool has ended support from update site). Although, i have found source code of plug-in from github(but it is not compiled version). I could download it as zip file. But, I am facing issues related to installation. It contains lot of plugin.xml files in different folders. But, i am not sure, which one to use.
This is the url for plug-in source code.
please help with the steps to install eclipse plugin from source code.
#ChandrayyaGK : I have followed steps mentioned in your answer.I am facing following error.
[INFO] Fetching org.eclipse.graphiti_0.11.4.v20150701-1432.jar.pack.gz from http://archive.eclipse.org/graphiti/updates/0.11.4/plugins/ (0B of 83.9kB at 0B/s)
[ERROR] Internal error: java.lang.NullPointerException -> [Help 1]
org.apache.maven.InternalErrorException: Internal error: java.lang.NullPointerException
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:164)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: java.lang.NullPointerException
at org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository.downloadArtifact(SimpleArtifactRepository.java:665)
at org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository.downloadArtifact(SimpleArtifactRepository.java:590)
at org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository.getArtifact(SimpleArtifactRepository.java:724)
at org.eclipse.tycho.repository.p2base.artifact.repository.RepositoryArtifactProvider.getArtifactFromOneMirror(RepositoryArtifactProvider.java:209)
at org.eclipse.tycho.repository.p2base.artifact.repository.RepositoryArtifactProvider.getArtifactFromAnyMirror(RepositoryArtifactProvider.java:192)
at org.eclipse.tycho.repository.p2base.artifact.repository.RepositoryArtifactProvider.access$1(RepositoryArtifactProvider.java:187)
at org.eclipse.tycho.repository.p2base.artifact.repository.RepositoryArtifactProvider$1.perform(RepositoryArtifactProvider.java:167)
at org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository.getArtifact(SimpleArtifactRepository.java:708)
at org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository.getArtifacts(SimpleArtifactRepository.java:779)
at org.eclipse.tycho.repository.p2base.artifact.repository.RepositoryArtifactProvider.getArtifactFromAnyChildRepository(RepositoryArtifactProvider.java:179)
at org.eclipse.tycho.repository.p2base.artifact.repository.RepositoryArtifactProvider.getArtifactFromAnyFormatAvailableInRepository(RepositoryArtifactProvider.java:149)
at org.eclipse.tycho.repository.p2base.artifact.repository.RepositoryArtifactProvider.getArtifactFromAnySource(RepositoryArtifactProvider.java:135)
at org.eclipse.tycho.repository.p2base.artifact.provider.CompositeArtifactProviderBaseImpl.getArtifact(CompositeArtifactProviderBaseImpl.java:50)
at org.eclipse.tycho.repository.local.MirroringArtifactProvider.downloadCanonicalArtifact(MirroringArtifactProvider.java:236)
at org.eclipse.tycho.repository.local.MirroringArtifactProvider.downloadMostSpecificNeededFormatOfArtifact(MirroringArtifactProvider.java:229)
at org.eclipse.tycho.repository.local.MirroringArtifactProvider.downloadArtifact(MirroringArtifactProvider.java:214)
at org.eclipse.tycho.repository.local.MirroringArtifactProvider.makeOneFormatLocallyAvailable(MirroringArtifactProvider.java:203)
at org.eclipse.tycho.repository.local.MirroringArtifactProvider.makeLocallyAvailable(MirroringArtifactProvider.java:174)
at org.eclipse.tycho.repository.local.MirroringArtifactProvider.getArtifactFile(MirroringArtifactProvider.java:118)
at org.eclipse.tycho.repository.p2base.artifact.provider.CompositeArtifactProvider.getArtifactFile(CompositeArtifactProvider.java:70)
at org.eclipse.tycho.p2.target.TargetPlatformBaseImpl.getLocalArtifactFile(TargetPlatformBaseImpl.java:93)
at org.eclipse.tycho.p2.resolver.P2ResolverImpl.addUnit(P2ResolverImpl.java:251)
at org.eclipse.tycho.p2.resolver.P2ResolverImpl.toResolutionResult(P2ResolverImpl.java:214)
at org.eclipse.tycho.p2.resolver.P2ResolverImpl.resolveDependencies(P2ResolverImpl.java:206)
at org.eclipse.tycho.p2.resolver.P2ResolverImpl.resolveDependencies(P2ResolverImpl.java:113)
at org.eclipse.tycho.p2.resolver.P2DependencyResolver.doResolveDependencies(P2DependencyResolver.java:360)
at org.eclipse.tycho.p2.resolver.P2DependencyResolver.resolveDependencies(P2DependencyResolver.java:333)
at org.eclipse.tycho.core.resolver.DefaultTychoResolver.resolveProject(DefaultTychoResolver.java:117)
at org.eclipse.tycho.core.maven.TychoMavenLifecycleParticipant.afterProjectsRead(TychoMavenLifecycleParticipant.java:77)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:271)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
... 11 more
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/InternalErrorException
After more investigation, i found reason was due to machine environment properties.
<environment>
<os>macosx</os>
<ws>cocoa</ws>
<arch>x86_64</arch>
</environment>
I have changed it to following , and it works.
<environment>
<os>win32</os>
<ws>win32</ws>
<arch>x86</arch>
</environment>
You have to have github account to clone or download sources from github. Create your github account then go to this project then click on clone or download button then download the sources as zip file.
You have to build these sources to get eclipse plugin, so unzip the content.
Location of graphiti p2 repo changed now so open the file
/Activiti-Designer-master/org.activiti.designer.parent/pom.xml
and change line from
<graphiti-site>http://download.eclipse.org/graphiti/updates/0.11.4</graphiti-site>
to
<graphiti-site> http://archive.eclipse.org/graphiti/updates/0.11.4</graphiti-site>
Go to Activiti-Designer-master/org.activiti.designer.parent folder in command prompt then run the command mvn clean install(Install maven if not installed).
I tried this and able to build this plugin successfully on my machine. By default it builds plugin for eclipse luna platform. So open eclipse luna and add /Activiti-Designer-master/org.activiti.designer.updatesite/target/repository folder as your update site then click install. Refer this for installing new software/plugin in luna.
About getting graphiti p2 repo.
Only solution worked for me, is to take graphiti site from a local folder.
Like it is described here Activiti Designer - build failures
download ZIP file: http://archive.eclipse.org/graphiti/archives/0.11.4/org.eclipse.graphiti.site_0.11.4.201507011432.zip
unzip it and set org.activiti.designer.parent/pom.xml <graphiti-site> value accordingly to point unzipped folder
in my case it was windows dir so e.g.:
<graphiti-site>file:///C:/temp/org.eclipse.graphiti.site_0.11.4.201507011432</graphiti-site>
after that i was able to build designer successfully.
ps. Sorry guys, I don't have enough reputation points to put this as a comment to a previous answer where it seems to be more obvious place.

Can maven treat WEB-INF\lib the way eclipse (and m2e) does?

I have a servlet/jsp web project which runs fine on eclipse and is exported as war fine (once I clean it that is). I mavenized the project deleting all of the dependencies from the WEB-INF\lib folder except a homebrew jar (the output of another project in the workspace). When I run the package maven goal I get messages for missing classes from this jar:
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
#..... NOTICE THIS COMES FROM A CUSTOM JAR
[ERROR] /C:/path/DataServlet.java:[3,30] package xxx.java.helpers does not exist
Now this has been asked before and the most rigorous solution appears to be to create a local repo: Can I add jars to maven 2 build classpath without installing them? (NB: I am at maven 3).
I would like to avoid this - so is there any way maven will just stuff this jar to WEB-INF\lib in the war ?
Solutions that use some maven plugin to cp the contents of the WEB-INF\lib in the war are welcome - although I just have this feeling that there should be a solution that takes into account the "special" nature of this folder.
Observations:
Alt+F5 removes this line:
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
which corresponds to the "Web App libraries" in the Java Build Path. So not only maven refuses to take into account the WEB-INF\lib - it also breaks the build path of eclipse completely.
Related:
Maven: How to include jars in Eclipse, which are not available in repository?
Uses the maven eclipse plugin : update my classpath with an Eclipse User Library via the maven eclipse plugin - not compatible with m2e
How does the m2e eclipse plugin interact with eclipse? - apparently m2e checks the pom then calls the eclipse builders (hence the .classpath is read)
Eclipse maven-enabled web app references workspace projects, but those are not deployed when running Tomcat server
Deploying a Maven project with dependencies to Tomcat or Jboss running within Eclipse
Did you add this jar from WEB-INF\lib as a dependency like this:
<dependency>
<groupId>someGroupId</groupId>
<artifactId>someArtifactId</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${basedir}/src/main/webapp/WEB-INF/lib/homebrew jar</systemPath>
</dependency>

Trouble with the sonar-packaging-maven-plugin after refactoring

I have some trouble developing a plugin for my company, later called as "myPlugin".
Background:
I was reading the book "SonarQube in Action" by the Manning company.
There was a little guide for developing a own plugin (they used the redmine plugin as example for developing). It told me to use the sonar-plugin-archetype to create the basic framework.
Situation before refactoring:
I wrote the plugin and it works fine. I encountered the problem when I've done some refactoring. Before the refactoring every package in the src folder in my tree (using ecplise) was called "main.java.org.sonar.plugins.myplugin" but the package decleration within each class was "org.sonar.plugins.myplugin". This were default settings created by using the sonar-plugin-archetype.
The settings within the pom.xml of the sonar-packaging-maven-plugin were the following once.
Pom-snippet before any changes were done:
<plugin>
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-packaging-maven-plugin</artifactId>
<version>1.9</version>
<extensions>true</extensions>
<configuration>
<pluginClass>org.sonar.plugins.myplugin.myPlugin</pluginClass>
</configuration>
</plugin>
So far everything worked fine. Now we come to my problem.
Situation after refactoring:
As my company has some naming conevtions for classes and packages i changed the package names in the tree to "com.mycompany.sonar.plugins.myplugin" and the package decleration within each class also to "com.mycompany.sonar.plugins.myplugin". Then i changed the classPath option for the sonar-packaging-maven-plugin to "com.mycompany.sonar.plugins.myplugin.myPlugin". All I've done so to say was changing "org." into "com.mycompany.".
Pom-snippet after changes were done:
<plugin>
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-packaging-maven-plugin</artifactId>
<version>1.9</version>
<extensions>true</extensions>
<configuration>
<pluginClass>com.mycompany.sonar.plugins.myplugin.myPlugin</pluginClass>
</configuration>
</plugin>
When i was running the "compile" command everything worked. Using "package" does not work, because the sonar-packaging-maven-plugin was not able to find the given class (see console output below). When i'm refoactoring everything again back to the beginning it works again.
[...]
[INFO] --- sonar-packaging-maven-plugin:1.9:sonar-plugin (default-sonar-plugin) # sonar-projectkeychecker-plugin ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 19.649 s
[INFO] Finished at: 2014-04-02T11:42:01+01:00
[INFO] Final Memory: 13M/67M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.sonar:sonar-packaging-maven-plugin:1.9:sonar-plugin (default-sonar-plugin) on project sonar-myplugin-plugin: Plugin class not found: 'com.mycompany.sonar.plugins.myplugin.myPlugin-> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
My Question: Why are my new names not working? Are there any inner convetions for the sonar-packaging-maven-plugin (like the packaging name has to beginn with "org.sonar" ot something like this)?
Thank you for reading this long text and your try to help me :)
pluginClass is the entry point of the plugin. Value must be an existing class. In your example I suppose that there's a typo, it should be com.mycompany.sonar.plugins.myplugin.MyPlugin (upper-case M).
Under <plugin> I was missing the <extensions>true</extensions> tag

What type of new project for the Hibernate tutorial?

I am trying to follow this Hibernate tutorial:
http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/tutorial.html
which seems pretty easy & straightforward, but I got stuck on the very 1st decision point: When selecting File > New Project to use the tutorial's suggested pom.xml, which of the many type of projects should I select?
Intuitively, I thought of creating a new Maven project:
Maven > Maven Project [Next]
[v] Create a simple project (skip archtype selection) [Next]
But at step #3 it prompts me for the very same information provided by the tutorial's pom.xml. So I am thinking the tutorial was aiming at creating a "blank project" and then manually adding the suggested pom.xml to it?
But what type of "blank project" would that be?
Java?
Java EE?
EJB?
JAXB?
JPA?
Maven?
Does it matter?
(sorry, don't have much experience (yet) with this new jargon, will get there eventually)
UPDATE 1: Actually, the proposed method of selecting a Maven project (regardless whether starting with bogus or correct info) doesn't work:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).
Project ID: org.hibernate.tutorials:hibernate-tutorial
POM Location: C:\Users\Daniel\Workspace\First Hibernate Tutorial\pom.xml
Validation Messages:
[0] 'dependencies.dependency.version' is missing for org.hibernate:hibernate-core:jar
[1] 'dependencies.dependency.version' is missing for javax.servlet:servlet-api:jar
[2] 'dependencies.dependency.version' is missing for org.slf4j:slf4j-simple:jar
[3] 'dependencies.dependency.version' is missing for javassist:javassist:jar
Reason: Failed to validate POM for project org.hibernate.tutorials:hibernate-tutorial at C:\Users\Daniel\Workspace\First Hibernate Tutorial\pom.xml
I am going to check now whether creating a plain Java project, then converting it to a Maven (after copying that tutorial's pom.xml) will do the trick.
UPDATE 2: Creating a plain Java project, then converting it to a Maven (after copying that tutorial's pom.xml) produces the same errors.
What am I missing?
UPDATE 3: Thanks to #cowls tip below I found that "I" was missing were the version numbers for the Maven dependencies. "I" because it's the tutorial that was missing them (what kind of a tutorial is this?)
Once I used some known version numbers, e.g.:
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.5.6-Final</version>
</dependency>
<!-- Because this is a web app, we also have a dependency on the servlet api. -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>1.2_02</version>
</dependency>
<!-- Hibernate uses slf4j for logging, for our purposes here use the simple backend -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.5.10</version>
</dependency>
<!-- Hibernate gives you a choice of bytecode providers between cglib and javassist -->
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.8.0.GA</version>
</dependency>
</dependencies>
I have been able to get rid of that scary FATAL ERROR message. That error message's "tip" BTW was counter-productive as it was pointing to the wrong direction:
[INFO] Error building POM (may not be this project's POM).
Now... I am still getting a build error, albeit much less scary:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building First Hibernate Tutorial
[INFO] task-segment: [install]
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources {execution: default-resources}]
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Users\dben\ws-study\First Hibernate Tutorial\src\main\resources
Downloading: http://repo1.maven.org/maven2/javax/servlet/servlet-api/1.2_02/servlet-api-1.2_02.pom
[INFO] Unable to find resource 'javax.servlet:servlet-api:pom:1.2_02' in repository central (http://repo1.maven.org/maven2)
Downloading: http://repo1.maven.org/maven2/javax/servlet/servlet-api/1.2_02/servlet-api-1.2_02.jar
[INFO] Unable to find resource 'javax.servlet:servlet-api:jar:1.2_02' in repository central (http://repo1.maven.org/maven2)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.
Missing:
----------
1) javax.servlet:servlet-api:jar:1.2_02
Try downloading the file manually from the project website.
Then, install it using the command:
mvn install:install-file -DgroupId=javax.servlet -DartifactId=servlet-api -Dversion=1.2_02 -Dpackaging=jar -Dfile=/path/to/file
Alternatively, if you host your own repository you can deploy the file there:
mvn deploy:deploy-file -DgroupId=javax.servlet -DartifactId=servlet-api -Dversion=1.2_02 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
Path to dependency:
1) org.hibernate.tutorials:hibernate-tutorial:jar:1.0.0-SNAPSHOT
2) javax.servlet:servlet-api:jar:1.2_02
----------
1 required artifact is missing.
for artifact:
org.hibernate.tutorials:hibernate-tutorial:jar:1.0.0-SNAPSHOT
from the specified remote repositories:
central (http://repo1.maven.org/maven2)
Interesting tutorial: I was expecting to learn some Hibernate but instead I am finding myself learning Maven. :)
UPDATE 4: I corrected the javax.servlet version to 2.4 and all is well now.
LESSONS LEARNED:
Maven's pom.xml requires a <version> for each & every dependency.
That <version>'s value must be valid.
Creating a new Maven project, then replacing its pom.xml entirely would work, but it still creates it with the incorrect subdirectory under Workspace because there is no way to define the <name> in the wizard-based creation process.
Creating a plain Java Project, then adding the pom.xml to its directory, then refreshing the Package Explorer view is the recommended way to go (no subdirectory renaming necessary).
That tutorial recommends Maven's "standard layout" but then breaks it by using the declared package "org.hibernate.tutorial.domain" which does not match the expected package "main.java.org.hibernate.tutorial.domain"... Do take Eclipse's fix suggestion to rename the package to "main.java.org.hibernate.tutorial.domain". (and move Event.java to the newly renamed package!)
The Hibernate configuration command (mvn exec:java -Dexec.mainClass="org.hsqldb.Server" etc.) must be run from the directory where pom.xml resides.
Easiest is to create a new maven project and use the maven-archetype-quickstart archetype.
This will create a basic maven project and you should be able to go from there.
Note that a maven project is just a Java project that uses Maven to build it, hence you will see a pom.xml file in your project.
Using this pom file you can build the project, include external dependencies and much more. I would suggest using the m2e plugin if you are developing with eclipse to help you manage the maven projects better: http://eclipse.org/m2e/
Each dependency you specify should have a version number associated with it.
e.g.
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.5.6-Final</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
To get the correct version number, just google artifactid maven dependency. E.g. hibernate-core maven dependency.
Look for the link for the maven central repository - i.e. http://mvnrepository.com. If you cant find it on Google you can search directly on the site, however I find its search feature quite poor.
Put your Java code in src/main/java and your resources in src/main/resources (e.g. xml files etc).
You can then build the project using mvn clean install

Eclipse 3.7 (Indigo): How to add a remote Maven 2 repository mirror

I recently installed Eclipse 3.7 (Indigo) and now a wanted to start a new project using the integrated Maven plugins.
Problem is, I can't download any dependencies from the central maven 2 repository http://repo1.maven.org/maven2
After creating a new simple Maven project (without an archetype), i constantly get these Error messages:
Description Resource Path Location Type
CoreException: Could not calculate build plan: Plugin org.apache.maven.plugins:maven-compiler-plugin:2.3.2 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-compiler-plugin:jar:2.3.2: ArtifactResolutionException: The repository system is offline but the artifact org.apache.maven.plugins:maven-compiler-plugin:pom:2.3.2 is not available in the local repository. pom.xml /JAVA line 1 Maven Project Build Lifecycle Mapping Problem
Description Resource Path Location Type
Could not calculate build plan: Plugin org.apache.maven.plugins:maven-resources-plugin:2.4.3 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.4.3 pom.xml /JAVA line 1 Maven Build Problem
Description Resource Path Location Type
Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (execution: default-compile, phase: compile) pom.xml /JAVA line 1 Maven Project Build Lifecycle Mapping Problem
Description Resource Path Location Type
Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:2.3.2:testCompile (execution: default-testCompile, phase: test-compile) pom.xml /JAVA line 1 Maven Project Build Lifecycle Mapping Problem
Using an archetype doesn't work at all.
Am I right to just add another repository mirror to get the needed dependencies?
If so, how do I add another one?
Update: I wrote a D:\Users\.m2\settings.xml manually and the m2e-plugin recognized it correctly:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository/>
<interactiveMode/>
<usePluginRegistry/>
<offline/>
<pluginGroups/>
<servers/>
<mirrors>
<mirror>
<id>dotsrc.org</id>
<url>http://mirrors.dotsrc.org/maven2</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
<proxies/>
<profiles/>
<activeProfiles/>
</settings>
Problem is: I can't find a complete mirror of the Maven central repository. I tried every single one I could find on the net, but all are missing some dependencies, archetypes, etc.
Any help out there?
Try one of these.