Skip to content

Commit 070e0e5

Browse files
authored
UpgradeJaCoCoMavenPluginVersion (#79)
Closes #76
1 parent 17fd8e5 commit 070e0e5

File tree

3 files changed

+137
-0
lines changed

3 files changed

+137
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#
2+
# Copyright 2021 the original author or authors.
3+
# <p>
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
# <p>
8+
# https://www.apache.org/licenses/LICENSE-2.0
9+
# <p>
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
---
17+
type: specs.openrewrite.org/v1beta/recipe
18+
name: org.openrewrite.java.migrate.jacoco.UpgradeJaCoCoMavenPluginVersion
19+
displayName: Upgrade JaCoCo Maven plugin version
20+
description: This recipe will upgrade the JaCoCo Maven plugin to a more recent version compatible with Java 11.
21+
tags:
22+
- java11
23+
- jacoco
24+
25+
recipeList:
26+
- org.openrewrite.maven.UpgradePluginVersion:
27+
groupId: org.jacoco
28+
artifactId: jacoco-maven-plugin
29+
newVersion: 0.8.7

src/main/resources/META-INF/rewrite/java8-to-java11.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,6 @@ recipeList:
4343
- org.openrewrite.java.migrate.javax.JavaxLangModelUtil
4444
- org.openrewrite.java.migrate.javax.JavaxManagementMonitorAPIs
4545
- org.openrewrite.java.migrate.javax.JavaxXmlStreamAPIs
46+
# Upgrade JaCoCo
47+
- org.openrewrite.java.migrate.jacoco.UpgradeJaCoCoVersion
48+
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
/*
2+
* Copyright 2022 the original author or authors.
3+
* <p>
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* <p>
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
* <p>
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.openrewrite.java.migrate.wro4j;
17+
18+
import org.assertj.core.api.Assertions.assertThat
19+
import org.junit.jupiter.api.Test
20+
import org.openrewrite.Recipe
21+
import org.openrewrite.config.Environment
22+
import org.openrewrite.maven.MavenRecipeTest
23+
24+
class UpgradeJaCoCoMavenPluginVersionTest : MavenRecipeTest {
25+
override val recipe: Recipe = Environment.builder()
26+
.scanRuntimeClasspath("org.openrewrite.java.migrate.jacoco")
27+
.build()
28+
.activateRecipes("org.openrewrite.java.migrate.jacoco.UpgradeJaCoCoMavenPluginVersion")
29+
30+
@Test
31+
fun property() = assertChanged(
32+
before = """
33+
<project>
34+
<modelVersion>4.0.0</modelVersion>
35+
36+
<properties>
37+
<jacoco.version>0.8.1</jacoco.version>
38+
</properties>
39+
40+
<groupId>com.mycompany.app</groupId>
41+
<artifactId>my-app</artifactId>
42+
<version>1</version>
43+
<build>
44+
<plugins>
45+
<plugin>
46+
<groupId>org.jacoco</groupId>
47+
<artifactId>jacoco-maven-plugin</artifactId>
48+
<version>${jacoco.version}</version>
49+
<executions>
50+
<execution>
51+
<goals>
52+
<goal>prepare-agent</goal>
53+
</goals>
54+
</execution>
55+
<execution>
56+
<id>report</id>
57+
<phase>prepare-package</phase>
58+
<goals>
59+
<goal>report</goal>
60+
</goals>
61+
</execution>
62+
</executions>
63+
</plugin>
64+
</plugins>
65+
</build>
66+
</project>
67+
""",
68+
after = """
69+
<project>
70+
<modelVersion>4.0.0</modelVersion>
71+
72+
<properties>
73+
<jacoco.version>0.8.7</jacoco.version>
74+
</properties>
75+
76+
<groupId>com.mycompany.app</groupId>
77+
<artifactId>my-app</artifactId>
78+
<version>1</version>
79+
<build>
80+
<plugins>
81+
<plugin>
82+
<groupId>org.jacoco</groupId>
83+
<artifactId>jacoco-maven-plugin</artifactId>
84+
<version>${jacoco.version}</version>
85+
<executions>
86+
<execution>
87+
<goals>
88+
<goal>prepare-agent</goal>
89+
</goals>
90+
</execution>
91+
<execution>
92+
<id>report</id>
93+
<phase>prepare-package</phase>
94+
<goals>
95+
<goal>report</goal>
96+
</goals>
97+
</execution>
98+
</executions>
99+
</plugin>
100+
</plugins>
101+
</build>
102+
</project>
103+
"""
104+
)
105+
}

0 commit comments

Comments
 (0)