Unable to deploy release package to nexus using maven release:perform - maven

I am getting 400 errors when I try to execute maven release: perform.
[INFO] [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy) on project my-project: Failed to deploy artifacts: Cou
ld not transfer artifact com.acca.project:project:pom:1.0.0-RELEASE from/to acca-nexus (https://nexus.io/repository/project/): Failed to transfer file https://nexus.io/repository/project/myproject/myproject/1.0.0-RELEASE/myproject-1.0.0-RELEASE.pom with status code 400 -> [Help 1]
Following things I have tried
1) I verified, credentials are correct
2) URL for nexus repo is correct
3) I am maintaining the proper 1.0.0-SNAPSHOT name
4) there is no package with the same version in nexus as well
5) Not a network issue as well, I can do maven deploy properly.
Release plugin -config looks like below
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<scmCommentPrefix>[maven-scm] :</scmCommentPrefix>
<goals>deploy</goals>
<releaseProfiles>release</releaseProfiles>
</configuration>
</plugin>
I want to deploy the package when I do maven release: perform, but I am unable to debug beyond this. can someone please tell me how to debug this. Pointing out the issue will also helpful

I fixed the above issue.
The solution was in the nexus repository configuration.
I updated the configuration to "allow redeploy" and it started working.
Thank you

Related

Failed to execute goal Spring Framework Maven

I have a project_1 which is using JAR of project_2.
project_2 is using the spring framework.
project_2 builds successfully but project_1 fails with below error using 'mvn clean install' command:
Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.5.4:repackage on project : xxx
: Execution repackage of goal org.springframework.boot:spring-boot-maven-plugin:2.5.4:repackage failed:
Plugin org.springframework.boot:spring:boot-maven-plugin:2.5.4 or one of its dependencies could not be resolved.
Failed to read artifact descriptor for org.springframework.boot:spring-boot-buildpack-platform:jar2.5.4 Could not transfer artifact org.springframework.boot:spring-boot-buildpack-platform:pom:2.5.4 from artifact repository: Failed to transfer file http://repo.xxx.com/repo/org/springframework/boot/spring-boot-builpack-platform-2.5.4 with status code 308
I tried below command on project_1
" mvn clean install -U"
but it does not help.
One more thing I noticed:
Project_1 has following lines
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
and If I comment above plugin everything works perfectly.
But do not know if commenting it is a good idea or not.

mvn dependency:go-offline doesn't download the requirements for maven-surefire-plugin

I'm trying to build an open source project in docker and want to save time spent on builds, so I tried using mvn dependency:go-offline, which does download maven-surefire-plugin itself.
Running mvn -o clean package afterwards results in
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M4:test (default-test) on project oxalis-api: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M4:test failed: Plugin org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M4 or one of its dependencies could not be resolved: Cannot access apache.snapshots (http://repository.apache.org/snapshots/) in offline mode and the artifact org.codehaus.plexus:plexus-utils:jar:1.1 has not been downloaded from it before. -> [Help 1]
(I've enabled the snapshots repository because maven-dependency-plugin has serious issues with multi module projects otherwise)
The POM includes
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M4</version>
<configuration>
<useSystemClassLoader>false</useSystemClassLoader>
</configuration>
</plugin>
</plugins>
</pluginManagement>
and as described above, that plugin itself does exist in my repository after go-offline.
It seems that your maven local repository uses the legacy structure, details here. So the goal dependency:go-offline prepares the repository in the legacy mode, then the actual goal for building package cannot find the dependency because it uses the default mode.
So for your specific scenario you can use the following command to download the dependencies and the plugins in batch mode:
mvn dependency:resolve-plugins dependency:go-offline -B
And you can use the following for the build, with the offline, batch and legacy local repository options:
mvn package -o -llr -B
Hint: if you need additional plugin or dependencies in your build that are not explicitly defined in the main pom, like the ones you add during the build (i.e. clover, allure, pact, etc) you can pre download using the following command:
mvn dependency:get -Dartifact=org.openclover:clover-maven-plugin:4.4.1 -B
Hint 2: If you have issues when offline and the dependencies are not taken maybe it is because you have different maven settings when you download the dependencies and when you build your project. You can consider to delete the maven-metadata*.xml and _*.repositories inside the local repository, you can use this:
find ~/.m2/repository -name 'maven-metadata*.xml' | xargs -n1 rm
find ~/.m2/repository -name '_*.repositories' | xargs -n1 rm
I too was facing the same issue, changed the version from 3.0.0-M4 to 2.12 and it worked for me. I am still trying to figure out why its not working with 3.0.0-M4.

sonar.host.url not working with sonar-maven-plugin:2.7

After upgrading my POMs to sonar-maven-plugin:2.7 the configuration does not work any more. My configuration in settings.xml is like this:
<profile>
<id>sonar</id>
<properties>
<sonar.jdbc.url>jdbc:postgresql://my.server:5432/sonar</sonar.jdbc.url>
<sonar.jdbc.driverClassName>org.postgresql.Driver</sonar.jdbc.driverClassName>
<sonar.jdbc.username>xxxxx</sonar.jdbc.username>
<sonar.jdbc.password>yyyyy</sonar.jdbc.password>
<sonar.host.url>http://my.server</sonar.host.url>
</properties>
</profile>
The build is started with -Psonar of course. With version 2.6 everything is fine, with 2.7 I get
[INFO] --- sonar-maven-plugin:2.7:sonar (default-cli) # myproject ---
[INFO] User cache: C:\Users\me\.sonar\cache
[ERROR] SonarQube server 'http://localhost:9000' can not be reached
...
[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.7:sonar (default-cli) on project myproject: Fail to download libraries from server: java.net.ConnectException: Connection refused: connect -> [Help 1]
Starting the build with -X gives me the correct mojo configuration in both cases, especially the url is still correct in the log
[DEBUG] (f) sonarHostURL = http://my.server
Even deleting the mentioned caching directory does not help.
What can I do except of managing the plugin to version 2.6?
We are investigating the issue. Ticket was created: https://jira.sonarsource.com/browse/MSONAR-129
In the meantime you could either lock the SQ plugin to version 2.6 or pass all properties using command line.
Workaround: Adding -Dsonar.host.url=http://my.server:9000 to mvn command works for me
Better than disabling the plugin, you may fix the plugin version to 2.6, which works fine, taking into account sonar.host.url.
For instance, with Maven in my case:
<pluginManagement>
</plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>2.6</version>
<!-- sonar.host.url not working with version 2.7 -->
</plugin>
</plugins>
</pluginManagement>
I use the full qualified goal in the CI server to run the sonar goals:
mvn org.codehaus.mojo:sonar-maven-plugin:2.6:sonar
Since we use the templates in TeamCity this is not so much of a disaster. Still we were a bit surprised by the event.
Both
mvn -Dsonar.host.url=http://localhost:9000 org.codehaus.mojo:sonar-maven-plugin:2.6:sonar
and
mvn -Dsonar.host.url=http://localhost:9000 org.sonarsource.scanner.maven:sonar-maven-plugin:3.2:sonar
worked for me :
Instead of reconfiguring all jobs I disabled sonar for all jobs until this gets fixed. I added
<sonar.skip>true</sonar.skip>
to the sonar profile in settings.xml.

"Artifact is not fully assembled" error with maven-invoker-plugin in parallel build

According to the docs, maven-invoker-plugin is "thread-safe and supports parallel builds." However, when I build by multi-module project with -T 1C, I get an error like the following:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-invoker-plugin:1.10:install (integration-test) on project my-archetype: Failed to install project dependencies: MavenProject: com.tavianator:my-archetype:1.6-SNAPSHOT # /home/tavianator/code/Project/my-archetype/pom.xml: Failed to install project artifacts: MavenProject: com.tavianator:my-project:1.6-SNAPSHOT # /home/tavianator/code/Project/my-project/pom.xml: Failed to install artifact: com.tavianator:my-project:jar:1.6-SNAPSHOT: Artifact is not fully assembled: /home/tavianator/code/Project/my-project/target/classes -> [Help 1]
The project layout is like this:
Root
|--Project 1
|--Project 2
|--Archetype (depends on Project 1, scope=test)
The archetype integration tests use the maven-invoker-plugin to install the relevant dependencies (Root and Project 1) to a local repository, then runs the normal archetype integration tests. In parallel builds, Archetype and Project 2 run at the same time. When the maven-invoker-plugin runs, it tries to install Project 2 to the local repo, but Project 2 isn't built yet, hence the error.
But since Project 2 isn't even needed for the tests, I should be able to work around the problem by explicitly installing only the needed dependencies. I don't see how to get the invoker plugin to do that, but is there another plugin I can use?
I reported the maven-invoker-plugin bug here. I have an example project that demonstrates the error here.
I ran into this problem as well, in addition to other problems with the setup suggested in Fast Build Configuration (such as some artifacts being downloaded by the invoked project in every run), and implemented my own solution. Instead of the invoker:install goal, you would use the following:
<plugin>
<groupId>com.github.veithen.invoker</groupId>
<artifactId>resolver-proxy-maven-plugin</artifactId>
<version>0.1</version>
<executions>
<execution>
<goals>
<goal>start</goal>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
Note that there is no need to explicitly configure settings.xml or a dedicated local repository. This is done automatically.
Currently the code in the plugin is experimental. If it turns out to be robust enough, I will submit a patch integrating it into maven-invoker-plugin. More information here.

Sonar 4.1.1 maven plugin can't be resolved

I'm using SonarQube 4.1.1 and have the following configuration in my pom.xml file:
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>4.1.1</version>
</plugin>
</plugins>
</pluginManagement>
When I try to run sonar from the command line using the maven plugin I get:
[ERROR] Plugin org.codehaus.mojo:sonar-maven-plugin:4.1.1 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.codehaus.mojo:sonar-maven-plugin:jar:4.1.1: Failure to find org.codehaus.mojo:sonar-maven-plugin:pom:4.1.1 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
Anyone know how to fix this issue? Do I need to make some configuration changes?
In fact this configuration is not needed. Have you try to run an analysis without it? You should give a try if you haven't.
But if you really need to force the version of the sonar-maven-plugin, you should set it to 2.1 on Maven 3.
See http://docs.codehaus.org/display/SONAR/Analyzing+with+Maven for more details.
Regards
Try this:
mvn clean sonar:sonar -U
The -U flag means force update of dependencies.

Resources