|
19 | 19 | import org.openrewrite.DocumentExample; |
20 | 20 | import org.openrewrite.test.RecipeSpec; |
21 | 21 | import org.openrewrite.test.RewriteTest; |
| 22 | +import org.openrewrite.test.SourceSpec; |
22 | 23 |
|
23 | 24 | import java.util.regex.Matcher; |
24 | 25 | import java.util.regex.Pattern; |
25 | 26 |
|
26 | 27 | import static org.assertj.core.api.Assertions.assertThat; |
| 28 | +import static org.openrewrite.java.Assertions.mavenProject; |
27 | 29 | import static org.openrewrite.maven.Assertions.pomXml; |
28 | 30 |
|
29 | 31 | class LombokBestPracticesTest implements RewriteTest { |
@@ -90,4 +92,97 @@ void providedScope() { |
90 | 92 | ) |
91 | 93 | ); |
92 | 94 | } |
| 95 | + |
| 96 | + @Test |
| 97 | + void excludeTransitiveLombok() { |
| 98 | + //language=xml |
| 99 | + rewriteRun( |
| 100 | + mavenProject( |
| 101 | + "parent", |
| 102 | + pomXml( |
| 103 | + """ |
| 104 | + <project> |
| 105 | + <modelVersion>4.0.0</modelVersion> |
| 106 | + <groupId>com.example</groupId> |
| 107 | + <artifactId>parent</artifactId> |
| 108 | + <version>1.0.0</version> |
| 109 | + <modules> |
| 110 | + <module>library</module> |
| 111 | + <module>project</module> |
| 112 | + </modules> |
| 113 | + </project> |
| 114 | + """ |
| 115 | + ), |
| 116 | + mavenProject("library", |
| 117 | + pomXml( |
| 118 | + """ |
| 119 | + <project> |
| 120 | + <modelVersion>4.0.0</modelVersion> |
| 121 | + <parent> |
| 122 | + <groupId>com.example</groupId> |
| 123 | + <artifactId>parent</artifactId> |
| 124 | + <version>1.0.0</version> |
| 125 | + </parent> |
| 126 | + <artifactId>library</artifactId> |
| 127 | + <dependencies> |
| 128 | + <dependency> |
| 129 | + <groupId>org.projectlombok</groupId> |
| 130 | + <artifactId>lombok</artifactId> |
| 131 | + <version>1.18.6</version> |
| 132 | + </dependency> |
| 133 | + </dependencies> |
| 134 | + </project> |
| 135 | + """, |
| 136 | + SourceSpec::skip // Keep as is, such that we trigger exclude below |
| 137 | + ) |
| 138 | + ), |
| 139 | + mavenProject("project", |
| 140 | + pomXml( |
| 141 | + """ |
| 142 | + <project> |
| 143 | + <modelVersion>4.0.0</modelVersion> |
| 144 | + <parent> |
| 145 | + <groupId>com.example</groupId> |
| 146 | + <artifactId>parent</artifactId> |
| 147 | + <version>1.0.0</version> |
| 148 | + </parent> |
| 149 | + <artifactId>project</artifactId> |
| 150 | + <dependencies> |
| 151 | + <dependency> |
| 152 | + <groupId>com.example</groupId> |
| 153 | + <artifactId>library</artifactId> |
| 154 | + <version>1.0.0</version> |
| 155 | + </dependency> |
| 156 | + </dependencies> |
| 157 | + </project> |
| 158 | + """, |
| 159 | + """ |
| 160 | + <project> |
| 161 | + <modelVersion>4.0.0</modelVersion> |
| 162 | + <parent> |
| 163 | + <groupId>com.example</groupId> |
| 164 | + <artifactId>parent</artifactId> |
| 165 | + <version>1.0.0</version> |
| 166 | + </parent> |
| 167 | + <artifactId>project</artifactId> |
| 168 | + <dependencies> |
| 169 | + <dependency> |
| 170 | + <groupId>com.example</groupId> |
| 171 | + <artifactId>library</artifactId> |
| 172 | + <version>1.0.0</version> |
| 173 | + <exclusions> |
| 174 | + <exclusion> |
| 175 | + <groupId>org.projectlombok</groupId> |
| 176 | + <artifactId>lombok</artifactId> |
| 177 | + </exclusion> |
| 178 | + </exclusions> |
| 179 | + </dependency> |
| 180 | + </dependencies> |
| 181 | + </project> |
| 182 | + """ |
| 183 | + ) |
| 184 | + ) |
| 185 | + ) |
| 186 | + ); |
| 187 | + } |
93 | 188 | } |
0 commit comments