Skip to content

Commit

Permalink
check for SNAPSHOT dependencies in all projects in the build reactor (c…
Browse files Browse the repository at this point in the history
…loses #28)
  • Loading branch information
aleksandr-m committed Dec 25, 2016
1 parent ec2f46b commit 22e2cad
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
3 changes: 1 addition & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,8 @@
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<artifactId>maven-core</artifactId>
<version>3.3.9</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.List;

import org.apache.maven.artifact.ArtifactUtils;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Model;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
Expand Down Expand Up @@ -128,6 +129,9 @@ public abstract class AbstractGitFlowMojo extends AbstractMojo {
@Parameter(property = "gitExecutable")
private String gitExecutable;

/** Maven session. */
@Component
private MavenSession mavenSession;
/** Maven project. */
@Parameter(defaultValue = "${project}", readonly = true)
private MavenProject project;
Expand Down Expand Up @@ -214,14 +218,16 @@ protected void checkUncommittedChanges() throws MojoFailureException,
}
}

@SuppressWarnings("unchecked")
protected void checkSnapshotDependencies() throws MojoFailureException {
getLog().info("Checking for SNAPSHOT versions in dependencies.");
List<Dependency> list = project.getDependencies();
for (Dependency d : list) {
if (ArtifactUtils.isSnapshot(d.getVersion())) {
throw new MojoFailureException(
"There is some SNAPSHOT dependencies in the project. Change them or ignore with `allowSnapshots` property.");
List<MavenProject> projects = mavenSession.getProjects();
for (MavenProject project : projects) {
List<Dependency> dependencies = project.getDependencies();
for (Dependency d : dependencies) {
if (ArtifactUtils.isSnapshot(d.getVersion())) {
throw new MojoFailureException(
"There is some SNAPSHOT dependencies in the project. Change them or ignore with `allowSnapshots` property.");
}
}
}
}
Expand Down

0 comments on commit 22e2cad

Please sign in to comment.