Comments (8)
Thanks again for the report @smurf667 ; you can try it out through our snapshot versions, before we release somewhere in the next two weeks.
from rewrite.
Thank you @timtebeek - I am very impressed with the handling of the issue and the speed of the fix. I tried the 8.12.0-SNAPSHOT, and it works for me. Good job, and thanks again!
from rewrite.
Thanks for providing context to the issue; indeed unfortunate that you have to deal with such escapes, and we have to handle that better.
from rewrite.
Exploring the issue here for a bit; your test indeed fails; this passes, despite the escape
@Test
void escapedAinArtifactId() {
rewriteRun(
pomXml(
"""
<project>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1</version>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.9</version>
</dependency>
</dependencies>
</project>
""",
spec -> spec.afterRecipe(pomXml -> {
assertThat(pomXml.getMarkers().findFirst(MavenResolutionResult.class).orElseThrow()
.getDependencies().get(Scope.Compile))
.singleElement()
.satisfies(dep -> assertThat(dep.getArtifactId()).isEqualTo("slf4j-api"));
})
)
);
}
from rewrite.
And this indeed shows what you also found, that the artifactId contains an ArrayList instead of a regular value
@Test
void escapedAinArtifactIdVisited() {
rewriteRun(
spec -> spec.recipe(RewriteTest.toRecipe(() -> new XmlVisitor<>() {
@Override
public Xml visitTag(Xml.Tag tag, ExecutionContext ctx) {
if (new XPathMatcher("/project/dependencies/dependency").matches(getCursor())) {
var child = tag.getChild("artifactId");
var childValue = tag.getChildValue("artifactId");
var children = tag.getChildren("artifactId");
System.out.println();
}
return super.visitTag(tag, ctx);
}
})),
pomXml(
"""
<project>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1</version>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.9</version>
</dependency>
</dependencies>
</project>
"""
)
);
}
from rewrite.
@traceyyoshima It seems like the XML entity fix you made doesn't also extend to XML character references and needs a separate fix.
from rewrite.
I think I have a fix in
from rewrite.
Glad to hear that works and thanks for confirming here!
from rewrite.
Related Issues (20)
- DependencyUseStringNotation.coerceToStringNotation method is not compatible with G.GString
- ChangePropertyValue regex does not allow for multiple replacements of same regex pattern.
- `ChangePluginGroupIdAndArtifactId` ignores profile specific plugins HOT 1
- Allow custom location of parser workspace HOT 2
- `AddOrUpdateAnnotationAttribute` throws an error when adding a `class` as `attributeValue` HOT 2
- UpdateMavenWrapper inconsistent when the wrapper is in a nested directory HOT 10
- Trailing comma in an array end up in white-space HOT 2
- Declarative Preconditions - `or` association
- Declarative Preconditions - Control applicability to ScanningRecipes HOT 6
- Split method signature line into multiple lines based on the length HOT 1
- Add or merge content to yaml file HOT 7
- Create YAML File with remote content HOT 2
- Create a folder HOT 8
- [Windows build from source] Gradle JDK auto-download doesn't work as expected HOT 2
- Unirest 4.x HOT 1
- foo.properties is not print idempotent due to `key==value` HOT 1
- `ChangeType` not working with types provided to the parser using `dependsOn`. HOT 6
- RemoveObjectsIsNull doesn't remove unnecessary parentheses, if it HOT 1
- `AddManagedDependency` should allow version placeholder properties HOT 7
- org.openrewrite.gradle.RemoveDependency does not remove dependency in subproject HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rewrite.