Maven configuration while building project - java

I have crated maven project in eclipse to compile xstream library for java 1.4. Currently I have several errors shown below.
Plugin execution not covered by lifecycle configuration: org.codehaus.mojo:build-helper-maven-plugin:1.5:maven-version (execution: versions, phase: initialize)
What is that?
maven-resources-plugin prior to 2.4 is not supported by m2e. Use
maven-resources-plugin version 2.4 or later.
Where to get this plugin?
And several other errors similar to firs one:
Plugin execution not covered by lifecycle configuration:
org.codehaus.mojo:build-helper-maven-plugin:1.5:parse-version
(execution: versions, phase: initialize)
Plugin execution not covered by lifecycle configuration:
org.apache.felix:maven-bundle-plugin:2.3.7:manifest (execution:
bundle-manifest, phase: process-classes)
How to solve these problems?

This is caused because Maven and Eclipse are two different building tools, sometimes resembling and sometimes disjoint. So, the M2 plugin is supposed to adapt the POM's contents to the building lifecycle of Eclipse. However, as Maven's building lifecycle is much more complete than Eclipse's, M2 is not always able to do such an adaptation, and in these cases it raises the error you are asking about.
Usually, you should not worry a lot about this, because the project will eventually be built by Maven, so the important thing is the POM be 100% understood by Maven, not Eclipse. We use Eclipse mostly for the automatic building, not for producing the final JAR.
Anyway, you can drop these errors through three alternative options (available in the very screenshots you have posted):
Discover new M2 connectors: I do not recommend this, if you are using the latest M2 version. You can give it a try once, if you want.
The other two options are both aimed to instruct Eclipse to ignore the reported plugins:
Permanently mark goal X in pom.xml as ignored: It adds an extra declaration to the POM marking that plugin as ignorable by Eclipse.
Mark goal X as ignored in Eclipse build: It leaves the POM unmodified, but adds that info to the current Eclipse workspace metadata, so it will be applied to all POMs (present and future) in the same workspace.

Related

Maven Release Without Tagging or Compiling

I am trying to use maven to build a JNI project and I am running into some difficulty creating a GA release. The project's native code needs to be compiled on at least 3 systems (Linux, OSX, Windows) due to the native code requirements. I would also like GitHub Actions to produce a release build when I create a tag on GitHub. Because of this, I am facing a number of issues with the maven release plugin. It seems like maven's release process involves compiling and testing the code as well as screwing around with SCM before I can create a GA version and release. This simply isn't possible for this JNI project. I have already gone down the cross compiler route with Ant and I would really like to move away from that for any number of reasons, mostly Apple related. I also thought about releasing each JNI target individually, but I would really like to bundle the native code inside of the JAR and things start getting complicated when I need to share a .m2 folder across different build environments. Is it possible to release a maven project without all the compiling, testing and SCM nonsense? Maybe a different 3rd party plugin? Is there a better way I should be doing this? For reference, the pom can be found here.
Dont use the release plugin, I had a lot more success with the maven version plugin.
All the maven release plugin is doing is taking the version off the snapshot, creating a new commit and then upping the version to a new incremented SNAPSHOT. You can mimic this process without maven needing to know anything about your SCM using versions.
One way to do it is to not SNAPSHOTS and instead build with the git short hash as part of the version:
So while developing, the version looks pretty normal
<groupId>org.example</groupId>
<artifactId>my-app</artifactId>
<version>1.1.0</version>
The do a "release" build based on a tag. My flow was
commit and push
build - mvn clean install, results in my-app-1.1.0.jar
deploy to a test env and run regression tests, if they succeed, we tag the commit with a "passed_tests" tag
CI fires on tags that match "passed_tests" - this needed to be the same commit that resulted in the jar under test
runs mvn -f ./pom.xml versions:set -DnewVersion=${gitProps['git.build.version']}_${gitProps['git.commit.id.abbrev']}
On the disk, our maven version is now:
<groupId>org.example</groupId>
<artifactId>my-app</artifactId>
<version>1.1.0-abcdef</version>
then runs mvn deploy. This is the artifact that gets deployed to the repo and now we have a jar file (or whatever) that has a version matching the git commit.
You could use the same process for all your target architectures.

Maven Run Error "maven-clean-plugin:2.5 or one of its dependencies could not be resolved"

Using İntelliJIdea, I Downloaded my project from Subversion for 12 times.
Deleted .m2/repository for 7-8 times.
Reimported, downloaded source for 15 times. Tried every possibilities but still cannot run my project.
Here is my Maven run profile and project hierarchy
and here this is my maven output
[ERROR] Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of its dependencies could not be resolved: Cannot access central (https://repo.maven.apache.org/maven2) in offline mode and the artifact org.apache.maven.plugins:maven-clean-plugin:jar:2.5 has not been downloaded from it before. -> [Help 1]
http://paste.ubuntu.com/10613835/
There is nothing wrong with project or maven files. I'm running it on my work computer. But not in my personel.
Update1: After I deleted "-o" parameter in maven run configuration. Here is my new log Logs after deletig "-o" paramter and here is image url http://i.hizliresim.com/Lp6dDJ.png
Update2: I run this command on cmd,
C:\MAYA\MAD4>mvn dependency:tree -Dverbose the result is success. And also saw C:\Users\tayfuny\.m2\repository\org\codehaus\plexus\plexus-digest\1.0\plexus-di‌​gest-1.0.jar in my dir. Here is latest maven output http://i.hizliresim.com/XBgD07.png
Update: Its early in the morning here in Switzerland - i have overseen you specified the -o parameter in your run configuration in the section Command line:. This is the console parameter to let Maven work offline ;) Remove it and you should be all good. Source: http://books.sonatype.com/mvnref-book/reference/running-sect-options.html
Update 2: Alright the initial problem is solved - your log however shows two more things to fix (one of them optionally but very recomended): 1.) The warnings at the very start of the build imply you have duplicate dependency/version declarations - those should be easy fixable. You can for example use mvn dependency:tree -Dverbose to get a overview on the duplicates (and which definition takes place in the end). The second is a actuall build error. I dont know about the install plugin you are using but i guess that you are missing this dependency: http://mvnrepository.com/artifact/org.codehaus.plexus/plexus-digest/1.0 (or another one containing the class that could not be found - adjust version as needed as well).
Answer regarding offline mode:
Remove the parameter -o when running maven unless you want to work in offline mode and with your local repository only.
Another probable cause is explicitly setting Maven to work in offline mode (e.g. only consult the local repository to resolve dependencies) from within the IDE itself (which will result in calling Maven with the -o parameter behind the scenes).
General Settings/ Project Settings:
File -> Settings -> Build, Execution, Deployment -> Build Tools -> Maven
(The very first option Work offline should be deactivated/ deselected unless you realy want to work with the local repository only).
Those settings are inherited by Maven-run configurations by default but may be overwritten at two levels
Default Run Configuration:
(Those default configs will be inherited by specific run configurations. Note that changes to the general settings apply to newly created run configurations only and will not be populated to existing ones).
Specific Run Configuration:
Make sure none of the options is selected. In the end if you use a specific launch configuration make sure the option is not selected in that specific configuration and change the higher levels for convenience if it makes sence)
EASY WAY
This should work for all similar errors.
This is how an error looks like
Could not resolve : org.apache.maven.plugins:maven-clean-plugin:jar:2.5
Could not resolve : (groupID):(artifactID):version
So what you actually need is a correct version of the clean plugin.
<dependency>
<groupId>(groupId)</groupId>
<artifactId>(artifactId)</artifactId>
<version>(version)</version>
<type>maven-plugin</type>
</dependency>
This will become something like this. Add this to dependencies section Pom.xml. Reload build.
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<type>maven-plugin</type>
</dependency>
Reload build and IDE will automatically download these version of artefacts and
replace if there are other versions because your project needs these particular versions to run.
Do the same with other dependency errors. "Works every time".

Sample Guestbook GAE Project - 'Plugin execution not covered by lifecycle configuration'

I'm new to programming (and web development) and thought it would be good practice to try and build the sample Google App Engine project through Google's tutorial.
Here are my notes, spanning vim/command line weirdness/other fun stuff -http://goo.gl/EfZ3Gm
For reference, I am using OS X Yosemite 10.10.3 (beta)
I started here - https://cloud.google.com/appengine/docs/java/gettingstarted/introduction
and followed all the command line instructions for Steps 1-3. I have Maven 3.2.5 installed, here is the output from my command prompt when I type 'mvn -v'
Apache Maven 3.2.5 (12a6b3acb947671f09b81f49094c53f426d8cea1; 2014-12-14T12:29:23-05:00)
Maven home: /usr/local/Cellar/maven/3.2.5/libexec
Java version: 1.7.0_75, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/jre
When I reach Step 4, I'd like to open the project in Eclipse, since I'm a bit more comfortable with looking at the code in an IDE.
Looking at the project's pom.xml file in the 'Overview' tab, I see the error -
Plugin execution not covered by lifecycle configuration: org.codehaus.mojo:versions-maven-plugin:2.1:display-plugin-updates (execution: default, phase: compile)
Looking at the code, I would guess it's because the maven referenced in the project doesn't match what I have installed on my machine? I see similar questions have been asked previously -
Plugin execution not covered by lifecycle configuration
Plugin error: execution not covered by lifecycle configuration
Plugin execution not covered by lifecycle configuration
But running 'mvn eclipse:eclipse' in my terminal window would negate all the work I did in Steps 1-3 with maven in the command prompt; I needed maven for these steps. And the second option involves installing Spring IDE - there has to be a better way than this, I hope!
When using eclipse with the m2e plugin (which is included standard and enables maven in eclipse), it will attempt to run plugins in your pom file as part of build for any maven enabled project.
For it to know what to do it uses an m2e-connector - there needs to be one for each plugin, installed into eclipse.
If it can't find one, it issues this error/warning.
If you press cmd-1 on the troublesome line, it will give you a few options. They boil down to 'ignore this'. One will modify your pom file to include a maven plugin which controls the configuration of eclipse, or add a clause to it if already present. The other saves the 'ignore this' configuration into eclipse settings.
This should remove the warning/error, and make no difference to your development environment.
In the case that this plugin is crucial, you'll need to locate an m2e-connector. They generally don't exist - so you'd probably be out of luck. In this case, it just spits out a report telling you if there are any more recent versions of dependencies available and has no impact on your build, so don't worry about it.
I strongly advise against using mvn eclipse:eclipse, especially with appengine apps. It won't use the correct library setup for your app to run properly.

What is an OSGI version qualifier

I need to confirm what I suspect as I cannot find any documentation on it, so this would appear a silly question, and since I am a learner at eclipse PDE.
Initially,
I had a parent project pom of an eclipse plugin project with
<version>1.1.0-SNAPSHOT</version>
with two child projects, with both their poms referring to the parent pom as version 1.1.0-SNAPSHOT.
I was able to build the projects successfully and had a site which I use to install the plugin into eclipse.
Then, I wanted my personal temp version called 1.1.1-mine. So I modified the three poms to
1.1.1-mine
I also updated the META-INF/MANIFEST.MF and feature.xml from
0.13.0.qualifier
to
0.13.1.qualifier
However, the build encountered the following error.
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-packaging-plugin:0.15.0:validate-version (default-validate-version) on project org.sonatype.m2e.subclipse: OSGi version 1.1.1.qualifier in META-INF/MANIFEST.MF does not match Maven version 1.1.1-mine in pom.xml
Does qualifier have to be a maven version keyword? Because, the build proceeded without error after I changed mine to SNAPSHOT in the poms.
If not, what did I do wrong?
What can I do to allow me to have version 1.1.1-mine?
In a nutshell, OSGi .qualifier means the same thing as -SNAPSHOT.
Since OSGi doesn't allow for more than 3 numbers in a version (+ qualifier), creating a -mine version is a bit tricky.
According to the FAQ, you can tell Tycho a string that it should be use to replace qualifier with:
mvn -DforceContextQualifier=mine
Note that this disables all the goodness you get from SNAPSHOT versions (namely that you can deploy the bundle several times).

Maven plugin execution not covered by lifecycle configuration

I have the same problem like on the below link , and solution from there works
but i have a little of hard time in understanding what it cause this and how it affects the project.
Plugin execution not covered by lifecycle configuration (JBossas 7 EAR archetype)
I start reading about m2e
http://wiki.eclipse.org/M2E_plugin_execution_not_covered
What is the difference between the 'eclipse build' and maven one ?
Still not clear what is meant by "interesting" and "not-interesting" mojo executions:
https://docs.sonatype.org/display/M2ECLIPSE/Project+build+lifecycle+mapping
So there is the solution but , not the understanding of the problem.
Thanks for helping me understand the problem ...:)
Generally speaking, The way m2e used for resolving/mapping plugins' goal execution into Eclipse build life cycle has been reinvented after version 0.12. Now m2e requires explicit instructions what to do with all Maven plugins bound to "interesting" phases of a project build lifecycle. By either configure the lifecycle mapping in your project's pom, or use specific m2e configurator Eclipse plugin if somebody has kindly created it for the community.
By "interesting" they mean phases which normally occur during writing and debuging of code inside the IDE, mostly excluding packaging and deployment steps.
Also note (from this blog post):
M2E allows you to run Maven manually. You can invoke a goal like "mvn install" from within Eclipse just as you would do it from the command line. That works (and always worked) just fine. Unfortunately, Maven is also invoked automagically from M2E whenever Eclipse builds the project, for example after a clean. In such cases M2E acts as an "Eclipse Builder". It is these latter invocations that people have always had problems with and that the connectors should handle better.

Categories