Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,12 @@ public class PluginUpgradeStrategy extends AbstractUpgradeStrategy {
DEFAULT_MAVEN_PLUGIN_GROUP_ID,
"maven-resources-plugin",
"3.3.1",
"Beta/RC versions compiled against different Maven 4 API signatures"));
"Beta/RC versions compiled against different Maven 4 API signatures"),
new PluginUpgrade(
"org.codehaus.mojo",
"jaxb2-maven-plugin",
"3.2.0",
"Versions before 3.2.0 depend on jaxb-parent:3.0.0 which contains invalid XML rejected by Maven 4"));

private static final List<PluginUpgrade> PLUGIN_DEPENDENCY_UPGRADES = List.of(new PluginUpgrade(
"org.codehaus.mojo",
Expand Down Expand Up @@ -270,6 +275,9 @@ private Map<String, PluginUpgradeInfo> getPluginUpgradesMap() {
upgrades.put(
DEFAULT_MAVEN_PLUGIN_GROUP_ID + ":maven-resources-plugin",
new PluginUpgradeInfo(DEFAULT_MAVEN_PLUGIN_GROUP_ID, "maven-resources-plugin", "3.3.1"));
upgrades.put(
"org.codehaus.mojo:jaxb2-maven-plugin",
new PluginUpgradeInfo("org.codehaus.mojo", "jaxb2-maven-plugin", "3.2.0"));
return upgrades;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,45 @@ void shouldUpgradeSurefireReportPluginWhenBelowMinimum() throws Exception {
assertEquals("3.5.2", version);
}

@Test
@DisplayName("should upgrade jaxb2-maven-plugin when below minimum")
void shouldUpgradeJaxb2MavenPluginWhenBelowMinimum() throws Exception {
String pomXml = """
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>test</artifactId>
<version>1.0.0</version>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>3.1.0</version>
</plugin>
</plugins>
</build>
</project>
""";

Document document = Document.of(pomXml);
Map<Path, Document> pomMap = Map.of(Paths.get("pom.xml"), document);

UpgradeContext context = createMockContext();
UpgradeResult result = strategy.doApply(context, pomMap);

assertTrue(result.success(), "Plugin upgrade should succeed");
assertTrue(result.modifiedCount() > 0, "Should have upgraded jaxb2-maven-plugin");

Editor editor = new Editor(document);
Element root = editor.root();
String version = root.path("build", "plugins", "plugin", "version")
.map(Element::textContentTrimmed)
.orElse(null);
assertEquals("3.2.0", version);
}

@Test
@DisplayName("should not upgrade when version is already higher")
void shouldNotUpgradeWhenVersionAlreadyHigher() throws Exception {
Expand Down
Loading