diff --git a/plugins/codemodder-plugin-maven/src/main/java/io/codemodder/plugins/maven/DefaultArtifactInjectionPositionFinder.java b/plugins/codemodder-plugin-maven/src/main/java/io/codemodder/plugins/maven/DefaultArtifactInjectionPositionFinder.java index 4bd2a8496..63998eaf3 100644 --- a/plugins/codemodder-plugin-maven/src/main/java/io/codemodder/plugins/maven/DefaultArtifactInjectionPositionFinder.java +++ b/plugins/codemodder-plugin-maven/src/main/java/io/codemodder/plugins/maven/DefaultArtifactInjectionPositionFinder.java @@ -18,17 +18,17 @@ public int find(final List> deltas, final String artifactI if (hasArtifactId && hasVersion) { // if it has the artifact and version, it could be the section, which // is 2nd preference - backupPosition = 1 + delta.getSource().getPosition(); + backupPosition = 1 + delta.getTarget().getPosition(); } else if (hasArtifactId) { // if it has the artifact but not the version, it could be the section, which // is preferred - return 1 + delta.getSource().getPosition(); + return 1 + delta.getTarget().getPosition(); } } if (backupPosition != null) { return backupPosition; } // the fallback is to just use the first change to the file - return 1 + deltas.get(0).getSource().getPosition(); + return 1 + deltas.get(0).getTarget().getPosition(); } } diff --git a/plugins/codemodder-plugin-maven/src/test/java/io/codemodder/plugins/maven/MavenProviderTest.java b/plugins/codemodder-plugin-maven/src/test/java/io/codemodder/plugins/maven/MavenProviderTest.java index 1925c7636..3fe5b7e3b 100644 --- a/plugins/codemodder-plugin-maven/src/test/java/io/codemodder/plugins/maven/MavenProviderTest.java +++ b/plugins/codemodder-plugin-maven/src/test/java/io/codemodder/plugins/maven/MavenProviderTest.java @@ -172,11 +172,11 @@ private static Stream expectedChangeDescriptionLocations() { Arguments.of(simplePom, 7), // injects all new text in one delta Arguments.of( simplePomWithExistingSections, - 16), // already has both sections, record at dependencies section + 17), // already has both sections, record at dependencies section Arguments.of( webgoatPomThatJustNeedsUpgrades, 151), // just updating the version number here in the properties - Arguments.of(webgoatPom, 413) // add to the end of the dependencies section + Arguments.of(webgoatPom, 419) // add to the end of the dependencies section ); }