-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Delaying execution to the end of multi-module project with Maven para…
…llel build (#726) * Delaying execution to the end of multi-module project * Clean comments
- Loading branch information
1 parent
20fbae7
commit 38eb90b
Showing
11 changed files
with
231 additions
and
22 deletions.
There are no files selected for viewing
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
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
48 changes: 48 additions & 0 deletions
48
src/test/java/org/openrewrite/maven/RewriteRunParallelIT.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,48 @@ | ||
/* | ||
* Copyright 2021 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 org.openrewrite.maven; | ||
|
||
import com.soebes.itf.jupiter.extension.*; | ||
import com.soebes.itf.jupiter.maven.MavenExecutionResult; | ||
import org.junit.jupiter.api.condition.DisabledOnOs; | ||
import org.junit.jupiter.api.condition.OS; | ||
|
||
import static com.soebes.itf.extension.assertj.MavenITAssertions.assertThat; | ||
|
||
@MavenJupiterExtension | ||
@MavenOption(value = MavenCLIOptions.THREADS, parameter = "2") | ||
@MavenOption(MavenCLIOptions.NO_TRANSFER_PROGRESS) | ||
@MavenOption(MavenCLIExtra.MUTE_PLUGIN_VALIDATION_WARNING) | ||
@DisabledOnOs(OS.WINDOWS) | ||
@MavenGoal("${project.groupId}:${project.artifactId}:${project.version}:run") | ||
@SuppressWarnings("NewClassNamingConvention") | ||
class RewriteRunParallelIT { | ||
|
||
@MavenTest | ||
void multi_module_project(MavenExecutionResult result) { | ||
assertThat(result) | ||
.isSuccessful() | ||
.out() | ||
.info() | ||
.anySatisfy(line -> assertThat(line).contains("Delaying execution to the end of multi-module project for org.openrewrite.maven:b:1.0")); | ||
|
||
assertThat(result) | ||
.isSuccessful() | ||
.out() | ||
.warn() | ||
.anySatisfy(line -> assertThat(line).contains("org.openrewrite.staticanalysis.SimplifyBooleanExpression")); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
...t/resources-its/org/openrewrite/maven/RewriteRunParallelIT/multi_module_project/a/pom.xml
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,38 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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> | ||
|
||
<parent> | ||
<groupId>org.openrewrite.maven</groupId> | ||
<artifactId>multi_module_project</artifactId> | ||
<version>1.0</version> | ||
</parent> | ||
|
||
<artifactId>a</artifactId> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-antrun-plugin</artifactId> | ||
<version>3.0.0</version> | ||
<executions> | ||
<execution> | ||
<id>simulate-sleep</id> | ||
<phase>validate</phase> | ||
<goals> | ||
<goal>run</goal> | ||
</goals> | ||
<configuration> | ||
<target> | ||
<sleep seconds="10"/> | ||
</target> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
4 changes: 4 additions & 0 deletions
4
...e/maven/RewriteRunParallelIT/multi_module_project/a/src/main/java/sample/MyInterface.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,4 @@ | ||
package sample; | ||
|
||
public interface MyInterface { | ||
} |
20 changes: 20 additions & 0 deletions
20
...writeRunParallelIT/multi_module_project/a/src/main/java/sample/SimplifyBooleanSample.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,20 @@ | ||
package sample; | ||
|
||
public class SimplifyBooleanSample { | ||
boolean ifNoElse() { | ||
if (isOddMillis()) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
static boolean isOddMillis() { | ||
boolean even = System.currentTimeMillis() % 2 == 0; | ||
if (even == true) { | ||
return false; | ||
} | ||
else { | ||
return true; | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...t/resources-its/org/openrewrite/maven/RewriteRunParallelIT/multi_module_project/b/pom.xml
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,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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> | ||
|
||
<parent> | ||
<groupId>org.openrewrite.maven</groupId> | ||
<artifactId>multi_module_project</artifactId> | ||
<version>1.0</version> | ||
</parent> | ||
|
||
<artifactId>b</artifactId> | ||
|
||
</project> |
14 changes: 14 additions & 0 deletions
14
...en/RewriteRunParallelIT/multi_module_project/b/src/main/java/sample/EmptyBlockSample.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,14 @@ | ||
package sample; | ||
|
||
import java.util.Random; | ||
|
||
public class EmptyBlockSample { | ||
int n = sideEffect(); | ||
|
||
static { | ||
} | ||
|
||
int sideEffect() { | ||
return new Random().nextInt(); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
...est/resources-its/org/openrewrite/maven/RewriteRunParallelIT/multi_module_project/pom.xml
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 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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>multi_module_project</artifactId> | ||
<version>1.0</version> | ||
<packaging>pom</packaging> | ||
|
||
<modules> | ||
<module>a</module> | ||
<module>b</module> | ||
</modules> | ||
|
||
<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>com.example.RewriteRunIT.CodeCleanup</recipe> | ||
</activeRecipes> | ||
<configLocation> | ||
${maven.multiModuleProjectDirectory}/src/test/resources-its/org/openrewrite/maven/RewriteRunIT/multi_module_project/rewrite.yml | ||
</configLocation> | ||
</configuration> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.openrewrite.recipe</groupId> | ||
<artifactId>rewrite-static-analysis</artifactId> | ||
<version>1.0.4</version> | ||
</dependency> | ||
</dependencies> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
7 changes: 7 additions & 0 deletions
7
...resources-its/org/openrewrite/maven/RewriteRunParallelIT/multi_module_project/rewrite.yml
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,7 @@ | ||
--- | ||
type: specs.openrewrite.org/v1beta/recipe | ||
name: com.example.RewriteRunIT.CodeCleanup | ||
recipeList: | ||
- org.openrewrite.staticanalysis.SimplifyBooleanExpression | ||
- org.openrewrite.staticanalysis.SimplifyBooleanReturn | ||
- org.openrewrite.staticanalysis.UnnecessaryParentheses |