mvn one:convert don't work? - java

Finally, I found that some dependency of maven-one-plugin don't install properly. but fix them this plugin work.
question fixed :
I am working on convert a maven 1 project to maven 2 project so I just run this command at the folder of the project:
mvn one:convert
then get a error:
[INFO] Internal error in the plugin manager executing goal
'org.apache.maven.plugins:maven-one-plugin:1.2:convert':
Unable to find the mojo 'org.apache.maven.plugins:maven-one-plugin:1.2:convert' in
the plugin 'org.apache.maven.plugins:maven-one-plugin'
org.apache.maven.model.v3_0_0.PatternSet
Anybody know the reason ? Sorry I just so green on maven and the task is urgent...

Try maven-one-plugin:convert

Please take a look at the plugin manual and check if your configuration matches the required configuration.
http://maven.apache.org/plugins/maven-one-plugin/usage.html

The plugin does exist in central repo
Just wondering if you are running this command using maven 1. If so, can you install maven 2/3 and try?
Edit 1:
Downloaded a sample Maven 1 project from here.
Ran mvn convert:one using the latest maven (maven 3).
Worked successfully
D:\work\sample-echo>mvn one:convert
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-one-plugin:1.2:convert (default-cli) # standalone-pom ---
[INFO] Adding report org.apache.maven.plugins:maven-changes-plugin
[INFO] There are 14 plugin relocators available
[INFO] Writing new pom to: D:\work\sample-echo\pom.xml
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.950s
[INFO] Finished at: Wed Jun 22 15:01:52 IST 2011
[INFO] Final Memory: 4M/15M
[INFO] ------------------------------------------------------------------------

Related

Maven tries download multimodule dependency on `validate` phase

From a build pipeline I want to run validate phase for things like the enforcer plugin. However it does not work for a multimodule project as it tries to download dependencies from repository which are inside the project. However, compile phase does not do that, but for me it is not an option as it is too slow.
pom.xml:
<module>lib</module>
<module>app</module>
lib/pom.xml
<version>1.2.3</version>
app/pom.xml
<dependency>
<artifactId>lib</artifactId>
<version>1.2.3</version>
</dependency>
So, if I do mvn compile it works fine.
But if I do mvn validate it fails validating app module as it tries to download lib-1.2.3 from maven repo. For some reason it now could not see that the lib is a neighbour dependency. Why?
I have created a small repo: https://github.com/kan-izh/so63963768
mvn compile
[INFO] --- maven-enforcer-plugin:3.0.0-M3:enforce (enforce-no-snapshots) # app ---
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) # app ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Workspace\repo\so63963768\app\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) # app ---
[INFO] No sources to compile
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] parent ............................................ SUCCESS [1.612s]
[INFO] lib ............................................... SUCCESS [1.224s]
[INFO] app ............................................... SUCCESS [0.056s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
mvn validate
[INFO] --- maven-enforcer-plugin:3.0.0-M3:enforce (enforce-no-snapshots) # app ---
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] parent ............................................ SUCCESS [0.979s]
[INFO] lib ............................................... SUCCESS [0.015s]
[INFO] app ............................................... FAILURE [0.020s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.180s
[INFO] Finished at: Wed Sep 23 11:27:38 BST 2020
[INFO] Final Memory: 7M/34M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:3.0.0-M3:enforce (enforce-no-snapshots) on project app: Execution
enforce-no-snapshots of goal org.apache.maven.plugins:maven-enforcer-plugin:3.0.0-M3:enforce failed: org.apache.maven.shared.dependency.graph.
DependencyGraphBuilderException: Could not resolve following dependencies: [com.so.q63963768:lib:jar:1.2.3 (compile)]: Could not resolve depend
encies for project com.so.q63963768:app:jar:1.2.3: Failure to find com.so.q63963768:lib:jar:1.2.3 in http://xxxxxxxxxxxxx.xx.xxxxxxxxxxxxxxxxx.
com:8081/repository/maven-public/ was cached in the local repository, resolution will not be reattempted until the update interval of nexus has
elapsed or updates are forced -> [Help 1]
This is a good question, and it shows a small flaw in how Maven handles dependencies.
You need to know that for every plugin-goal you can define if dependencies should be resolved, and for which scope. (and there's a small difference if having only the poms is enough, or that you also need the artifacts)
compiler:compile requires the dependencies that are required during compile, compiler:testCompile requires the dependencies that are required during test.
For the enforce goal it is tricky: the goal itself doesn't require to have resolved dependencies, nor do most rules( like requireJavaVersion or requireMavenVersion), but some rules do, like the one you try to enforce.
Ideally rules can define if they need to have resolved dependencies, but right now the API doesn't support that.
So you have a couple of solutions: always run with compile, or have an execution-block bound to the compile-pahse if it requires artifacts.

mvn install:install-file is unable to install ojdbc7.jar at correct location

I am having difficulty in getting this ojdbc7 JAR file installed in the correct location. I tried the following from Windows 10 command prompt and got the BUILD SUCCESS message as shown below:
C:\Users\john>mvn install:install-file -Dfile=C:\ojdbc7.jar -DgroupId=com.oracle -DartifactId=ojdbc7 -Dversion=12.1.0.1 -Dpackaging=jar
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.4:install-file (default-cli) # standalone-pom ---
[INFO] Installing C:\ojdbc7.jar to C:\Users\l-john\.m2\repository\com\oracle\ojdbc7\12.1.0.1\ojdbc7-12.1.0.1.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.381 s
[INFO] Finished at: 2018-10-24T12:09:04-05:00
[INFO] ------------------------------------------------------------------------
However, when I went inside the 12.1.0.1 folder (located here C:\Users\john\.m2\repository\com\oracle\ojdbc7\12.1.0.1) I only saw the following files :
For one of my Maven project, eclipse(version 2018-19) is trying to access the JAR file and I keep getting following BUILD FAILURE message which is obvious since the file isn't there:
BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.208 s
[INFO] Finished at: 2018-10-24T12:15:39-05:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project MyProject: Could not resolve dependencies for project com.company.ii:MyProject:war:0.1: Could not find artifact com.oracle.jdbc:ojdbc7:jar:12.1.0.1 in spring-releases (https://repo.spring.io/libs-release) -> [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.
In my pom.xml, I do have the dependency defined as follows:
Is there anything I am doing wrong? Please let me know if I need to perform some additional testing?
I could see that in mvn install command -DgroupId is not correct, instead of giving "-DgroupId=com.oracle.jdbc", you have given just "-DgroupId=com.oracle"
Maven tells you it is installing the jar to
C:\Users\l-john\.m2\repository\com\oracle\ojdbc7\12.1.0.1\ojdbc7-12.1.0.1.jar
But you are looking at
C:\Users\john\.m2\repository\com\oracle\ojdbc7\12.1.0.1
l-john vs john

Where is the created pom.xml

I'm trying to use maven goal of eclipse:to-maven, contained in Apache Maven Eclipse Plugin (RETIRED).
When I executed eclipse:to-maven with -DeclipseDir option, it prints BUILD SUCCESS like the following, but I cannot find the created pom.xml.
C:\Users\sample\Desktop\sample>mvn eclipse:to-maven -DeclipseDir="../jee-oxygen/eclipse"
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-eclipse-plugin:2.10:to-maven (default-cli) # standalone-pom ---
[INFO] Processing file C:\Users\sample\Desktop\jee-oxygen\eclipse\plugins\ch.qos.logback.classic_1.0.7.v20121108-1250.jar
...
skip the middle part
...
[INFO] Installing C:\Users\sample\Desktop\jee-oxygen\eclipse\plugins\org.eclipse.datatools.help_1.7.0.201701131441.jar to C:\Users\sample\.m2\repository\org\eclipse\datatools\help\1.7.0-201701131441\help-1.7.0-201701131441.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 36.557 s
[INFO] Finished at: 2017-11-22T06:00:23+09:00
[INFO] Final Memory: 16M/621M
[INFO] ------------------------------------------------------------------------
I'm using
Windows 10 Pro
Maven 3.5.0
1.8.0_131
Eclipse Oxygen.1 Release (4.7.1)
And I tried it with other version, like maven 3.3.9 and eclipse Juno, but this did not solve my problem.
edited.
I thought eclipse:to-maven goal is for my eclipse project, so I expected the created pom.xml is for my eclipse project.
I know converting to maven project in eclipse UI, but I would like to know if there are plugins or goals that enable to convert eclipse projects to maven projects.
From eclipse:to-maven plugin documentation
Add eclipse artifacts from an eclipse installation to the local repo. This mojo automatically analize the eclipse directory, copy plugins jars to the local maven repo, and generates appropriate poms.
So you should search in your local maven repo.
For example pom generated for org.eclipse.datatools.help should be installed at C:\Users\hyojinbae\.m2\repository\org\eclipse\datatools\help\1.7.0-201701131441\help-1.7.0-201701131441.pom

Missing artifact com.oracle:ojdbc6:jar:11.2.0 ?

I know this question has been asked several times.Even i have successfully done this in WINDOWS.But installed ubuntu OS and all set up is done except this.
Here are the following things i did.I Have oracle 11g i downloaded ojdbc6.jar,Installed Maven and run following command
sudo mvn install:install-file -Dfile=/home/nawaz/Downloads/ojdbc6.jar -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0 -Dpackaging=jar
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.5.2:install-file (default-cli) # standalone-pom ---
[INFO] pom.xml not found in ojdbc6.jar
[INFO] Installing /home/nawaz/Downloads/ojdbc6.jar to /root/.m2/repository/com/oracle/ojdbc6/11.2.0/ojdbc6-11.2.0.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.545 s
[INFO] Finished at: 2016-07-15T17:48:32+05:30
[INFO] Final Memory: 8M/208M
[INFO] ------------------------------------------------------------------------
and in .m2 directory
ojdbc6-11.2.0.jar.lastUpdated ojdbc6-11.2.0.pom.lastUpdated I cleaned the mvn -U clean and Update nothing works..Hope someone can find the BUG :)
I faced the same issue. I resolved this issue by checking my maven settings.xml file. My maven local repository is the place where I installed ojdbc6.jar. And when I tried to build my project using eclipse, the maven repository used by eclipse is different. This is causing the problem. I updated maven settings in eclipse and then it's worked fine for me.
To change the maven repo path in eclipse
1.Windows --> preferences
2. Maven --> User Settings
3. And in right side window update the settings
It looks like this:

Jersey maven skeleton project not running

I'm just getting started with jersey and have built the jersey 2.0 skeleton webapp using maven.
The command being:
mvn archetype:generate -DarchetypeGroupId=org.glassfish.jersey.archetypes \
-DarchetypeArtifactId=jersey-quickstart-webapp -DarchetypeVersion=2.0
Now if I try to execute this using mvn clean exec:java I get the following error:
[INFO] ------------------------------------------------------------------------
[INFO] Building testwebservice 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) # testwebservice ---
[INFO] Deleting /Volumes/data/Projects/TestWebService/testwebservice/target
[INFO]
[INFO] >>> exec-maven-plugin:1.2.1:java (default-cli) # testwebservice >>>
[INFO]
[INFO] <<< exec-maven-plugin:1.2.1:java (default-cli) # testwebservice <<<
[INFO]
[INFO] --- exec-maven-plugin:1.2.1:java (default-cli) # testwebservice ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.627s
[INFO] Finished at: Sat Jun 22 17:46:18 CEST 2013
[INFO] Final Memory: 8M/125M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java (default-cli) on project testwebservice: The parameters 'mainClass' for goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java are missing or invalid -> [Help 1]
The help provided isn't very helpful and I can't seem to find anything about this on the web. I have no clue where to set the parameters mainClass for "goal" (whatever that means) org.codehaus... . This is my first maven project and I'm pretty lost
Thanks for the help guys
You have generated a WEB Project and you are trying to run a java Application.
If you have a look at the Exec Plungin Documentation you will find that it requires an mainClassargument
and that's what the error message tells you
The parameters 'mainClass' for goal
org.codehaus.mojo:exec-maven-plugin:1.2.1:java are missing or invalid
But as I've already written you have generated a WEB Application Skeleton running it as Java Application does not really make sense.
Have a look at Building Simple Jersey Web App With Maven to find out what you'll have to do to get your web application running.
Try to run the following command using command line by going inside your project directory:
mvn clean generate-sources package

Categories