Skip to content

Commit

Permalink
Merge branch 'main' into fix/add-columns-to-datatable
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek authored Jun 23, 2024
2 parents 3b3df57 + 702ec67 commit e086a48
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,9 @@ private J.MethodInvocation updateDependency(J.MethodInvocation method, Execution
}
} else if (arg instanceof J.Literal) {
J.Literal literal = (J.Literal) arg;
if (literal.getType() != JavaType.Primitive.String) {
return arg;
}
String gav = (String) literal.getValue();
if (gav == null) {
getCursor().putMessage(UPDATE_VERSION_ERROR_KEY, new IllegalStateException("Unable to update version"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -882,4 +882,29 @@ void unknownConfiguration() {
)
);
}

@Test
@Issue("https://github.com/openrewrite/rewrite/issues/4275")
void noActionForNonStringLiterals() {
rewriteRun(
buildGradle(
"""
plugins {
id 'java'
}
repositories {
mavenCentral()
}
dependencies {
implementation(gradleApi())
jar {
enabled(true)
}
}
"""
)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ public List<ResolvedDependency> resolveDependencies(Scope scope, Map<GroupArtifa
for (Dependency requestedDependency : getRequestedDependencies()) {
Dependency d = getValues(requestedDependency, 0);
Scope dScope = Scope.fromName(d.getScope());
if (dScope == scope || dScope.isInClasspathOf(scope)) {
if (dScope == scope || dScope.transitiveOf(scope) == scope) {
dependenciesAtDepth.add(new DependencyAndDependent(requestedDependency, Scope.Compile, null, requestedDependency, this));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3008,4 +3008,34 @@ void transitiveDependencyManagement() {
)
);
}

@Test
void runtimeClasspathOnly() {
rewriteRun(
pomXml(
"""
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>cache-2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>4.0.5</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</project>
""",
spec -> spec.afterRecipe(pomXml -> {
MavenResolutionResult resolution = pomXml.getMarkers().findFirst(MavenResolutionResult.class).orElseThrow();
assertThat(resolution.findDependencies("org.glassfish.jaxb", "jaxb-runtime", Scope.Runtime)).isNotEmpty();
assertThat(resolution.findDependencies("org.glassfish.jaxb", "jaxb-runtime", Scope.Compile)).isEmpty();
assertThat(resolution.findDependencies("jakarta.xml.bind", "jakarta.xml.bind-api", Scope.Compile)).isEmpty();
})
)
);
}
}
8 changes: 1 addition & 7 deletions rewrite-xml/src/main/java/org/openrewrite/xml/tree/Xml.java
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,9 @@ public Xml.Document withCharset(Charset charset) {
@With
Prolog prolog;

@With
Tag root;

public Document withRoot(Tag root) {
if (this.root == root) {
return this;
}
return new Document(id, sourcePath, prefixUnsafe, markers, charsetName, charsetBomMarked, checksum, fileAttributes, prolog, root, eof);
}

String eof;

public Document withEof(String eof) {
Expand Down

0 comments on commit e086a48

Please sign in to comment.