0
votes

I am facing a strange issue. I have edited Maven settings.xml file in M2_HOME/conf and want the jars to get download to a place other than {users.home}/.m2.

I have pasted <localRepository>G:/m2Repo</localRepository> into settings.xml.

Now when I type mvn archetype:generate, I get following error:

[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'archetype'.
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] The plugin 'org.apache.maven.plugins:maven-archetype-plugin' does not exist or no valid version could be found
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: The plugin 'org.apache.maven.plugins:maven-archetype-plugin' does not exist or no valid version could be found
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.verifyPlugin(DefaultLifecycleExecutor.java:1569)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.getMojoDescriptor(DefaultLifecycleExecutor.java:1851)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.segmentTaskListByAggregationNeeds(DefaultLifecycleExecutor.java:462)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:175)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
        at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.version.PluginVersionNotFoundException: The plugin 'org.apache.maven.plugins:maven-archetype-plugin' does not exist or no valid version could be found
        at org.apache.maven.plugin.version.DefaultPluginVersionManager.resolvePluginVersion(DefaultPluginVersionManager.java:229)
        at org.apache.maven.plugin.version.DefaultPluginVersionManager.resolvePluginVersion(DefaultPluginVersionManager.java:91)
        at org.apache.maven.plugin.DefaultPluginManager.verifyPlugin(DefaultPluginManager.java:179)
        at org.apache.maven.plugin.DefaultPluginManager.loadPluginDescriptor(DefaultPluginManager.java:1642)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.verifyPlugin(DefaultLifecycleExecutor.java:1540)
        ... 15 more
[INFO] ------------------------------------------------------------------------

What could be the problem?

4

4 Answers

2
votes

This can happen if the artifact or metadata got corrupted. Try to clean out your local repo by deleting all versions of the maven-archetype-plugin (including metadata and pom files).

Then execute archetype:generate again.

0
votes

The issue was resolved by removing the entry for localRepository in settings.xml . Starting to generate the archetype again Move the downloaded artifacts the place where we wanted G:/m2Repo start generating the artifact again. Now the jars etc would get downloaded to the new place automatically

The problem which I can think is that I had deleted the {users.home}/.m2 folder also and that was preventing the download .

0
votes

I had a similar issue.

Environment:

`OS`: Mac Seirra 10.12.6.  
`Java version` :1.8.0_144
`Maven` 3.5.4

Solution :

rm -rf ~/.m2/repository/org/apache/maven/plugins/maven-archetype-plugin/
-1
votes

My error was:

(http://mirrors.ibiblio.org/pub/mirrors/maven2):

Plugin not found in any plugin repository

Solution :

1. go to .m2 folder > repository
2. delete all folders inside this 
3. try the following command again:

mvn archetype:generate