maven build offline error- must specify a valid lifecycle phase - java

I am still getting the hang of Maven and spring, but am having an odd problem.
Up until a few days ago I could build maven fine by using the command:
mvn -Dmaven.test.skip=true clean install eclipse:eclipse –o
not sure what changed but i started getting the error:
BUILD FAILURE
Invalid task 'uo': you must specify a valid lifecycle phase,
or a goal in the format plugin:goal or
pluginGroupIf:pluginArtifactId:pluginVersion:goal
for mor information run with the -e switch
I tried updating all my code from SVN and got the same error. I finally completed building all packages with online with:
mvn -Dmaven.test.skip=true clean install eclipse:eclipse
which gave be BUILD SUCCESSFUL for all project packages.
Yet when I try building maven offline again i continue to get the same Build Failure error. Any thoughts?
Note: there is about 8 packages in my project and they all get the same build failure error

– character is incorrect use - instead, in your command
change this
mvn -Dmaven.test.skip=true clean install eclipse:eclipse –o
to
mvn -Dmaven.test.skip=true clean install eclipse:eclipse -o
Note: there is change in - hyphen character

Related

How to find the dependencies of a maven plugin goal

I'm trying to find out where the dependencies are coming from for a particular plugin goal. I know the dependencies exist because Maven downloaded them when I ran the goal for the first time. And they're not (directly) dependencies of my project, because I ran mvn clean install first, and these dependencies weren't downloaded then.
In this specific case, I'm trying to figure out what the dependencies are when I run mvn sonar:sonar, but I expect the answer will be general purpose. For instance, even though I've built this project a number of times, when I ran that goal Maven downloaded a bunch of new jars like maven-antrun-plugin.
Here are things I've tried:
mvn dependency:tree shows the dependencies for the project, but not for the plugin goal (it doesn't include anything related to SonarQube in the list).
mvn org.apache.maven.plugins:maven-help-plugin:3.2.0:effective-pom -Dverbose=true also doesn't include anything related to SonarQube.
mvn -X sonar:sonar prints out what looks like a dependency graph, but it's missing the jars that Maven downloaded the first time I ran the sonar:sonar goal.
mvn -X dependency:resolve-plugins seems to be meant to download the dependencies of plugins, but does not capture the sonar:sonar dependencies. If I clear out my Maven cache, run mvn dependency:resolve-plugins, and then run mvn sonar:sonar, Maven has to download jars.
Use your IDE to navigate to the POM of the plugin project and then look at the dependency tree.
Or do this manually by copying the plugin POM to your file system and running mvn dependency:tree.
The dependencies downloaded by maven are generally stored locally on the pc at the address C:\Users\yourUser/.m2 this regardless of your projects and so that you do not have to reload dependencies that you are already using in other projects.
I hope I have understood your question and that my answer is useful to you, greetings.

Keycloak Authenticator SPI Example not working because of wrong relative path in pom.xml

I followed the walkthrough for setting up a custom authenticator spi for keycloak.I'm trying to use the example code from https://github.com/keycloak/keycloak/tree/master/examples/providers/authenticator .
But when I run mvn clean install wildfly:deploy i'm getting this error :
FATAL] Non-resolvable parent POM for org.keycloak:keycloak-examples-parent:8.0.0-SNAPSHOT: Could not find artifact org.keycloak:keycloak-parent:pom:8.0.0-SNAPSHOT and 'parent.relativePath' points at wrong local POM # org.keycloak:keycloak-examples-parent:8.0.0-SNAPSHOT, C:\Users\dazoulay\Downloads\keycloak-master\keycloak-master\examples\pom.xml, line 20, column 13
What I did :
mvn clean install
on /keycloak-master folder OK
After that I tried to follow instruction found on Github Readme
So I tried
mvn clean install wildfly:deploy
on the /keycloak-master/examples/providers/authenticator but I got the "Non-resolvable parent Error"
I also Tried the git checkout 8.0.0 but I got the same mistake.
Two solutions:
You need to start the build at the root of the of the project, not the subproject. So instead of
cd keycloak/examples/providers/authenticator
mvn clean install
do:
cd keycloak
mvn clean install
Second option, checkout a tag, then build from the subproject (this is likely the better option as it will go faster)
cd keycloak/examples/providers/authenticator
git checkout 8.0.0
mvn clean install

Want to build project with commandline mvn but have to use Maven update in eclipse first

I'm working with multiple projects in Eclipse. because I want to automate the building I want to script the building process.
Unfortunately I cannot do the same actions on the commandline as in Eclipse.
So a common problem is that when a new function from a referenced project is used, I cannot build the project on the commandline with mvn. I use the command:
mvn clean install -U
But this command will give a build failure until I do a Eclipse Maven Update from the eclipse GUI. After that I can build the project again.
I also tried all the other commands I came across Stackoverflow:
mvn eclipse:eclipse
mvn dependency:resolve
So I just want to that Maven Update command in eclipse from the commandline so I can build from the commandline. If anyone could tell me what I'm doing wrong that would be awesome.
Thx in advance
Update for more clarification:
The project structure is:
Rest-service, Framework-service, Framework-model
Framework-model is referenced in the pom file by Framework-service and Framework-service is referenced by Rest-service. The other projects are not relevant to the problem.
When a function is added to Framework-model and used in Rest-service it gives an compilation error in eclipse and when I build with mvn clean install -U, although Maven install in eclipse is succesful but I think it is still using the old compiled code. After a Maven Update command in eclipse the compilation error is gone. And mvn clean install -U from the commandline also works.
How could I do a Maven Update command in the commandline? If mvn clean install -U should also do a Maven Update command, what settings should I check?
Another update: So this weekend I tried different things and running mvn compile before the mvn clean install -U command gives a different output. And finds the new function. But as I read maven, I thought install should also do the previous steps. How is this possible?
Eclipse's Maven plugin uses the maven version configured in Preferences/Maven/User settings. If you have a different version of maven in your Eclipse's settings than the one on your PATH variable, you could have different outputs. Maybe try and check that.

Create an hermetic Maven build

I'm preparing a workshop where they may be no Internet connection. Because of that, I'd like to provide every dependency/plugin of the project, so attendees can work on it, completely offline.
I've got a basic Maven project with some dependencies and two plugins.
First, I created an alternate local repository:
mvn -Dmaven.repo.local=dependencies dependency:go-offline
Then, I expected the following command to run fine, but it doesn't! And I some mentioned missing plugins are not available in maven central or within the maven distribution:
mvn -o -Dmaven.repo.local=dependencies package
This fail with the following error message:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.6:resources (default-resources) on project XXX: Execution default-resources of goal org.apache.maven.plugins:maven-resources-plugin:2.6:resources failed: Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: The following artifacts could not be resolved: org.apache.maven:maven-profile:jar:2.0.6, org.apache.maven:maven-repository-metadata:jar:2.0.6, org.apache.maven:maven-plugin-registry:jar:2.0.6, classworlds:classworlds:jar:1.1-alpha-2: Cannot access central (https://repo.maven.apache.org/maven2) in offline mode and the artifact org.apache.maven:maven-profile:jar:2.0.6 has not been downloaded from it before.
Any idea how to get these missing bits while creating an alternate local repo? Thanks in advance!
Based on this issue in the plugin's Jira this problem is still not resolved.
The best work around so far is to package the project online once, using the custom repository.
mvn -Dmaven.repo.local=dependencies dependency:go-offline
then
mvn -Dmaven.repo.local=dependencies package
and finally
mvn -Dmaven.repo.local=dependencies -o package
If your workshop go farther than deploy, you should check that next goals run fine offline too!
can you declare pluginManagement for every plugin that is used by your packaging? That should enable downloading when dependency:go-offline is called.
(in addition, this will improve stability for your build, since you'll be sure that changing Maven version won't change plugins versions)
Can you confirm this works?
(now, I have ideas to improve this, but won't be available before a few months at least...)
The documentation seems to suggest that you need to run:
mvn dependency:resolve-plugins
Before go-offline
Could you try it?
See: https://people.apache.org/~aramirez/maven-dependency-plugin/go-offline-mojo.html

Maven release not working - "Maven executable not found"

I recently had to get a new computer at work, and reinstall all programming stuff including Maven. Now I'm trying to release a project change, but I can't get Maven Release to work.
I ran mvn release:prepare from Eclipse, and it completed successfully.
I started mvn release:perform from Eclipse, and it failed with a message saying prepare had failed mid-way.
I ran release:prepare from Eclipse again, and now it failed with "Maven executable not found at: C:\Users\bls\Git\events\EMBEDDED\bin\mvn.bat"
I ran mvn release:prepare from cmd prompt, and it completed successfully.
I ran mvn release:perform from cmd prompt, it gave me some questions and failed with "Unable to tag SCM"
-
There never used to be any folder at C:\Users\bls\Git\events\EMBEDDED\bin
C:\Maven\apache-maven-3.3.3\bin includes both mvn.bat and mvn.cmd.
C:\Maven\apache-maven-3.3.3\bin is added in PATH.
In Eclipse, Window/Prefrences/Maven/Installations I added the proper path and set it to default.
Still not working. Ideas?
You need to rename the mvn.cmd file into mvn.bat folder. In mvn 3.3.x the structure of maven have changed. The mvn.bat file have been changed into mvn.cmd. But in command line this is not taken into consideration. Hope i have help you with your issue.
#Progamactor is correct. You need to
Create the mvn.bat at the location maven complains it needs one.
Add the following contents to that batch (mvn.bat):
#mvn.cmd %*

Categories

Resources