Settings for Maven for conditional checkout or update from SVN? - maven

I have following settings in POM file.But my build script fails with 'SVN file locked' message.Is there any other way to do conditional checkout.If project is already checked out then I want to update only otherwise if project is not checkedout it should check out the code and should not update it.Thanks in advance.
<!-- Initial check out of (will not do anything if directory already there) -->
<execution>
<id>check-out-project</id>
<phase>generate-sources</phase>
<goals>
<goal>checkout</goal>
</goals>
<configuration>
<checkoutDirectory>${project.build.directory}/project</checkoutDirectory>
<connectionUrl>scm:svn:http://XX:XX/svn/repos/${XX}</connectionUrl>
<username>${svn.username}</username>
<password>${svn.password}</password>
<skipCheckoutIfExists>true</skipCheckoutIfExists>
</configuration>
</execution>
<!-- Update project (if directory was already there) -->
<execution>
<id>update-project</id>
<phase>generate-sources</phase>
<goals>
<goal>update</goal>
</goals>
<configuration>
<basedir>${project.build.directory}/project</basedir>
<connectionUrl>scm:svn:http://XXX:XXX/svn/repos/${project}</connectionUrl>
<username>${svn.username}</username>
<password>${svn.password}</password>
<revisionKey>project.revision</revisionKey>
</configuration>
</execution>
Error log after running maven (Please note I have replaced directory paths and urls with xxxx)
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building xxxxxx.and.xxxxxx 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-xxxxxx-xxxxxx) # xxxxxx.and.
xxxxxx ---
[INFO]
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-sat) # xxxxxx.and.xxxxxx ---
[INFO]
[INFO] --- maven-scm-plugin:1.4:checkout (check-out-xxxxxx) # xxxxxx.and.xxxxxx --
-
[INFO] Removing x:\xxxx\xxxx\target\xxxxxx
[INFO] Executing: cmd.exe /X /C "svn --username xxxx --password ***** --no-aut
h-cache --non-interactive checkout http://xxxx:xxx/svn/repos/xxxx/xxx x:\
projects\xxxx\target\xxxxxx"
[INFO] Working directory: x:\xxxx\xxxx\target
[INFO]
[INFO] --- maven-scm-plugin:1.4:update (update-xxxxxx) # xxxxxx.and.xxxxxx ---
[INFO] Executing: cmd.exe /X /C "svn --username xxxx --password ***** --no-aut
h-cache --non-interactive update x:\xxxx\xxx\target\xxxxxx"
[INFO] Working directory: x:\xxx\xxx\target\xxxxxx
[INFO] Svn command failed due to some locks in working copy. We try to run a 'sv
n cleanup'.
[INFO] Executing: cmd.exe /X /C "svn"
[INFO] Working directory: x:\xxx\xxxx\target\xxxxxx
[ERROR] Provider message:
[ERROR] The svn command failed.
[ERROR] Command output:
[ERROR] svn: Working copy 'x:\xxxx\xxxx\target\xxxxxx' locked
svn: run 'svn cleanup' to remove locks (type 'svn help cleanup' for details)
Type 'svn help' for usage.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8:03.303s
[INFO] Finished at: Thu Apr 28 17:24:50 BST 2011
[INFO] Final Memory: 4M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-scm-plugin:1.4:upd
ate (update-xxxxxx) on project xxxxxx.and.xxxxxx: Command failed.The svn command f
ailed. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[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 rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionE
xception

First run
mvn clean
After this run
mvn scm:update

Related

Maven release issue - JUnit tests run when they shouldn't

I need to be able to run Maven release:prepare / release:perform on an artifact from Jenkins without its JUnit tests running.
Surefire configuration in my test pom.xml
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<executions>
<execution>
<id>default-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<testFailureIgnore>false</testFailureIgnore>
</configuration>
</execution>
</executions>
<configuration>
<testFailureIgnore>false</testFailureIgnore>
</configuration>
</plugin>
Apache’s Surefire documentation suggests using either mvn install -DskipTests or mvn install -Dmaven.test.skip=true. Both work when I run an install:
mvn clean install -Dsurefire.testFailureIgnore=true --show-version --batch-mode -e
But neither argument works when I try them on a release:perform.
I’ve tried the following commands:
mvn -DpreparationGoals=clean release:prepare release:perform -DskipTests -e --batch-mode --show-version -Dusername=**** -Dpassword=**** -Dresume=false
I’d expect the tests to be skipped and the release:perform to succeed. Instead, the tests run and fail (see below) causing the entire release:perform to fail.
mvn -DpreparationGoals=clean release:prepare release:perform -Dmaven.test.skip=true -e --batch-mode --show-version -Dusername=**** -Dpassword=**** -Dresume=false
I’d expect the tests to be skipped and the release:perform to succeed. Instead, the tests run and fail (see below) causing the entire release:perform to fail.
mvn -DpreparationGoals=clean release:prepare release:perform -Dsurefire.testFailureIgnore=true -e --batch-mode --show-version -Dusername=**** -Dpassword=**** -Dresume=false
This isn’t ideal (there’s no need to rerun the JUnit tests since they’ve already been run), but if ignoring the JUnit results allows the release:perform to succeed, that would get us by for now. Instead of ignoring the results, the tests run and still fail, though, causing the entire release:perform to fail.
mvn -DpreparationGoals=clean release:prepare release:perform -fn -e --batch-mode --show-version -Dusername=**** -Dpassword=**** -Dresume=false
This isn’t ideal either. It does allow release:perform to complete successfully, but at the expense of end users not being notified if the release:perform fails for other reasons than failed JUnit tests.
Here’s the output from running either release:prepare release:perform -DskipTests or release:prepare release:perform -Dmaven.test.skip=true:
+ mvn -DpreparationGoals=clean release:prepare release:perform -DskipTests -e --batch-mode --show-version -Dusername=**** -Dpassword=**** -Dresume=false
Apache Maven 3.2.5 (12a6b3acb947671f09b81f49094c53f426d8cea1; 2014-12-14T11:29:23-06:00)
…
Java version: 1.7.0_71, vendor: Oracle Corporation
…
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-862.11.6.el7.x86_64", arch: "amd64", family: "unix"
[INFO] [INFO] --- maven-surefire-plugin:2.22.1:test (default-test) # TestInvProfileWeb ---
[INFO] [INFO]
[INFO] [INFO] -------------------------------------------------------
[INFO] [INFO] T E S T S
[INFO] [INFO] -------------------------------------------------------
[INFO] [INFO] Running com.investmentprofile.jsf.EndUserBeanTest
[INFO] [ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.028 s <<< FAILURE! - in com.investmentprofile.jsf.EndUserBeanTest
[INFO] [ERROR] test1(com.investmentprofile.jsf.EndUserBeanTest) Time elapsed: 0.008 s <<< FAILURE!
[INFO] junit.framework.AssertionFailedError
[INFO] at com.investmentprofile.jsf.EndUserBeanTest.test1(Unknown Source)
[INFO]
[INFO] [INFO]
[INFO] [INFO] Results:
[INFO] [INFO]
[INFO] [ERROR] Failures:
[INFO] [ERROR] EndUserBeanTest.test1:48
[INFO] [INFO]
[INFO] [ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0
[INFO] [INFO]
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Reactor Summary:
[INFO] [INFO]
[INFO] [INFO] TestInvProfileWebParent ............................ SUCCESS [ 1.622 s]
[INFO] [INFO] TestInvProfileWebClient ............................ SUCCESS [ 8.253 s]
[INFO] [INFO] TestInvProfileWeb .................................. FAILURE [ 5.333 s]
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] BUILD FAILURE
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Total time: 15.396 s
[INFO] [INFO] Finished at: 2018-10-19T13:40:42-05:00
[INFO] [INFO] Final Memory: 48M/600M
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.1:test (default-test) on project TestInvProfileWeb: There are test failures.
[INFO] [ERROR]
[INFO] [ERROR] Please refer to /opt/Jenkins/workspace/unk_TestInvProfileWebParent-YI772VMG3PH6E767GSGQFPUMCBV45RSLSRI75337QAZHUOO63NUQ/target/checkout/TestInvProfileWebParent/TestInvProfileWeb/target/surefire-reports for the individual test results.
[INFO] [ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[INFO] [ERROR] -> [Help 1]
[INFO] [ERROR]
[INFO] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[INFO] [ERROR] Re-run Maven using the -X switch to enable full debug logging.
[INFO] [ERROR]
[INFO] [ERROR] For more information about the errors and possible solutions, please read the following articles:
[INFO] [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[INFO] [ERROR]
[INFO] [ERROR] After correcting the problems, you can resume the build with the command
[INFO] [ERROR] mvn <goals> -rf :TestInvProfileWeb
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] TestInvProfileWebParent ............................ FAILURE [ 20.071 s]
[INFO] TestInvProfileWebClient ............................ SKIPPED
[INFO] TestInvProfileWeb .................................. SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 20.508 s
[INFO] Finished at: 2018-10-19T13:40:42-05:00
[INFO] Final Memory: 15M/210M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5:perform (default-cli) on project TestInvProfileWebParent: Maven execution failed, exit code: '1' -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5:perform (default-cli) on project TestInvProfileWebParent: Maven execution failed, exit code: '1'
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:355)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:216)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:160)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: Maven execution failed, exit code: '1'
at org.apache.maven.plugins.release.PerformReleaseMojo.execute(PerformReleaseMojo.java:181)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 19 more
Caused by: org.apache.maven.shared.release.ReleaseExecutionException: Maven execution failed, exit code: '1'
at org.apache.maven.shared.release.phase.AbstractRunGoalsPhase.execute(AbstractRunGoalsPhase.java:89)
at org.apache.maven.shared.release.phase.RunPerformGoalsPhase.runLogic(RunPerformGoalsPhase.java:135)
at org.apache.maven.shared.release.phase.RunPerformGoalsPhase.execute(RunPerformGoalsPhase.java:46)
at org.apache.maven.shared.release.DefaultReleaseManager.perform(DefaultReleaseManager.java:429)
at org.apache.maven.shared.release.DefaultReleaseManager.perform(DefaultReleaseManager.java:381)
at org.apache.maven.plugins.release.PerformReleaseMojo.execute(PerformReleaseMojo.java:177)
... 21 more
Caused by: org.apache.maven.shared.release.exec.MavenExecutorException: Maven execution failed, exit code: '1'
at org.apache.maven.shared.release.exec.InvokerMavenExecutor.executeGoals(InvokerMavenExecutor.java:394)
at org.apache.maven.shared.release.exec.AbstractMavenExecutor.executeGoals(AbstractMavenExecutor.java:110)
at org.apache.maven.shared.release.phase.AbstractRunGoalsPhase.execute(AbstractRunGoalsPhase.java:81)
... 26 more
How can I get Surefire not to run tests during release:perform?
Regards,
M.Manojkumar
First, I agree with the two comments above. That said, the problem is that your '-DskipTests' needs to be passed to the release:perform. You can do that by setting the arguments parameter:
mvn release:perform -Darguments=-DskipTests

Building SonarQube with maven and batch_boostrap/index cannot be found

I'm running mvn sonar:sonar in the directory of the project I'm running. I already have my pom.xml updated:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>2.7.1</version>
</plugin>
After running sudo mvn sonar:sonar (I am on ubuntu 14.04) in my terminal, I get the following error:
eschwartz#LATITUDE:~/ideaprojects/xQueryEngine$ sudo mvn sonar:sonar
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building xQueryEngine (Solr 4 REX) 1.11.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- sonar-maven-plugin:2.7.1:sonar (default-cli) # xqe ---
[INFO] User cache: /root/.sonar/cache
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.854s
[INFO] Finished at: Wed Feb 17 15:56:59 EST 2016
[INFO] Final Memory: 17M/302M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.7.1:sonar (default-cli) on project xqe: Fail to download libraries from server: Status returned by url : 'http://localhost:9000/batch_bootstrap/index' is invalid : 404 -> [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/MojoExecutionException
Anyone know how to fix this?
Thanks.
You have to set sonar.host.url=http://localhost:9000/sonar. You can do this by passing -Dsonar.host.url=... to mvn, or ideally set it in your Maven Global/Project Settings so that you don't always have to pass it as a command line argument.
Details: if your dashboard is at localhost:9000/sonar then it means you're using sonar.web.context=/sonar , which is different from the default (/). So you need to tell the scanner where to find SonarQube.

"Auth fail" error with maven-scm-provider-jgit during release:prepare

I am on a windows machine where git command line is not installed. I have installed GitExtensions and an EGit and this is sufficient for me (until now).
Now I wanted to perform a maven release to BinTray, following this guide:
Publishing releases using Github, Bintray and maven-release-plugin
Running:
mvn -Prelease release:prepare
Produces this output:
[INFO] ------------------------------------------------------------------------
[INFO] Building xxxxx 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-release-plugin:2.4.1:prepare (default-cli) # xxxxx ---
[INFO] Resuming release from phase 'scm-commit-release'
[INFO] Checking in modified POMs...
[INFO] Executing: cmd.exe /X /C "git add -- pom.xml"
[INFO] Working directory: C:\Users\jbr\git\yyyyyyyyyyyyyyy
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.770 s
[INFO] Finished at: 2015-09-12T20:17:24+02:00
[INFO] Final Memory: 20M/989M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.4.1:prepare (default-cli) on project xxxxx: Unable to commit files
[ERROR] Provider message:
[ERROR] The git-add command failed.
[ERROR] Command output:
[ERROR] 'git' is not recognized as an internal or external command,
[ERROR] operable program or batch file.
Absolutely fair, I never use the git command from the windows shell and I never set up the pageant.exe stuff. (for details see this answer to the question “Why git can't remember my passphrase under Windows”).
My second idea was to use the maven-scm-provider-jgit to not depend on the git command line.
The output is now:
[INFO] ------------------------------------------------------------------------
[INFO] Building xxxxx 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-release-plugin:2.4.1:prepare (default-cli) # xxxxx ---
[INFO] Change the default 'git' provider implementation to 'jgit'.
[INFO] Resuming release from phase 'scm-commit-release'
[INFO] Checking in modified POMs...
[INFO] push changes to remote... refs/heads/master:refs/heads/master
[INFO] fetch url: git#github.com:jmini/yyyyyyyyyyyyyyy.git
[INFO] push url: git#github.com:jmini/yyyyyyyyyyyyyyy.git
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.4.1:prepare (default-cli) on project xxxxx: An error is occurred in the checkin process: Exception while executing SCM command. JGit checkin failure! git#github.com:jmini/yyyyyyyyyyyyyyy.git: Auth fail -> [Help 1]
Much better, but still no luck.
My guess is that the private key and the passphrase are not loaded. How should I configure them?
This answer suggests that for some SCM providers, it is possible to specify the credentials in the <servers> section of settings.xml. The domain name of the repository should be used as <id>.
According to the last comment with scm:git:ssh://git#bitbucket.org/{account}/{project} used in the <developerConnection>, this entry is working in the settings.xml:
<server>
<id>bitbucket.org</id>
<privateKey>/c/Users/neil.hunt/.ssh/id_rsa</privateKey>
</server>
Is this construct supported by the JGit SCM provider?
When searching for “Auth failed” error, I found this related question (plain JGit, no maven plugin):
How do you set the configuration for jschconfigsessionfactory for jgit so that pull and push work?

500 error when using github site-maven-plugin to publish directory to gh-pages

I'm trying to use the github site plugin to copy a directory to my gh-pages branch on github. I'm getting a 500 error whenever I try, though.
Here's my build configuration:
<plugin>
<groupId>com.github.github</groupId>
<artifactId>site-maven-plugin</artifactId>
<version>0.7</version>
<configuration>
<message>Creating site for ${project.version}</message>
<branch>gh-pages</branch>
<noJekyll>true</noJekyll>
<outputDirectory>${project.build.directory}/mvn-repo</outputDirectory>
<includes>
<include>**/*</include>
</includes>
<repositoryName>greenDAO</repositoryName>
<repositoryOwner>emmby</repositoryOwner>
</configuration>
</plugin>
Here's the output of mvn ghSite:site
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building DaoCore 1.3-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- site-maven-plugin:0.7:site (default-cli) # greendao ---
[INFO] Creating 12 blobs
[INFO] Creating tree with 13 blob entries
[INFO] Creating commit with SHA-1: 656a23ffd7d898c2d45a107ee4f8f2d8ee86706e
[INFO] Creating reference gh-pages starting at commit 656a23ffd7d898c2d45a107ee4f8f2d8ee86706e
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.608s
[INFO] Finished at: Sat Dec 22 22:25:21 MST 2012
[INFO] Final Memory: 7M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.github:site-maven-plugin:0.7:site (default-cli) on project greendao: Error creating reference: Server Error (500) -> [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/MojoExecutionException
You can find the full output of mvn -X ghSite:site here.
Any ideas what I might be doing wrong?
(My authentication credentials are in my ~/.m2/settings.xml file and appear to be correct, since the push fails with an authentication error if I comment them out.)
Your branch is incorrect:
<branch>gh-pages</branch>
Remove it and use the default.
Did you try this maven plugin http://maven.apache.org/plugins/maven-scm-publish-plugin/various-tips.html ?

maven error BUILD FAILURE

I am following a maven tutorial. I am trying to execute this command which is my 1st maven command. Tutorial says it will crate a directory named my-app, but it didn't. This is command & its output,
command:
mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
output:
C:\Users\Babar>mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=m
y-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:2.1:generate (default-cli) # standalone-pom >>
>
[INFO]
[INFO] <<< maven-archetype-plugin:2.1:generate (default-cli) # standalone-pom <<
<
[INFO]
[INFO] --- maven-archetype-plugin:2.1:generate (default-cli) # standalone-pom --
-
[INFO] Generating project in Batch mode
[INFO] -------------------------------------------------------------------------
---
[INFO] Using following parameters for creating project from Old (1.x) Archetype:
maven-archetype-quickstart:1.0
[INFO] -------------------------------------------------------------------------
---
[INFO] Parameter: groupId, Value: com.mycompany.app
[INFO] Parameter: packageName, Value: com.mycompany.app
[INFO] Parameter: package, Value: com.mycompany.app
[INFO] Parameter: artifactId, Value: my-app
[INFO] Parameter: basedir, Value: C:\Users\Babar
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 22.971s
[INFO] Finished at: Fri Nov 18 00:07:12 EET 2011
[INFO] Final Memory: 6M/11M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2
.1:generate (default-cli) on project standalone-pom: Directory my-app already ex
ists - please run from a clean directory -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[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 rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureExc
eption
'cmd' is not recognized as an internal or external command,
operable program or batch file.
error msg says directory already exists but it's not. I execute this command more than oncw
EDIT
command(suggested in answer)
mvn archetype:generate -DarchetypeGroupId=org.apache.maven.archet
ypes -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=5-SNAPS
HOT
OUTPUT
C:\Users\Babar>mvn archetype:generate -DarchetypeGroupId=org.apache.maven.archet
ypes -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=5-SNAPS
HOT
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:2.1:generate (default-cli) # standalone-pom >>
>
[INFO]
[INFO] <<< maven-archetype-plugin:2.1:generate (default-cli) # standalone-pom <<
<
[INFO]
[INFO] --- maven-archetype-plugin:2.1:generate (default-cli) # standalone-pom --
-
[INFO] Generating project in Interactive mode
[INFO] Archetype repository missing. Using the one from [org.apache.maven.archet
ypes:maven-archetype-quickstart:1.1] found in catalog remote
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.552s
[INFO] Finished at: Fri Nov 18 01:09:15 EET 2011
[INFO] Final Memory: 6M/12M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2
.1:generate (default-cli) on project standalone-pom: The desired archetype does
not exist (org.apache.maven.archetypes:maven-archetype-quickstart:5-SNAPSHOT) ->
[Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[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 rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureExc
eption
'cmd' is not recognized as an internal or external command,
operable program or batch file.
Close your eclipse
Delete the .m2 folder which shows the server connnection
Re-run your eclipse.
Try this one, it works for maven 3-3-9 for win7 32bit
mvn archetype:generate -DgroupId="com.mycompany.app" -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
Try this :
mvn archetype:generate -DgroupId="com.mycompany.app" -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
Your sentences have been modified -DgroupId="com.mycompany.app". You need to use double quotes.
I´ve worked on windows 8 and it works. I don´t know if it happens on Linux.
I faced the same issue, and I resolved by run the commond(MVN Clean) from inside the folder where pom.xml located. Please follow below steps:
Open Eclipse
Open your Maven project.
Right Click on pom.xml
Click on properties
5.Copy pom.xml location URL
Open cmd
Write and paste the pom.xml location in the cmd until before /pom.xml as below,
cd C:\Users\X\eclipse-workspace\Your project Name
Hit Enter.
Run mvn clean commond again.
You will note that the original error said
Directory my-app already exists - please run from a clean directory
Did you possibly run that command from a directory where there is already a Maven project (one with a pom.xml file)? If so please start with a clean location.
When I ran the command you used verbatim on an empty directory, it ran without error and created a directory called my-app.
This line is of concern:
[INFO] Using following parameters for creating project from Old (1.x)
Archetype: maven-archetype-quickstart:1.0
Looking at the maven docs page at http://maven.apache.org/archetype/maven-archetype-bundles/maven-archetype-quickstart/, i see that the command you should be using is:
mvn archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=5-SNAPSHOT
Which is not exactly what you are running (you are missing the -DarchetypeVersion=5-SNAPSHOT part).

Resources