How can I force a Maven clean? - maven

I'm using Maven 3.0.3 on WinXP and running my Maven build commands through Cygwin. Occassionally, I'll be able to run a maven clean ...
mvn clean install
And I'll get errors like ...
[INFO] Deleting C:\Documents and Settings\E18538\workspace\iteration1\target
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.891s
[INFO] Finished at: Mon Jan 23 11:07:58 CST 2012
[INFO] Final Memory: 4M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.4.1:clean (default-clean) on project myco-productplus-web: Failed to clean project:Failed to delete C:\Documents and Settings\E18538\workspace\iteration1\target -> [Help 1]
Other than Cygwin, I'll close all other applications, but there is still a process holding something in "target". How do I figure out what that process is and then kill it? Note that when I restart my system, I can again run "mvn clean" commands.
Edit: The process that is holding onto the directory in question is "TGitCache.exe", spawned by TortoiseGit, installed on my system. I have marked the "target" directory as one to ignore, so I'm wondering if there's a way to cause this process to ignore target.
Thanks, - Dave

Run mvn -X clean to see the actual error stacktrace to figure out what's wrong. As to check what is locking the directory see unlocker.

Use mvn clean -Dmaven.clean.failOnError=false
to resolve this problem.

I am using Spring(Eclipse) to do a maven clean and already had a command line and cygwin open with target as the current directory. I closed cygwin and other console, did a maven clean on the pom.xml in Spring and it worked!
This link helped me out: http://maven.apache.org/plugins/maven-clean-plugin/faq.html

Related

Life cycle error in jenkins

After building my project in Jenkins, I ran into this error:
<===[JENKINS REMOTING CAPACITY]===>channel started
log4j:WARN No appenders could be found for logger
(org.apache.commons.beanutils.converters.BooleanConverter).
log4j:WARN Please initialize the log4j system properly.
Executing Maven: -B -f /var/lib/jenkins/jobs/A/workspace/pom.xml mvn clean
integration-test -Dlog4j.configuration=file./src/test/
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Invalid task 'mvn': you must specify a valid lifecycle phase, or a goal in the
format plugin:goal or pluginGroupId:pluginArtifactId:pluginVersion:goal
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
This is a little weird, since I was to build the project using maven via the command line. Why is my repository, via Jenkins not able to build the project, while I could on my local machine?
The answer is right in your log file
Executing Maven: -B -f /var/lib/jenkins/jobs/A/workspace/pom.xml mvn clean.
You have miss-configured the job, so it's now trying to execute an in-existent mvn task. If your project type is "maven", just type clean compile package etc in the input box. Otherwise please post a screenshot of your job's config so we can better understand what's going on
It looks like you are specifying mvn as a goal to maven. The Goals and options line in jenkins project config should not include mvn: clean integration-test for example.
I personally solved such an error doing a mere
rm -rf /var/lib/jenkins/jobs/A/workspace
which does equivalently reset everything clean when such a 'sandgrain' has gotten inside somehow and corrupted the build.

Mahout in Action examples doesn't work

I'm new in Mahout and I have a week trying to run the book examples. The book recommends to use an IDE for this but Eclipse and Netbeans are having some troubles with the maven and slf4j installation thats why I tryed to use the ubuntu 13.04 terminal. Can anyone could help me with this?? I downloaded the source code from the 0.7 branch on the git repository and trying to make it work doing the following steps:
Install maven with the
$sudo apt-get install maven (it installs the 3.0.4 version)
Extract the zip with the files and run the command $ mvn package (I think I have to modify the pom file but I'm not sure)
When finishes the package command, it shows me a build success message
Then I want to run one of the examples with the $ mvn exec:java -Dexec.mainClass="mia.recommender.ch02.IREvaluatorIntro" -Dexec.args="src" command but when i run it it shows me this:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.424s
[INFO] Finished at: Wed Jul 10 10:43:36 PDT 2013
[INFO] Final Memory: 8M/19M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java (default-cli) on project mia: An exception occured while executing the Java class. null: InvocationTargetException: intro.csv -> [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
Thanks in advance!
i think you have to build mahout jar files first! they created in a target folder in each of the mahout main folder such as math,examples and ...
then after extract zip file run this command to build jar files
sudo mvn -DskipTests install -e
after that you can run your example :)

OpenTripPlanner getting started tutorial error

I'm trying to install OpenTripPlanner following the official tutorial.
I've correctly cloned the git repository, then I import the project in Eclipse but it is unable to build all the packages. One of the error is "The import org.geotools cannot be resolved"
So I've tryed with the Maven tutorial but when I run "mvn install integration-test -DskipTests -P interactive" I get:
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).
Project ID: org.geotools:library:pom:null
Reason: Cannot find parent: org.geotools:modules for project: org.geotools:library:pom:null for project org.geotools:library:pom:null
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7 seconds
[INFO] Finished at: Mon May 20 15:53:31 CEST 2013
[INFO] Final Memory: 44M/473M
[INFO] ------------------------------------------------------------------------
Googling, I've not found anything similar, so, what's the matter?
seems that the geotools.version (and other) properties are not set in the main pom (https://github.com/openplans/OpenTripPlanner/blob/master/pom.xml).
Probably the hudson builder is using variables coming from the settings.xml.
Try defining it manually:
mvn install integration-test -DskipTests -Pinteractive -Dgeotools.version=9.1 -Dspring.version=3.1.1.RELEASE

Error when trying to 'mvn clean install' Gerrit's replication plugin

This is probably a newbie question, but I'm new to Maven.
I'm trying to build Gerrit's replication plugin, "since the master branch (and thus Gerrit 2.5) no longer supports replication out of the box."
So I did clone https://gerrit.googlesource.com/plugins/replication and executed mvn clean install inside the new directory. The error message is:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building replication 1.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for com.google.gerrit:gerrit-plugin-api:jar:2.6-SNAPSHOT is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.840s
[INFO] Finished at: Thu Apr 25 17:30:10 BRT 2013
[INFO] Final Memory: 6M/105M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project replication: Could not resolve dependencies for project com.googlesource.gerrit.plugins.replication:replication:jar:1.1-SNAPSHOT: Failure to find com.google.gerrit:gerrit-plugin-api:jar:2.6-SNAPSHOT in https://gerrit-api.commondatastorage.googleapis.com/release/ was cached in the local repository, resolution will not be
reattempted until the update interval of gerrit-api-repository has elapsed or updates are forced -> [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/DependencyResolutionException
It looks like this URL isn't valid: https://gerrit-api.commondatastorage.googleapis.com/release/ -- but like I said, I'm new to Maven so I'm not sure how to proceed. I did some research, but I don't know what I'm looking for.
Any pointer would be highly appreciated. Thanks in advance.
A couple of things -
You are missing the gerrit-plugin-api.jar. This currently isn't provided upstream, so you must build it yourself. I believe running mvn install from a Gerrit repository will package and add this jar to your system.
You don't want to run install, you just want to run package on the plugin. mvn package will put the .jar in the target/ folder, which you then copy to your plugins folder inside your Gerrit installation.
Good luck!
Like Brad mentioned, I am missing the gerrit-plugin-api.jar. Unfortunately, I was not able to build it, since the Gerrit repos seem to be facing issues lately, as mentioned in other threads (this one, for instance - from two days ago).
Anyway, below are my additional steps based on Brad's answer (hopefully this may help others):
git clone https://gerrit.googlesource.com/gerrit
cd gerrit/gerrit-plugin-api/
mvn clean install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Gerrit Code Review - Plugin API 2.7-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for com.google.gerrit:gerrit-sshd:jar:2.7-SNAPSHOT is missing, no dependency information available
[WARNING] The POM for com.google.gerrit:gerrit-httpd:jar:2.7-SNAPSHOT is missing, no dependency information available
[WARNING] The POM for com.google.gerrit:gerrit-pgm:jar:2.7-SNAPSHOT is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.342s
[INFO] Finished at: Fri Apr 26 10:52:54 BRT 2013
[INFO] Final Memory: 5M/105M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project gerrit-plugin-api: Could not resolve dependencies for project com.google.gerrit:gerrit-plugin-api:jar:2.7-SNAPSHOT: The following artifacts could not be resolved: com.google.gerrit:gerrit-sshd:jar:2.7-SNAPSHOT, com.google.gerrit:gerrit-httpd:jar:2.7-SNAPSHOT, com.google.gerrit:gerrit-pgm:jar:2.7-SNAPSHOT: Failure to find com.google.gerrit:gerrit-sshd:jar:2.7-SNAPSHOT in https://gerrit-maven.commondatastorage.googleapis.com was cached in the local repository, resolution will not be reattempted until the update interval of gerrit-maven has elapsed or updates are forced -> [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/DependencyResolutionException
EDIT
These are the steps that worked for me, in case someone else faces the same issue.
git clone https://gerrit.googlesource.com/gerrit
Check available 'versions'
git branch -r
git checkout -b 2.5 origin/stable-2.5
The steps didn't work on the master branch in my environment, and I'm using 2.5...
So yeah, 2.5.
cd gerrit
mvn clean install
This will rebuild the entire universe, go grab a cup of coffee. :)
.. when done
cd gerrit-plugin-api/
mvn package
This also takes some time...
If everything goes fine, you can copy the jar at the target folder, like:
cp target/<large-name>.jar ~/replication.jar
Finally install it (from ~):
ssh -p 29418 localhost gerrit plugin install -n name \ - <replication.jar
Details on how to install Gerrit plugins are here.
The thing is, now I'm getting another error, something like:
"A binding to (something) was already configured at (something)."
But that's another story / thread / post...
Thanks and good luck!
Do a mvn -P all clean install on the toplevel, not inside gerrit-plugin-api.
The fastest way to fix is is to change the pom.xml and use a version that is not a snapshot. I was trying to build the delete-project for the stable-2.6 branch and was facing the same issue. All that needs to be done is to change the Gerrit-ApiVersion:
<Gerrit-ApiType>plugin</Gerrit-ApiType>
- <Gerrit-ApiVersion>2.6-SNAPSHOT</Gerrit-ApiVersion>
+ <Gerrit-ApiVersion>2.6-rc2</Gerrit-ApiVersion>
</properties>
<name>Delete Project Gerrit Plugin</name>
Building off of #Conaaando's answer, I performed these exact steps and successfully am using the plugin. Steps courtesy of http://asheepapart.blogspot.com/2013/12/how-to-build-gerrit-replication-plugin.html
git clone --recursive https://gerrit.googlesource.com/gerrit
You need the --recursive here because the plugins are actually git submodules and won't otherwise be cloned along with your repo.
If you've already cloned, you can run git submodule init; git submodule update
cd gerrit
git checkout -b stable-2.7 origin/stable-2.7
mvn install -DskipTests=true -Dmaven.javadoc.skip=true
It's not necessary to skip the tests or generating Java Doc, but it will greatly improve your compile time and decrease the amount of memory maven uses
cd gerrit-plugin-api
mvn package -Dmaven.javadoc.skip=true
This creates the jar that will be necessary for the replication plugin to get built
cd plugins/replication
mvn package -Dmaven.javadoc.skip=true
At this point, you have compiled and packaged the replication jar! All you need to do now is register it with your Gerrit server. For simplicity, I'll pretend your gerrit server is running at gerrit.example.com. These steps copy the replication jar to your review server and then instruct the review server to install the plugin from that copied location.
scp target/replication-2.7.jar gerrit.example.com:/tmp/
ssh -p 29418 gerrit.example.com gerrit plugin install -n replication /tmp/replication-2.7.jar

maven deploy-file failed with 503: cannot find maven-metadata.xml

I am using Maven to integrate our project with others, maybe in a unpopular way and encountered issue.
We have a project that used to compile with Ant. Ant script is big and awesome, so when we are using Maven for integration, it is decided to keep compiling with Ant.
Now let's say Ant compile output is res-1.0-SNAPSHOT.tar.gz. (any filename can be possible but it IS tar.gz) And I am deploying the file to a nexus-hosted snapshot repository called "snapshots".
I tried to deploy with this command:
mvn deploy:deploy-file \
-DgroupId="com.my-company" \
-DartifactId="res" \
-Dversion="1.0-SNAPSHOT" \
-Dpackaging="tar.gz" \
-Dfile="res-1.0-SNAPSHOT.tar.gz" \
-Durl="http://our-nexus-ip/nexus/content/repositories/snapshots" \
-DrepositoryId="snapshots"
I have a simple settings.xml in ~/.m2 with proxy and server settings. However server settings is not being used in current progress yet, wrong passwords don't get errors.
The output is like this:
[[root#cnbi maven]# ./run.sh
+ mvn deploy:deploy-file -DgroupId=com.my-company -DartifactId=res -Dversion=1.0-SNAPSHOT -Dpackaging=tar.gz -Dfile=res-1.0-SNAPSHOT.tar.gz -Durl=http://135.252.234.142:8081/nexus/content/repositories/snapshots -DrepositoryId=snapshots
Warning: JAVA_HOME environment variable is not set.
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'deploy'.
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO] task-segment: [deploy:deploy-file] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] [deploy:deploy-file]
[INFO] Retrieving previous build number from snapshots
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error retrieving previous build number for artifact 'com.my-company:res:tar.gz': repository metadata for: 'snapshot com.my-company:res:1.0-SNAPSHOT' could not be retrieved from repository: snapshots due to an error: Error transferring file
Server returned HTTP response code: 503 for URL: http://135.252.234.142:8081/nexus/content/repositories/snapshots/com/my-company/res/1.0-SNAPSHOT/maven-metadata.xml
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 51 seconds
[INFO] Finished at: Tue Jun 12 08:44:13 CST 2012
[INFO] Final Memory: 7M/209M
[INFO] ------------------------------------------------------------------------
You see, it fails to find maven-metadata.xml. It is for certain, the file and its folder "com/my-company" do not exist at all in the repository.
Besides any misuse of Maven you may find, my questions are:
1) am I using Maven in the right way? (deploying tar.gz, using deploy:deploy-file...)
2) are there incorrect parameters?
3) what is maven-metadata.xml for? It is not there but Maven insists to find it -- I guess it is generated, am I missing some steps?
The solution might be stupid, I am really not familiar with Maven. Unfortunately it has to be done... Please, help me out of this.
Maven version is 2.0.11. Let me know if you want to know more.
I had the same problem and there was a bug in our nexus.
Using maven3 (with same settings.xml, pom.xml and .m2 repo) solved our problem and its easier than upgrading nexus.
You can check this bug also.
If you're still stuck with using Ant, I would recommend you at least consider adding Ivy to the picture, as your dependency manager. If I recall correctly, it was able to update maven-metadata.xml files in the repository.
Have a look at this example.

Resources