If I type the command:
mvn dependency:list
The docs suggest that I'll get a list of my project's dependencies. Instead though, I get this:
[INFO] Searching repository for plugin with prefix: 'dependency'.
[INFO] -----------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] -----------------------------------------------------------
[INFO] Required goal not found: dependency:list
Call me a hopeful naive, but I had hoped maven would download any plugins it didn't have. Does anyone know what might be leading to this error? Does anyone know where maven stores information about what plugins it has installed, and where they're stored in the maven repository?
Have you tried mvn -cpu dependency:list (or: mvn --check-plugin-updates dependency:list)? Probably, you have older version of dependency plugin which does not have goal list
If this does not help, try upgrading Maven. Since 2.0.9 default versions are provided by the Super POM for most important plugins (dependency plug-in included), so 2.0 version will be downloaded (which has list goal).
Or you can try removing the cached version of the plug-in from the repository (~/.m2/repository/org/apache/maven/plugins/maven-dependency-plugin/, where ~ is the user home directory).
I have gotten a similiar result from being behind the corporate firewall. Proxy settings in your config (settings.xml) might be the answer.
<proxies>
<proxy>
<id>proxy</id>
<active>true</active>
<username>user</username>
<password>passwrd</password>
<protocol>http</protocol>
<host>example.proxy.name.com</host>
<port>80</port>
</proxy>
</proxies>
To answer my own question, thanks to some comments that were made on it, the settings.xml file had been customized and did not list the central maven repository.
Oops.
Many Maven troubles can be solved easier by knowing all the details of the failed attempt when posting to forums (answering many of the follow-up questions folks above posted) or mailing list, and this is accomplished by running Maven with the debug and exception option switches like so: mvn <yourgoal> -X -e
Sample output then will look like this:
[~/Documents/Temp/Scratch] mvn clean -e -X
Using Java version: 1.6
+ Error stacktraces are turned on.
Maven version: 2.0.9
Java version: 1.6.0_07
OS name: "mac os x" version: "10.5.6" arch: "x86_64" Family: "mac"
[DEBUG] Building Maven user-level plugin registry from: '/Users/mccm06/.m2/plugin-registry.xml'
[DEBUG] Building Maven global-level plugin registry from: '/Applications/Dev/apache-maven/conf/plugin-registry.xml'
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO] task-segment: [clean]
[INFO] ------------------------------------------------------------------------
[DEBUG] Retrieving parent-POM: org.apache.maven.plugins:maven-plugins::10 for project: null:maven-clean-plugin:maven-plugin:2.2 from the repository.
[DEBUG] Retrieving parent-POM: org.apache.maven:maven-parent::7 for project: org.apache.maven.plugins:maven-plugins:pom:10 from the repository.
[DEBUG] Retrieving parent-POM: org.apache:apache::4 for project: org.apache.maven:maven-parent:pom:7 from the repository.
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Cannot execute mojo: clean. It requires a project with an existing pom.xml, but the build is not using one.
[INFO] ------------------------------------------------------------------------
[DEBUG] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Cannot execute mojo: clean. It requires a project with an existing pom.xml, but the build is not using one.
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:583)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:499)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:478)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:330)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:291)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:142)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:287)
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.MojoExecutionException: Cannot execute mojo: clean. It requires a project with an existing pom.xml, but the build is not using one.
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:377)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:558)
... 16 more
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Mon Feb 16 10:59:39 MST 2009
[INFO] Final Memory: 2M/7M
[INFO] ------------------------------------------------------------------------
Try latest maven version, usually upgrades to newer versions solve issues.
While unrelated to your issue being fixed, first you should execute install and only then try executing goals for your plugin.
Related
I am very new to maven was about to start learning spring with maven but when I created my first project with maven in eclipse this error occurred and I think maven plugins are not getting downloaded. I have tried several solutions from stackoverflow but nothing worked.
Console Window is like :-
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.097 s
[INFO] Finished at: 2020-06-01T21:17:39-07:00
[INFO] ------------------------------------------------------------------------
[ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [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/NoGoalSpecifiedException
Error window is like this:-
Please see this screenshot for exact information of errors.
Screenshot attached
POM.xml file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.anuragr07</groupId>
<artifactId>springpractice</artifactId>
<version>0.0.1-SNAPSHOT</version>
</project>
Solutions tried so far:-
Installing maven using help > install a new software option
Tried mvn install using cmd
Tried uncommenting proxy tag in setting.xml file
Tried 'https' instead of 'http' in proxy tag in settings.xml file
Tried reinstalling eclipse
and maybe more..
After mvn package
E:\Workspace\springpractice>mvn package
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------< com.anuragr07:springpractice >--------------------
[INFO] Building springpractice 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-resources-plugin/2.6/maven-resources-plugin-2.6.pom
**Downloaded all the plugins**
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 20.831 s
[INFO] Finished at: 2020-06-01T23:52:35-07:00
[INFO] ------------------------------------------------------------------------
I am really frustrated and searching for solutions from past 24 hours. Please help me resolve this.
Thanks!
The given ERORR is the cause of the default goal.
ERROR No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format : or :[:]:.
Resolution:
Specify any goal in your run configuration for maven build like clear, compile, install, package.
install
...
Could you please refer to the given steps?
Right click on your project.
Click 'Run as' and select 'Maven Build'
Edit Configuration window will open.
write any goal but your problem specific write 'package'
in Goal text box.
Click on 'Run'
There was an issue with the settings.xml file and the solution is:-
Close the eclipse first - try to work in CMD and configure maven there. Remove setting.xml in your user directory if the file exists there.
Download Maven from official site.
Add the path to %MVN_HOME%\bin to the Path env. variable in windows.
open CMD and cd to the folder where you have a pom.xml.
Type: mvn package. 6. Post the output.
Thanks to #MarkBramnik
you have to designate maven goal.
in pom.xml, insert that
<build>
<defaultGoal>install</defaultGoal>
</build>
I guess there is no defaultGoal in your pom.xml.
I have successfully installed a JAR into the Maven local repository. I edit my pom.xml to include these lines:
<dependency>
<groupId>org.jcrontab</groupId>
<artifactId>jcrontab</artifactId>
<version>4.0.0</version>
<scope>system</scope>
<systemPath>[somepath]/jcrontab-4.0.0.jar</systemPath>
</dependency>
But, after installing with install:install-file, I think these lines are redundant. I just use them to install and when I want to "use" the jar, they are useless because the jar is in the local repo.
So I changed them to:
<dependency>
<groupId>org.jcrontab</groupId>
<artifactId>jcrontab</artifactId>
<version>4.0.0</version>
</dependency>
The same form as those dependencies that exist in the remote Maven central repo. But now Eclipse complains about:
missing artifact: org.jcrontab:jcrontab:jar:4.0.0
And in the Maven dependencies library in Java Build path, I see red cross on the jar, saying:
jcrontab-4.0.0.jar - D:\desarrollo\eclipse-jee-mars-x86_64\eclipse\${maven.home}\m2\repository\org\jcrontab\jcrontab\4.0.0 (missing)
Under this dir, I only see:
jcrontab-4.0.0.jar.lastUpdated jcrontab-4.0.0.pom.lastUpdated
And no jar is there. But other dependencies jars in this Eclipse repo are in their places.
As I examine my maven home repo (<maven-installation-dir>/m2/repository), the jar is installed there. But in the repo under Eclipse dir, the jar is missing.
I am confused.
If the installation of external jar generates a JAR under Maven installation repo, why does Eclipse "Maven dependencies" library points to a repo under Eclipse dir? The {$maven.home} directory smells bad to me.
Am I supposed to change the dependencies of local installed jars like what I did?
As suggested, I execute the command of install:install-file, and I get:
C:\Windows\System32>mvn install:install-file -Dfile="D:\desarrollo\Java environment\lib\jcrontab-4.0.0.jar" -DgroupId=org.jcronta
b -DartifactId=jcrontab -Dversion=4.0.0 -Dpackaging=jar
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.4:install-file (default-cli) # standalone-pom ---
[INFO] Installing D:\desarrollo\Java environment\lib\jcrontab-4.0.0.jar to D:\desarrollo\Java environment\lib\Maven\apache-maven-3.5.0\bin\..\m2\repository\org\jcrontab\jcrontab\4.0.0\jcrontab-4.0.0.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.597 s
[INFO] Finished at: 2017-08-03T14:27:48+02:00
[INFO] Final Memory: 6M/114M
[INFO] ------------------------------------------------------------------------
The same form as those dependencies that exist in the remote Maven central repo.
But jcrontab doesn't exist on maven central.
See yourself on maven central: https://search.maven.org/#search|ga|1|jcrontab
So you need to install the jar into your local repository if you want to use it like another dependency. You can do that like that:
mvn install:install-file -Dfile=jcrontab-4.0.0.jar -DgroupId=org.jcrontab -DartifactId=jcrontab -Dversion=4.0.0 -Dpackaging=jar
See also the maven documentation here: https://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html
I've been happily developing my API in AnypointStudio (Eclipse) 6.2.2 until just now I added a JSON-to-Object transformer to a flow; now when I build mvn clean package -U
I get:
Downloading: https://repository.mulesoft.org/nexus/content/repositories/public/org/mule/extensions/mule-extensions/3.8.3/mule-extensions-3.8.3.pom
[INFO] BUILD FAILURE
[INFO] -----------------------------------------------------------------------
[INFO] Total time: 14.775 s
[INFO] Finished at: 2017-07-19T10:38:10+10:00
[INFO] Final Memory: 25M/644M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project foobar: Could not resolve dependencies for project org.foo:bar:mule:1.0.0-SNAPSHOT: Failed to collect dependencies at org.mule.modules:mule-module-json:jar:3.8.3 -> org.mule.modules:mule-module-validation:jar:3.8.3: Failed to read artifact descriptor for org.mule.modules:mule-module-validation:jar:3.8.3: Could not find artifact org.mule.extensions:mule-extensions:pom:3.8.3 in Central (http://central.maven.org/maven2/) -> [Help 1]
Can anyone suggest what's going wrong? Do I need an EE licence to use JSON-to-Object?
I found the answer to this. My POM was using Mule runtime 3.8.3
<mule.version>3.8.3</mule.version>
However, there is no release of the json module that corresponds to this release. The latest at Mulesoft Releases is 3.8.1:
https://repository.mulesoft.org/nexus/content/repositories/releases/org/mule/modules/mule-module-json/3.8.1/
So, manually changing the version of this dependency in my POM gets around the issue:
<dependency>
<groupId>org.mule.modules</groupId>
<artifactId>mule-module-json</artifactId>
<version>3.8.1</version>
<scope>provided</scope>
</dependency>
I'm trying to follow the get started manual of maven, but I receive this error
c:\Ambiente\workspace>mvn archetype:generate \ -DarchetypeGroupId=org.apache.maven.archety
pes \ -DgroupId=com.mycompany.app \ -DartifactId=my-app -X
Apache Maven 3.1.0 (893ca28a1da9d5f51ac03827af98bb730128f9f2; 2013-06-27 23:15:32-0300)
Maven home: C:\Ambiente\apache-maven-3.1.0
Java version: 1.7.0_25, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.7.0_25\jre
Default locale: pt_BR, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "x86", family: "windows"
[INFO] Error stacktraces are turned on.
[DEBUG] Reading global settings from C:\Ambiente\apache-maven-3.1.0\conf\settings.xml
[DEBUG] Reading user settings from C:\Users\t316360\.m2\settings.xml
[DEBUG] Using local repository at C:\Users\t316360\.m2\repository
[DEBUG] Using manager EnhancedLocalRepositoryManager with priority 10.0 for C:\Users\t3163
60\.m2\repository
[INFO] Scanning for projects...
[DEBUG] Extension realms for project org.apache.maven:standalone-pom:pom:1: (none)
[DEBUG] Looking up lifecyle mappings for packaging pom from ClassRealm[plexus.core, parent
: null]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.078s
[INFO] Finished at: Mon Jul 22 17:23:03 BRT 2013
[INFO] Final Memory: 11M/247M
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM in this d
irectory (c:\Ambiente\workspace). Please verify you invoked Maven from the correct directo
ry. -> [Help 1]
org.apache.maven.lifecycle.MissingProjectException: The goal you specified requires a proj
ect to execute but there is no POM in this directory (c:\Ambiente\workspace). Please verif
y you invoked Maven from the correct directory.
what is POM and what do I suppose to do to have this file?
A pom.xml file describes how to build a project. It can be considered the Java version of a Makefile in C/C++ or setup.py in Python. Are you following a specific example?
The pom.xml file is the core of a project's configuration in Maven. It is a single configuration file that contains the majority of information required to build a project in just the way you want. The POM is huge and can be daunting in its complexity, but it is not necessary to understand all of the intricacies just yet to use it effectively.
Below is just a simple example:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Maven Quick Start Archetype</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
To build the dependencies that you specified in pom.xml file execute:
mvn clean package
After a successfull mvn package you will see something like below:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2 seconds
[INFO] Finished at: Tue Jul 23 (Time..)
[INFO] Final Memory: 3M/6M
[INFO] -----------------------------
the above command will download all the dependencies to your home directory /home/user/.m2/..
Have a look on this How to create a maven project
Also have a look to Maven in 5 min
The way you tried the command is supposed to work for Linux environment and you are running Windows. Please double check the command (likely removing the \ ) and it should work just fine.
I cannot import a maven project with WTP features enabled.
I have already tried:
mvn -Dwtpversion=R7 eclipse:eclipse
When I did the import, the WTP features are not enabled.
How do I import with the features enabled?
Does the maven-eclipse-plugin generate the .wtpmodules file as expected? This is what I get when running the same command on a war project:
$ mvn -Dwtpversion=R7 eclipse:eclipse
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'eclipse'.
[INFO] ------------------------------------------------------------------------
[INFO] Building maven-eclipse-plugin-wtp-testcase
[INFO] task-segment: [eclipse:eclipse]
[INFO] ------------------------------------------------------------------------
[INFO] Preparing eclipse:eclipse
[INFO] No goals needed for project - skipping
[INFO] [eclipse:eclipse {execution: default-cli}]
[INFO] Adding support for WTP version R7.
[INFO] Using Eclipse Workspace: null
[INFO] Adding default classpath container: org.eclipse.jdt.launching.JRE_CONTAINER
[INFO] Not writing settings - defaults suffice
[INFO] Wrote Eclipse project for "maven-eclipse-plugin-wtp-testcase" to /home/pascal/Projects/maven-eclipse-plugin-wtp-testcase.
[INFO]
Javadoc for some artifacts is not available.
Please run the same goal with the -DdownloadJavadocs=true parameter in order to check remote repositories for javadoc.
List of artifacts without a javadoc archive:
o junit:junit:3.8.1
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3 seconds
[INFO] Finished at: Tue Oct 27 22:49:17 CET 2009
[INFO] Final Memory: 9M/79M
[INFO] ------------------------------------------------------------------------
$ ls -a
. .. .classpath pom.xml .project src .wtpmodules
$ cat .wtpmodules
<project-modules id="moduleCoreId">
<wb-module deploy-name="maven-eclipse-plugin-wtp-testcase">
<module-type module-type-id="jst.web">
<version>2.4</version>
<property name="context-root" value="maven-eclipse-plugin-wtp-testcase"/>
</module-type>
<wb-resource deploy-path="/" source-path="/src/main/webapp"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/java"/>
</wb-module>
$
On my environment, the eclipse plugin seems seems to be working fine.
That said, WTP R7 (0.7) is quite old (it was released in July 2005) and may not be the right version for your configuration. According to the Web Tools Platform downloads page, WTP 0.7 and WTP 1.0 goes with Eclipse 3.1, WTP 1.5 goes with Eclipse 3.2, WTP 2.0 goes with Eclipse 3.3, WTP 2.1 and WTP 3.0 goes with Eclipse 3.4, WTP 3.1 goes with Eclipse 3.5.
So the question is: what versions of Eclipse and of the WTP are you running?
The plugin actually can create WTP R7, 1.0, 1.5 and 2.0 configuration files as mentioned on the WTP Support page (2.0 is currently missing in the documentation of the wtpversion optional parameter but this is a documentation bug, see MECLIPSE-434). I've successfully imported a generated WTP 2.0 project in Eclipse 3.5.1 + WTP 3.1 so using 2.0 should be ok for recent versions of Eclipse (regardless of MECLIPSE-559).
Note: If you don't want to pass the wtpversion on the command line, you can set it in the maven-eclipse-plugin configuration in your pom.xml like this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<wtpversion>2.0</wtpversion>
...
</configuration>
</plugin>
Don't forget to run a
mvn eclipse:clean eclipse:eclipse
To remove the previously created eclipse wtp configuration files