Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven deploys to snapshot instead of release

Tags:

I'm trying to release a project using maven but instead of releasing to the Releases repository it puts it in our Snapshots repo.

My pom looks like:

<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/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.example.my.profiler</groupId> <artifactId>profilerlib</artifactId> <name>Profiler Lib</name> <version>1.0.2-SNAPSHOT</version> <description>Profiler Library</description> <scm>     <connection>scm:svn:https://svn.example.com/my-project/profilerlib/trunk     </connection>     <developerConnection>scm:svn:https://svn.example.com/my-project/profilerlib/trunk     </developerConnection> </scm> <distributionManagement>     <!-- Publish the versioned releases here -->     <repository>         <id>nexus</id>         <name>nexus</name>         <url>http://repo.example.com:8081/nexus/content/repositories/releases         </url>     </repository>     <!-- Publish the versioned releases here -->     <snapshotRepository>         <id>nexus</id>         <name>nexus</name>         <url>http://repo.example.com:8081/nexus/content/repositories/snapshots         </url>     </snapshotRepository> </distributionManagement> <!-- download artifacts from this repo --> <repositories>     <repository>         <id>nexus</id>         <name>EXAMPLE Public Repository</name>         <url>http://repo.example.com:8081/nexus/content/groups/public</url>         <releases>             <enabled>true</enabled>         </releases>         <snapshots>             <enabled>true</enabled>         </snapshots>     </repository> </repositories> <dependencies>     ... </dependencies> <build>     <finalName>${project.artifactId}</finalName>     <plugins>         <plugin>             <artifactId>maven-release-plugin</artifactId>             <configuration>                 <tagBase>https://svn.example.com/my-project/profilerlib/tags                 </tagBase>             </configuration>         </plugin>         <plugin>             <artifactId>maven-compiler-plugin</artifactId>             <configuration>                 <source>1.6</source>                 <target>1.6</target>             </configuration>         </plugin>     </plugins> </build> <properties>     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>     <powermock.version>1.4.6</powermock.version> </properties> </project> 
like image 598
Leon Roy Avatar asked Sep 07 '11 10:09

Leon Roy


People also ask

What is the difference between snapshot and release in Maven?

A Maven snapshot is a special version of a Maven package that refers to the latest production branch code. It is a development version that precedes the final release version. You can identify a snapshot version of a Maven package by the suffix SNAPSHOT that is appended to the package version.

Why is it best practice not to release snapshot Maven artifacts to production?

Rule #3 Never release using the Time-Stamped snapshot The release plugin will still fail if you do this because it correctly understands you have SNAPSHOT dependencies. The plugin has a flag to allow bypass this check and people unfortunately use it far too often.

What is the difference between a snapshot and a release?

By definition, snapshots are mutable, releases are immutable. This is why Nexus makes you store them separately because usually you don't care if you lose snapshots, but you will care if you lose releases. It makes snapshot cleanup much easier to deal with that way.

How do I remove snapshot from pom?

Delete SNAPSHOT Task. You can use the Delete SNAPSHOT task to delete SNAPSHOT components from a Maven repository based on their timestamps. The task only removes timestamped versions within "-SNAPSHOT" version folders, which typically contain multiple SNAPSHOTs for the same SNAPSHOT version.


1 Answers

In case anyone else is having this problem and find the existing answers do not solve their issues:

There have been a handful of bugs which mean that release:prepare does not commit to the git repository before creating the release tag. This means that the version number in the pom files that the release:perform finds contains -SNAPSHOT and the deployer will try to release to the snapshot repository.

Here is the most recent defect responsible for this behavior: MRELEASE-875 (affects 2.5, fixed in 2.5.1)

like image 106
Ken Avatar answered Nov 04 '22 01:11

Ken