Merge branch '2.1.x'

This commit is contained in:
Marcin Grzejszczak
2019-08-23 16:41:33 +02:00
5 changed files with 20 additions and 10 deletions

View File

@@ -47,6 +47,10 @@ public class GenerateStubsMojo extends AbstractMojo {
required = true)
private File projectBuildDirectory;
@Parameter(defaultValue = "${project.build.finalName}", readonly = true,
required = true)
private String projectFinalName;
@Parameter(property = "stubsDirectory",
defaultValue = "${project.build.directory}/stubs")
private File outputDirectory;
@@ -112,9 +116,14 @@ public class GenerateStubsMojo extends AbstractMojo {
stubsJarFile);
}
private File createStubJar(File stubsOutputDir) throws MojoFailureException {
String stubArchiveName = this.project.getBuild().getFinalName() + "-"
+ this.classifier + ".jar";
private File createStubJar(File stubsOutputDir)
throws MojoFailureException, MojoExecutionException {
if (!stubsOutputDir.exists()) {
throw new MojoExecutionException("Stubs could not be found: ["
+ stubsOutputDir.getAbsolutePath()
+ "] .\nPlease make sure that spring-cloud-contract:convert was invoked");
}
String stubArchiveName = this.projectFinalName + "-" + this.classifier + ".jar";
File stubsJarFile = new File(this.projectBuildDirectory, stubArchiveName);
String[] excludes = excludes();
getLog().info("Files matching this pattern will be excluded from "

View File

@@ -148,7 +148,7 @@ public class PluginUnitTest {
public void shouldGenerateStubs() throws Exception {
File basedir = this.resources.getBasedir("generatedStubs");
this.maven.executeMojo(basedir, "generateStubs", defaultPackageForTests());
assertFilesPresent(basedir, "target/sample-project-0.1-stubs.jar");
assertFilesPresent(basedir, "target/sample-project-stubs.jar");
}
@Test
@@ -156,7 +156,7 @@ public class PluginUnitTest {
File basedir = this.resources.getBasedir("generatedStubs");
this.maven.executeMojo(basedir, "generateStubs", defaultPackageForTests(),
newParameter("attachContracts", "false"));
assertFilesPresent(basedir, "target/sample-project-0.1-stubs.jar");
assertFilesPresent(basedir, "target/sample-project-stubs.jar");
// FIXME: add assertion for jar content
}
@@ -165,7 +165,7 @@ public class PluginUnitTest {
File basedir = this.resources.getBasedir("generatedStubs");
this.maven.executeMojo(basedir, "generateStubs", defaultPackageForTests(),
newParameter("classifier", "foo"));
assertFilesPresent(basedir, "target/sample-project-0.1-foo.jar");
assertFilesPresent(basedir, "target/sample-project-foo.jar");
}
@Test

View File

@@ -27,6 +27,7 @@
<version>0.1</version>
<build>
<finalName>${project.name}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.cloud</groupId>