Cannot execute mvn release:prepare - maven

I have a simple project with just one class file and one junit test file. Trying and testing a release using mvn release:prepare but fetting following exception while executing the following command. I have SVN server installed but on a different Windows machine. I do have the SVN client (TortoiseSVN) installed on the current machine.
Can anybody please guide as to what am I missing ?
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.0:prepare (default-cli) on project maven-svn-release: Unable to check for local modifications
[ERROR] Provider message:
[ERROR] The svn command failed.
[ERROR] Command output:
[ERROR] 'svn' is not recognized as an internal or external command,
[ERROR] operable program or batch file.
[ERROR] -> [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.
pom.xml configuration:
<scm>
<connection>scm:svn:https://gsi-541243.gsiccorp.net/svn/maven-rnd/maven-svn-release/trunk</connection>
<developerConnection>scm:svn:https://gsi-541243.gsiccorp.net/svn/maven-rnd/maven-svn-release/trunk</developerConnection>
<url>https://gsi-541243.gsiccorp.net/svn/maven-rnd/maven-svn-release/trunk</url>
</scm>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<configuration>
<tagBase>https://gsi-541243.gsiccorp.net/svn/maven-rnd/maven-svn-release/tags</tagBase>
</configuration>
</plugin>
</plugins>
</build>

Related

mvn clean install, Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile

I want to connect my maven project to Jenkins, but I get the following error:
https://imgur.com/tnRwSW1
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project AnimalShelter: Fatal error compiling: invalid target release: 12 -> [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
So I changed the source and target to 11 or 10 but this also does not work. The same thing happens when I try to execute the following command : "mvn clean install". I think something is wrong in my settings but I don't know what.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>12</source>
<target>12</target>
</configuration>
</plugin>

Error on releasing with maven-release-plugin on Jenkins

I got a Jenkins job that builds a java maven project.
Now I tried a release build via Jenkins (Perform Maven Release) but it fails.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5:prepare (default-cli) on project MyProject: Unable to check for local modifications
[ERROR] Provider message:
[ERROR] The svn command failed.
[ERROR] Command output:
[ERROR] svn: E155036: Please see the 'svn upgrade' command
[ERROR] svn: E155036: The working copy at '/var/lib/hudson/workspace/JobName/MyProject'
[ERROR] is too old (format 8) to work with client version '1.9.5 (r1770682)' (expects format 31). You need to upgrade the working copy first.
[ERROR] -> [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/MojoFailureException
The plugin configuration in the pom is:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5</version>
<configuration>
<tagBase>http://svn.example.org/myproject/tags/_modules</tagBase>
</configuration>
</plugin>
I'm not sure now but in the past it was working.
What I don't understand is the maven-release-plugin not using the local svn client?
From the error message it seems so (svn upgrade) and if so why is it failing on the release but not the checkout?
Is there a way to come around this without changing jenkins?
What I tried is adding following as I understand that that should force the plugin to use this provider which should be compatible:
<dependencies>
<dependency>
<groupId>com.google.code.maven-scm-provider-svnjava</groupId>
<artifactId>maven-scm-provider-svnjava</artifactId>
<version>2.0.6</version>
<scope>compile</scope>
</dependency>
</dependencies>
But I got following error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5:prepare (default-cli) on project MyApp: Unable to commit files
[ERROR] Provider message:
[ERROR] SVN commit failed.
[ERROR] Command output:
[ERROR] svn: E170001: Commit failed (details follow):
[ERROR] svn: E170001: MKACTIVITY of '/products/MyAppsAgregator/!svn/act/24d46a73-6601-0010-864c-7b76c8107c40': 403 Forbidden (http://svn.example.org)
[ERROR] -> [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.

Sonar maven plugin without settings.xml

I need change the sonar url without change settings.xml, so i have the following:
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.4.1.1168</version>
<configuration>
<sonar.host.url>http://sonar.viavarejo.com.br</sonar.host.url>
</configuration>
</plugin>
My sonar.host.url didn't work, just ignore, see the error:
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.4.1.1168:sonar (default-cli) on project myproject: Unable to execute SonarQube: Fail to get bootstrap index from server: Failed to connect to localhost/0:0:0:0:0:0:0:1:9000: Connection refused (Connection refused) -> [Help 1]
Important: I can't change the settings.xml file.
You can set the URL as a property:
<properties>
<sonar.host.url>http://<server>:<port>/</sonar.host.url>
</properties>
or directly in the command line usind
mvn sonar:sonar -Dsonar.host.url=http://<server>:<port>/

Error Maven with mvn test

I am using this tool for first time, and I can't build a project correctly.
when i try the life cycle commands it builds succesfully with clean validate and compile. but when i try mvn test, it gives me this error :
[INFO] ---------------------------------------------------------------------
---
[INFO] BUILD FAILURE
[INFO] ---------------------------------------------------------------------
---
[INFO] Total time: 4.410 s
[INFO] Finished at: 2018-05-25T11:33:07+02:00
[INFO] ---------------------------------------------------------------------
---
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-
plugin:2.20.1:test (default-test) on project gdp: Execution default-test of
goal org.apache.maven.plugins:maven-surefire-plugin:2.20.1:test failed.
:NullPointerException
-> [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/PluginExecutionException
mvn -v 3.5.3
i am using a proxy and i did configure settings.xml file
Please help.
thank you
Change the version of maven-surefire-plugin via:
<project>
.
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.21.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

How do I run an individual test in Maven?

We're using Maven 3.0.3 and are using JUnit 4.8.1 ...
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
We have this test file ...
./src/test/java/com/myco/clearing/common/xml/TextNodeTest.java
How can I run this individual test? When I try
mvn -Dtest=TextNodeTest test
I get an error saying no tests were run. I get the same error if I specify the entire package name to my test. ...
mvn clean -Dtest=com.myco.clearing.common.xml.TextNodeTest test
which produces the error message ...
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project myco-productplus-web: No tests were executed!
(Set -DfailIfNoTests=false to ignore this error.) -> [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/MojoFailureException
Here is the surefire configuration I'm using
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<configuration>
<skip>false</skip>
<additionalClasspathElements>
<additionalClasspathElement>${project.build.sourceDirectory}</additionalClasspathElement>
<additionalClasspathElement>${project.build.testSourceDirectory}</additionalClasspathElement>
</additionalClasspathElements>
<useManifestOnlyJar>false</useManifestOnlyJar>
<forkMode>always</forkMode>
<systemProperties>
<property>
<name>gwt.args</name>
<value>-out "${webappDirectory}"</value>
</property>
</systemProperties>
<systemPropertyVariables>
<tomcat.port>${tomcat.servlet.port}</tomcat.port>
<project.artifactId>${project.artifactId}</project.artifactId>
</systemPropertyVariables>
</configuration>
</plugin>
The way to run a single test (method) in surefire is to do:
mvn test -Dtest=uk.co.farwell.AppTest#testSlow
Note the # instead of the space between the class name and the method name.
However, as #Andrew says, there is a bug in 2.12 (SUREFIRE-827: Surefire 2.12 cannot run a single test, regression from 2.11), but it works in 2.11.
The above bug is still open (as of 24.02.2012), but actually works for me using 2.13-SNAPSHOT.
EDIT: This is now marked as fixed in 2.12.1.
Looks like it's a bug in 2.12 version - SUREFIRE-827. Try downgrading to 2.11.
Like the others say, it's a bug in Surefire and it's fixed since version 2.11.1.

Resources