Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@
<plugins>
<plugin>
<artifactId>maven-invoker-plugin</artifactId>
<version>3.2.0</version>
<version>3.2.2</version>
<configuration>
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
build.log
expected-pom.xml
invoker.properties
init.bsh
verify.bsh
26 changes: 26 additions & 0 deletions src/it/release-start-it-snapshot-dependency-fail/init.bsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import org.apache.commons.io.FileUtils;

try {
new File(basedir, "gitignorefile").renameTo(new File(basedir, ".gitignore"));

Process p = Runtime.getRuntime().exec("git --git-dir=" + basedir + "/.git --work-tree=" + basedir + " init");
p.waitFor();

Process p = Runtime.getRuntime().exec("git --git-dir=" + basedir + "/.git --work-tree=" + basedir + " config user.email '[email protected]'");
p.waitFor();
Process p = Runtime.getRuntime().exec("git --git-dir=" + basedir + "/.git --work-tree=" + basedir + " config user.name 'a'");
p.waitFor();

p = Runtime.getRuntime().exec("git --git-dir=" + basedir + "/.git --work-tree=" + basedir + " add .");
p.waitFor();

p = Runtime.getRuntime().exec("git --git-dir=" + basedir + "/.git --work-tree=" + basedir + " commit -m init");
p.waitFor();

p = Runtime.getRuntime().exec("git --git-dir=" + basedir + "/.git --work-tree=" + basedir + " checkout -b develop");
p.waitFor();
} catch (Exception e) {
e.printStackTrace();
return false;
}
return true;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:release-start -B

invoker.description=Non-interactive simple release-start: Failure due to SNAPSHOT dependency

invoker.buildResult=failure
17 changes: 17 additions & 0 deletions src/it/release-start-it-snapshot-dependency-fail/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<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.amashchenko.maven.plugin</groupId>
<artifactId>gitflow-maven-test</artifactId>
<packaging>pom</packaging>
<version>0.0.3-SNAPSHOT</version>

<dependencies>
<dependency>
<groupId>localhost</groupId>
<artifactId>dummy-api</artifactId>
<version>1.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
File file = new File( basedir, "build.log" );
assert file.exists();

String text = file.getText("utf-8");

// ensure build fails due to SNAPSHOT dependencies
assert text.contains("There is some SNAPSHOT dependencies in the project,")

return true;
10 changes: 10 additions & 0 deletions src/it/release-start-it-snapshot-parent-fail/dummy-parent/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<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>localhost</groupId>
<artifactId>dummy-parent</artifactId>
<version>1.1-SNAPSHOT</version>
<packaging>pom</packaging>

</project>
5 changes: 5 additions & 0 deletions src/it/release-start-it-snapshot-parent-fail/gitignorefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
build.log
expected-pom.xml
invoker.properties
init.bsh
verify.bsh
26 changes: 26 additions & 0 deletions src/it/release-start-it-snapshot-parent-fail/init.bsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import org.apache.commons.io.FileUtils;

try {
new File(basedir, "gitignorefile").renameTo(new File(basedir, ".gitignore"));

Process p = Runtime.getRuntime().exec("git --git-dir=" + basedir + "/.git --work-tree=" + basedir + " init");
p.waitFor();

Process p = Runtime.getRuntime().exec("git --git-dir=" + basedir + "/.git --work-tree=" + basedir + " config user.email '[email protected]'");
p.waitFor();
Process p = Runtime.getRuntime().exec("git --git-dir=" + basedir + "/.git --work-tree=" + basedir + " config user.name 'a'");
p.waitFor();

p = Runtime.getRuntime().exec("git --git-dir=" + basedir + "/.git --work-tree=" + basedir + " add .");
p.waitFor();

p = Runtime.getRuntime().exec("git --git-dir=" + basedir + "/.git --work-tree=" + basedir + " commit -m init");
p.waitFor();

p = Runtime.getRuntime().exec("git --git-dir=" + basedir + "/.git --work-tree=" + basedir + " checkout -b develop");
p.waitFor();
} catch (Exception e) {
e.printStackTrace();
return false;
}
return true;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:release-start -B

invoker.description=Non-interactive simple release-start: Failure due to SNAPSHOT parent dependency

invoker.buildResult=failure
13 changes: 13 additions & 0 deletions src/it/release-start-it-snapshot-parent-fail/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<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">
<parent>
<groupId>localhost</groupId>
<artifactId>dummy-parent</artifactId>
<version>1.1-SNAPSHOT</version>
<relativePath>dummy-parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.amashchenko.maven.plugin</groupId>
<artifactId>gitflow-maven-test</artifactId>
<packaging>pom</packaging>
<version>0.0.3-SNAPSHOT</version>
</project>
9 changes: 9 additions & 0 deletions src/it/release-start-it-snapshot-parent-fail/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
File file = new File( basedir, "build.log" );
assert file.exists();

String text = file.getText("utf-8");

// ensure build fails due to SNAPSHOT dependencies
assert text.contains("There is some SNAPSHOT dependencies in the project,")

return true;
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TimeZone;
import java.util.regex.Pattern;

Expand Down Expand Up @@ -340,7 +342,7 @@ protected void checkSnapshotDependencies() throws MojoFailureException {
getLog().info("Checking for SNAPSHOT versions in dependencies.");

List<String> snapshots = new ArrayList<>();
List<String> builtArtifacts = new ArrayList<>();
Set<String> builtArtifacts = new HashSet<>();

List<MavenProject> projects = mavenSession.getProjects();
for (MavenProject project : projects) {
Expand All @@ -355,6 +357,13 @@ protected void checkSnapshotDependencies() throws MojoFailureException {
snapshots.add(reloadedProject + " -> " + d);
}
}
MavenProject parent = reloadedProject.getParent();
if (parent != null) {
String id = parent.getGroupId() + ":" + parent.getArtifactId() + ":" + parent.getVersion();
if (!builtArtifacts.contains(id) && ArtifactUtils.isSnapshot(parent.getVersion())) {
snapshots.add(reloadedProject + " -> " + parent);
}
}
}

if (!snapshots.isEmpty()) {
Expand Down