Skip to content

Commit

Permalink
Handle profile activation property being null
Browse files Browse the repository at this point in the history
  • Loading branch information
aegershman committed Dec 15, 2021
1 parent 22fd805 commit 66cf7c5
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ private MavenSettings buildSettings() {
p.getActivation() == null ? null : new ProfileActivation(
p.getActivation().isActiveByDefault(),
p.getActivation().getJdk(),
new ProfileActivation.Property(
p.getActivation().getProperty() == null ? null : new ProfileActivation.Property(
p.getActivation().getProperty().getName(),
p.getActivation().getProperty().getValue()
)
Expand Down
17 changes: 17 additions & 0 deletions src/test/java/org/openrewrite/maven/BasicIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,23 @@ void groupid_artifactid_should_be_ok(MavenExecutionResult result) {
.containsOnly("JAR will be empty - no content was marked for inclusion!");
}

@MavenTest
@MavenOption(value = MavenCLIOptions.SETTINGS, parameter = "settings.xml")
@MavenGoal("${project.groupId}:${project.artifactId}:${project.version}:dryRun")
void null_check_profile_activation(MavenExecutionResult result) {
assertThat(result)
.isSuccessful()
.out()
.info()
.anySatisfy(line -> assertThat(line).contains("Applying recipes would make no changes. No patch file generated."));

assertThat(result)
.isSuccessful()
.out()
.warn()
.isEmpty();
}

@MavenTest
@SystemProperty(value = "ossrh_snapshots_url", content = "https://oss.sonatype.org/content/repositories/snapshots")
@MavenGoal("${project.groupId}:${project.artifactId}:${project.version}:dryRun")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
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>org.openrewrite.maven</groupId>
<artifactId>null_check_profile_activation</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>BasicIT#null_check_profile_activation</name>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
<plugins>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
<configuration>
<activeRecipes>
<recipe>org.openrewrite.java.format.AutoFormat</recipe>
</activeRecipes>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<settings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<profiles>
<profile>
<id>example_profile_id</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>example_repository_id</id>
<url>https://repo1.maven.org/maven2</url>
</repository>
</repositories>
</profile>
</profiles>

</settings>

0 comments on commit 66cf7c5

Please sign in to comment.