IT to ensure plugin fails on snapshots
diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckDependencySnapshotsPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckDependencySnapshotsPhase.java
index 37603d1..b19b446 100644
--- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckDependencySnapshotsPhase.java
+++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckDependencySnapshotsPhase.java
@@ -123,7 +123,7 @@
}
}
- Set<Artifact> dependencyArtifacts = project.getArtifacts();
+ Set<Artifact> dependencyArtifacts = project.getDependencyArtifacts();
usedSnapshotDependencies.addAll( checkDependencies( releaseDescriptor, artifactMap, dependencyArtifacts ) );
//@todo check dependencyManagement
diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/AbstractReleaseTestCase.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/AbstractReleaseTestCase.java
index 2ddee24..989fad2 100644
--- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/AbstractReleaseTestCase.java
+++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/AbstractReleaseTestCase.java
@@ -1,6 +1,5 @@
package org.apache.maven.shared.release.phase;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -42,11 +41,13 @@
import org.apache.commons.lang.SystemUtils;
import org.apache.maven.artifact.ArtifactUtils;
+import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
import org.apache.maven.artifact.repository.MavenArtifactRepository;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
+import org.apache.maven.lifecycle.LifecycleExecutionException;
import org.apache.maven.model.Profile;
import org.apache.maven.model.Repository;
import org.apache.maven.project.DefaultProjectBuildingRequest;
@@ -54,6 +55,7 @@
import org.apache.maven.project.ProjectBuilder;
import org.apache.maven.project.ProjectBuildingRequest;
import org.apache.maven.project.ProjectBuildingRequest.RepositoryMerging;
+import org.apache.maven.project.artifact.InvalidDependencyVersionException;
import org.apache.maven.project.ProjectBuildingResult;
import org.apache.maven.project.ProjectSorter;
import org.apache.maven.repository.internal.MavenRepositorySystemSession;
@@ -82,6 +84,8 @@
protected ProjectBuilder projectBuilder;
protected ArtifactRepository localRepository;
+
+ private ArtifactFactory artifactFactory;
protected ReleasePhase phase;
@@ -92,6 +96,7 @@
super.setUp();
projectBuilder = lookup( ProjectBuilder.class );
+ artifactFactory = lookup( ArtifactFactory.class );
ArtifactRepositoryLayout layout = lookup( ArtifactRepositoryLayout.class, "default" );
String localRepoPath = getTestFile( "target/local-repository" ).getAbsolutePath().replace( '\\', '/' );
@@ -207,7 +212,22 @@
List<MavenProject> resolvedProjects = new ArrayList<>( reactorProjects.size() );
for ( MavenProject project : reactorProjects )
{
- resolvedProjects.add( projectBuilder.build( project.getFile(), buildingRequest ).getProject() );
+ MavenProject resolvedProject = projectBuilder.build( project.getFile(), buildingRequest ).getProject();
+
+ // from LifecycleDependencyResolver
+ if ( project.getDependencyArtifacts() == null )
+ {
+ try
+ {
+ resolvedProject.setDependencyArtifacts( resolvedProject.createArtifacts( artifactFactory, null, null ) );
+ }
+ catch ( InvalidDependencyVersionException e )
+ {
+ throw new LifecycleExecutionException( e );
+ }
+ }
+
+ resolvedProjects.add( resolvedProject );
}
return resolvedProjects;
}
diff --git a/maven-release-plugin/pom.xml b/maven-release-plugin/pom.xml
index 72702bf..acc6f7c 100644
--- a/maven-release-plugin/pom.xml
+++ b/maven-release-plugin/pom.xml
@@ -198,7 +198,10 @@
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
<postBuildHookScript>verify</postBuildHookScript>
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
- <settingsFile>src/it/settings.xml</settingsFile>
+ <settingsFile>src/it/mrm/settings.xml</settingsFile>
+ <filterProperties>
+ <mrm.repository.url>${mrm.repository.url}</mrm.repository.url>
+ </filterProperties>
<debug>true</debug>
<ignoreFailures>${maven.it.failure.ignore}</ignoreFailures>
<setupIncludes>
@@ -223,6 +226,27 @@
</properties>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>mrm-maven-plugin</artifactId>
+ <version>1.2.0</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>start</goal>
+ <goal>stop</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <repositories>
+ <mockRepo>
+ <source>src/it/mrm/repository</source>
+ </mockRepo>
+ <proxyRepo/>
+ </repositories>
+ </configuration>
+ </plugin>
</plugins>
</build>
</profile>
diff --git a/maven-release-plugin/src/it/mrm/repository/extension-1.0-SNAPSHOT.pom b/maven-release-plugin/src/it/mrm/repository/extension-1.0-SNAPSHOT.pom
new file mode 100644
index 0000000..3c5f169
--- /dev/null
+++ b/maven-release-plugin/src/it/mrm/repository/extension-1.0-SNAPSHOT.pom
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>test</groupId>
+ <artifactId>extension</artifactId>
+ <version>1.0-SNAPSHOT</version>
+
+</project>
diff --git a/maven-release-plugin/src/it/settings.xml b/maven-release-plugin/src/it/mrm/settings.xml
similarity index 91%
rename from maven-release-plugin/src/it/settings.xml
rename to maven-release-plugin/src/it/mrm/settings.xml
index 1851c77..4b3caf1 100644
--- a/maven-release-plugin/src/it/settings.xml
+++ b/maven-release-plugin/src/it/mrm/settings.xml
@@ -20,6 +20,15 @@
<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">
+ <mirrors>
+ <mirror>
+ <id>mrm-maven-plugin</id>
+ <name>Mock Repository Manager</name>
+ <url>@mrm.repository.url@</url>
+ <mirrorOf>*</mirrorOf>
+ </mirror>
+ </mirrors>
+
<servers>
<server>
<id>it-server</id>
diff --git a/maven-release-plugin/src/it/projects/prepare/fail-on-snapshots/invoker.properties b/maven-release-plugin/src/it/projects/prepare/fail-on-snapshots/invoker.properties
new file mode 100644
index 0000000..c19c711
--- /dev/null
+++ b/maven-release-plugin/src/it/projects/prepare/fail-on-snapshots/invoker.properties
@@ -0,0 +1,18 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+invoker.buildResult = failure
\ No newline at end of file
diff --git a/maven-release-plugin/src/it/projects/prepare/fail-on-snapshots/pom.xml b/maven-release-plugin/src/it/projects/prepare/fail-on-snapshots/pom.xml
new file mode 100644
index 0000000..317f36a
--- /dev/null
+++ b/maven-release-plugin/src/it/projects/prepare/fail-on-snapshots/pom.xml
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+<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>org.apache.maven.plugins.release.its</groupId>
+ <artifactId>fail-on-snapshot</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <scm>
+ <connection>scm:dummy|nul</connection>
+ <developerConnection>scm:dummy|nul</developerConnection>
+ </scm>
+
+ <build>
+ <extensions>
+ <extension>
+ <groupId>test</groupId>
+ <artifactId>extension</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </extension>
+ </extensions>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-release-plugin</artifactId>
+ <version>@project.version@</version>
+ <configuration>
+ <arguments>-Dflag -Dfoo=bar</arguments>
+ <mavenExecutorId>invoker</mavenExecutorId>
+ <goals>validate</goals>
+ <preparationGoals>validate</preparationGoals>
+ <completionGoals>verify</completionGoals>
+ </configuration>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.its.release</groupId>
+ <artifactId>maven-scm-provider-dummy</artifactId>
+ <version>1.0</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ <plugin>
+ <groupId>test</groupId>
+ <artifactId>plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-install-plugin</artifactId>
+ <version>3.0.0</version>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>test</groupId>
+ <artifactId>dependency</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>test</groupId>
+ <artifactId>dependency.test</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>test</groupId>
+ <artifactId>report</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </plugin>
+ </plugins>
+ </reporting>
+</project>
diff --git a/maven-release-plugin/src/it/projects/prepare/fail-on-snapshots/verify.groovy b/maven-release-plugin/src/it/projects/prepare/fail-on-snapshots/verify.groovy
new file mode 100644
index 0000000..7bc9f5f
--- /dev/null
+++ b/maven-release-plugin/src/it/projects/prepare/fail-on-snapshots/verify.groovy
@@ -0,0 +1,32 @@
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+def buildLog = new File(basedir,'build.log')
+def nonReleased = buildLog.readLines()
+ .dropWhile{ !it.endsWith("Can't release project due to non released dependencies :") }
+ .drop(1)
+ .collect{ (it - '[ERROR]').trim() }
+ .takeWhile{ !it.startsWith("in project 'fail-on-snapshot'") } as Set
+
+assert nonReleased == ['test:dependency:jar:1.0-SNAPSHOT:compile',
+ 'test:dependency.test:jar:1.0-SNAPSHOT:test',
+ 'test:extension:jar:1.0-SNAPSHOT',
+ 'test:plugin:maven-plugin:1.0-SNAPSHOT:runtime',
+ 'test:report:maven-plugin:1.0-SNAPSHOT:runtime'] as Set
\ No newline at end of file
diff --git a/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java b/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java
index 196f727..11c0fd3 100644
--- a/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java
+++ b/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java
@@ -25,6 +25,7 @@
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.shared.release.ReleaseExecutionException;
import org.apache.maven.shared.release.ReleaseFailureException;
import org.apache.maven.shared.release.ReleasePrepareRequest;
@@ -44,7 +45,7 @@
* @version $Id$
* @todo [!] check how this works with version ranges
*/
-@Mojo( name = "prepare", aggregator = true )
+@Mojo( name = "prepare", aggregator = true, requiresDependencyCollection = ResolutionScope.TEST )
public class PrepareReleaseMojo
extends AbstractScmReleaseMojo
{