-
Notifications
You must be signed in to change notification settings - Fork 913
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1676 from Netyyyy
* pr/1676: Polish "Add help section and Maven plugin when azure-support is selected" Add help section and Maven plugin when azure-support is selected Closes gh-1676
- Loading branch information
Showing
5 changed files
with
158 additions
and
2 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
...o/spring/start/site/extension/dependency/springazure/SpringAzureMavenBuildCustomizer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Copyright 2012-2024 the original author or authors. | ||
* | ||
* Licensed 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 | ||
* | ||
* https://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. | ||
*/ | ||
|
||
package io.spring.start.site.extension.dependency.springazure; | ||
|
||
import io.spring.initializr.generator.buildsystem.maven.MavenBuild; | ||
import io.spring.initializr.generator.project.ProjectDescription; | ||
import io.spring.initializr.generator.spring.build.BuildCustomizer; | ||
|
||
/** | ||
* A {@link BuildCustomizer} that adds a Maven plugin when azure-support is selected. | ||
* | ||
* @author Muyao Feng | ||
*/ | ||
class SpringAzureMavenBuildCustomizer implements BuildCustomizer<MavenBuild> { | ||
|
||
private static final String PLUGIN_VERSION = "0.1.0"; | ||
|
||
private final ProjectDescription projectDescription; | ||
|
||
SpringAzureMavenBuildCustomizer(ProjectDescription projectDescription) { | ||
this.projectDescription = projectDescription; | ||
} | ||
|
||
@Override | ||
public void customize(MavenBuild build) { | ||
build.plugins().add("com.microsoft.azure", "azure-container-apps-maven-plugin", (plugin) -> { | ||
plugin.version(PLUGIN_VERSION); | ||
plugin.configuration((configuration) -> { | ||
configuration.add("subscriptionId", "your-subscription-id"); | ||
configuration.add("resourceGroup", "your-resource-group"); | ||
configuration.add("appEnvironmentName", "your-app-environment-name"); | ||
configuration.add("region", "your-region"); | ||
configuration.add("appName", this.projectDescription.getName()); | ||
configuration.add("containers", (containers) -> { | ||
containers.add("container", (container) -> { | ||
container.add("type", "code"); | ||
container.add("directory", "${project.basedir}"); | ||
}); | ||
}); | ||
configuration.add("ingress", (ingress) -> { | ||
ingress.add("external", "true"); | ||
ingress.add("targetPort", "8080"); | ||
}); | ||
configuration.add("scale", (scale) -> { | ||
scale.add("minReplicas", "0"); | ||
scale.add("maxReplicas", "10"); | ||
}); | ||
}); | ||
}); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...ing/start/site/extension/dependency/springazure/SpringAzureMavenBuildCustomizerTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright 2012-2024 the original author or authors. | ||
* | ||
* Licensed 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 | ||
* | ||
* https://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. | ||
*/ | ||
|
||
package io.spring.start.site.extension.dependency.springazure; | ||
|
||
import io.spring.initializr.web.project.ProjectRequest; | ||
import io.spring.start.site.extension.AbstractExtensionTests; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
/** | ||
* Tests for {@link SpringAzureMavenBuildCustomizer}. | ||
* | ||
* @author Muyao Feng | ||
* @author Moritz Halbritter | ||
*/ | ||
class SpringAzureMavenBuildCustomizerTests extends AbstractExtensionTests { | ||
|
||
@Test | ||
void shouldDoNothingIfAzureSupportIsntSelected() { | ||
ProjectRequest request = createProjectRequest("web"); | ||
assertThat(mavenPom(request)).doesNotContain("azure-container-apps-maven-plugin"); | ||
} | ||
|
||
@Test | ||
void azureContainerAppsMavenPluginAddedWhenAzureSupportPresent() { | ||
ProjectRequest request = createProjectRequest("azure-support"); | ||
assertThat(mavenPom(request)).hasText("/project/build/plugins/plugin[1]/groupId", "com.microsoft.azure") | ||
.hasText("/project/build/plugins/plugin[1]/artifactId", "azure-container-apps-maven-plugin"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters