Skip to content

Commit

Permalink
Remove JIB plugin from apps generator.
Browse files Browse the repository at this point in the history
Removes jib-plugin
Modified tests that checked for presence of jib-plugin.
  • Loading branch information
Corneil du Plessis committed Dec 11, 2024
1 parent 0679da0 commit a98f21b
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,39 +138,18 @@
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
{{#app.bootPluginConfiguration}}
<configuration>
<image>
<name>{{app.containerImage.orgName}}/${project.artifactId}:{{app.containerImage.tag}}</name>
</image>
<!-- extra configuration -->
{{#app.bootPluginConfiguration}}
{{this}}
{{/app.bootPluginConfiguration}}
<!-- (end) extra configuration -->
</configuration>
{{/app.bootPluginConfiguration}}
</plugin>

<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<from>
<image>{{app.containerImage.baseImage}}</image>
</from>
<to>
<image>{{app.containerImage.orgName}}/${project.artifactId}:{{app.containerImage.tag}}</image>
</to>
<container>
<creationTime>USE_CURRENT_TIMESTAMP</creationTime>
<format>{{app.containerImage.format}}</format>
{{#app.containerImage.enableMetadata}}
<labels>
<org.springframework.cloud.dataflow.spring-configuration-metadata.json>
${org.springframework.cloud.dataflow.spring.configuration.metadata.json}
</org.springframework.cloud.dataflow.spring-configuration-metadata.json>
<application.name>${project.artifactId}</application.name>
<application.version>${project.version}</application.version>
</labels>
{{/app.containerImage.enableMetadata}}
</container>
</configuration>
</plugin>

{{#app.containerImage.enableMetadata}}
<!--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,6 @@
<url>https://repo.spring.io/libs-snapshot-local;buildName=${buildName};buildNumber=${buildNumber}</url>
</snapshotRepository>
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>3.3.0</version>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>milestone</id>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void httpSourceAppsGeneration() throws Exception {

Parent parent = pomModel.getParent();
assertThat(parent.getArtifactId()).isEqualTo("spring-boot-starter-parent");
assertThat(parent.getVersion()).isEqualTo("3.3.0.M3");
assertThat(parent.getVersion()).isEqualTo("3.3.6");
assertThat(pomModel.getArtifactId()).isEqualTo("http-source-kafka");
assertThat(pomModel.getGroupId()).isEqualTo("org.springframework.cloud.stream.app.test");
assertThat(pomModel.getName()).isEqualTo("http-source-kafka");
Expand All @@ -93,15 +93,6 @@ void httpSourceAppsGeneration() throws Exception {
List<Plugin> plugins = pomModel.getBuild().getPlugins();
assertThat(plugins.stream().filter(p -> p.getArtifactId().equals("spring-boot-maven-plugin")).count()).isEqualTo(1);
assertThat(plugins.stream().filter(p -> p.getArtifactId().equals("properties-maven-plugin")).count()).isEqualTo(1);
assertThat(plugins.stream().filter(p -> p.getArtifactId().equals("jib-maven-plugin")).count()).isEqualTo(1);

Plugin jibPlugin = plugins.stream().filter(p -> p.getArtifactId().equals("jib-maven-plugin")).findFirst().get();
assertThat(jibPlugin.getConfiguration().toString())
.contains("<org.springframework.cloud.dataflow.spring-configuration-metadata.json>" +
"${org.springframework.cloud.dataflow.spring.configuration.metadata.json}" +
"</org.springframework.cloud.dataflow.spring-configuration-metadata.json>");
assertThat(jibPlugin.getConfiguration().toString()).contains("<image>testspringcloud/${project.artifactId}:3.0.0.BUILD-SNAPSHOT</image>");
assertThat(jibPlugin.getConfiguration().toString()).contains("<image>globalBaseImage</image>");

assertThat(pomModel.getRepositories().size()).isEqualTo(5);
assertThat(pomModel.getRepositories().stream().map(r -> r.getId()).collect(Collectors.toList()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void prepareForTest() throws NoSuchFieldException {
application.getMaven().getDependencies().add(dep);

// BOM
application.setBootVersion("3.3.0.M3");
application.setBootVersion("3.3.6");
application.getMetadata().setMavenPluginVersion("1.0.2.BUILD-SNAPSHOT");

setMojoProperty("application", application);
Expand Down Expand Up @@ -126,13 +126,6 @@ public void testWithDisabledContainerMetadata() throws Exception {
// The properties-maven-plugin should not be defined if the container metadata is not enabled.
assertThat(plugins.stream().filter(p -> p.getArtifactId().equals("properties-maven-plugin")).count()).isEqualTo(0);

assertThat(plugins.stream().filter(p -> p.getArtifactId().equals("jib-maven-plugin")).count()).isEqualTo(1);

Plugin jibPlugin = plugins.stream().filter(p -> p.getArtifactId().equals("jib-maven-plugin")).findFirst().get();
assertThat(jibPlugin.getConfiguration().toString())
.doesNotContain("<org.springframework.cloud.dataflow.spring-configuration-metadata.json>" +
"${org.springframework.cloud.dataflow.spring.configuration.metadata.json}" +
"</org.springframework.cloud.dataflow.spring-configuration-metadata.json>");
}

@Test
Expand Down Expand Up @@ -166,9 +159,11 @@ public void testCustomBootMavenPluginConfiguration() throws Exception {
assertThat(bootPlugin.isPresent()).isTrue();
final Plugin plugin = bootPlugin.get();
final Xpp3Dom configuration = (Xpp3Dom) plugin.getConfiguration();
assertThat(configuration.getValue().contains("<requiresUnpack>")).isTrue();
assertThat(configuration.getValue().contains("jython-standalone")).isTrue();
assertThat(configuration.getValue().contains("</requiresUnpack>")).isTrue();
assertThat(configuration).isNotNull();
String configurationString = configuration.toString();
assertThat(configurationString).contains("<requiresUnpack>");
assertThat(configurationString).contains("jython-standalone");
assertThat(configurationString).contains("</requiresUnpack>");
}

private void assertGeneratedPomXml(File rootPath) {
Expand All @@ -186,7 +181,7 @@ private void assertGeneratedPomXml(File rootPath) {

Parent parent = pomModel.getParent();
assertThat(parent.getArtifactId()).isEqualTo("spring-boot-starter-parent");
assertThat(parent.getVersion()).isEqualTo("3.3.0.M3");
assertThat(parent.getVersion()).isEqualTo("3.3.6");

assertThat(pomModel.getArtifactId()).isEqualTo("log-sink-kafka");
assertThat(pomModel.getGroupId()).isEqualTo("org.springframework.cloud.stream.app");
Expand All @@ -197,14 +192,6 @@ private void assertGeneratedPomXml(File rootPath) {
List<Plugin> plugins = pomModel.getBuild().getPlugins();
assertThat(plugins.stream().filter(p -> p.getArtifactId().equals("spring-boot-maven-plugin")).count()).isEqualTo(1);
assertThat(plugins.stream().filter(p -> p.getArtifactId().equals("properties-maven-plugin")).count()).isEqualTo(1);
assertThat(plugins.stream().filter(p -> p.getArtifactId().equals("jib-maven-plugin")).count()).isEqualTo(1);

Plugin jibPlugin = plugins.stream().filter(p -> p.getArtifactId().equals("jib-maven-plugin")).findFirst().get();
assertThat(jibPlugin.getConfiguration().toString())
.contains("<org.springframework.cloud.dataflow.spring-configuration-metadata.json>" +
"${org.springframework.cloud.dataflow.spring.configuration.metadata.json}" +
"</org.springframework.cloud.dataflow.spring-configuration-metadata.json>");
assertThat(jibPlugin.getConfiguration().toString()).contains("<image>base/image</image>");

assertThat(pomModel.getRepositories().size()).isEqualTo(2);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<packaging>jar</packaging>

<properties>
<spring-boot.version>3.3.0.M3</spring-boot.version>
<spring-boot.version>3.3.6</spring-boot.version>
<stream-apps-core.version>5.0.0-SNAPSHOT</stream-apps-core.version>
<java-cfenv-boot.version>3.2.0</java-cfenv-boot.version>
<app-metadata-maven-plugin-version>1.1.0-SNAPSHOT</app-metadata-maven-plugin-version>
Expand Down Expand Up @@ -44,7 +44,7 @@
<application>
<bootVersion>${spring-boot.version}</bootVersion>
<metadata>
<mavenPluginVersion>3.3.0-M1</mavenPluginVersion>
<mavenPluginVersion>3.3.0</mavenPluginVersion>
</metadata>
<containerImage>
<orgName>globalOrgName</orgName>
Expand Down

0 comments on commit a98f21b

Please sign in to comment.