Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove custom XPath logic from PluginRemoting #442

Merged
merged 1 commit into from
Feb 7, 2023
Merged

Remove custom XPath logic from PluginRemoting #442

merged 1 commit into from
Feb 7, 2023

Conversation

basil
Copy link
Member

@basil basil commented Feb 7, 2023

Fixes #426 by replacing all the custom XPath logic in PluginRemoting with a few lines to delegate to MavenXpp3Reader which is already on our class path and already knows how to parse Maven pom.xml files. To test this I ran the full jenkinsci/bom test suite.

basil added a commit to basil/bom that referenced this pull request Feb 7, 2023
@basil basil requested a review from jtnord February 7, 2023 06:02
@basil basil marked this pull request as ready for review February 7, 2023 06:02
@basil basil requested a review from a team as a code owner February 7, 2023 06:02
Comment on lines -189 to -190
// Trimming url
transformedConnectionUrl = transformedConnectionUrl.trim();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whatever

Comment on lines -192 to -207
// Generally, when connectionUrl is empty, is implies it is declared in a parent pom
// => Only possibility is to deduct github repository from artifactId (crossing fingers it
// is not a bizarre repository url...)
String oldUrl = transformedConnectionUrl;
if (transformedConnectionUrl.isEmpty()) {
transformedConnectionUrl =
"scm:git:git://github.com/jenkinsci/"
+ pomData.artifactId.replaceAll("jenkins", "")
+ "-plugin.git";
if (!oldUrl.equals(transformedConnectionUrl)) {
LOGGER.log(
Level.WARNING,
"project.scm.connectionUrl is not present in plugin's pom .. isn't it"
+ " residing somewhere on a parent pom ?");
}
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is actually a problem the solution is to update the parent POM to read <scm child.scm.connection.inherit.append.path="false" child.scm.developerConnection.inherit.append.path="false" child.scm.url.inherit.append.path="false"> per our archetype.

Comment on lines -209 to -220
// Java.net SVN migration
oldUrl = transformedConnectionUrl;
transformedConnectionUrl =
transformedConnectionUrl.replaceAll(
"(svn|hudson)\\.dev\\.java\\.net/svn/hudson/",
"svn.java.net/svn/hudson~svn/");
if (!oldUrl.equals(transformedConnectionUrl)) {
LOGGER.log(
Level.WARNING,
"project.scm.connectionUrl is pointing to svn.dev.java.net/svn/hudson/ instead"
+ " of svn.java.net/svn/hudson~svn/");
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This migration happened a decade ago.

Comment on lines -222 to -225
// ${project.artifactId}
transformedConnectionUrl =
transformedConnectionUrl.replaceAll(
"\\$\\{project\\.artifactId\\}", pomData.artifactId);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't seen a POM like this in years and Maven 4 actually won't accept it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the repository and pluginsRepository section - not for scm? (not that it matters here - but if you we are no longer able to use properties in an SCM connection there are a lot of plugins that need to be fixed for maven 4.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw it at least for dependencies.dependency.groupId in JENKINS-70478.

Comment on lines -237 to -249
// Convert things like
// scm:git:git://git@github.com:jenkinsci/dockerhub-notification-plugin.git
oldUrl = transformedConnectionUrl;
transformedConnectionUrl =
transformedConnectionUrl.replaceAll(
"scm:git:git://git@github\\.com:jenkinsci",
"scm:git:git://github.com/jenkinsci");
if (!oldUrl.equals(transformedConnectionUrl)) {
LOGGER.log(
Level.WARNING,
"project.scm.connectionUrl should should be accessed in read-only mode (with"
+ " git:// protocol)");
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have spent months fixing up cases like this and I think most of the fixes have been released. If not then they should be, there is no reason to keep working around this in higher-level code.

Comment on lines -251 to -258
oldUrl = transformedConnectionUrl;
transformedConnectionUrl =
transformedConnectionUrl.replaceAll("://github\\.com[^/]", "://github.com/");
if (!oldUrl.equals(transformedConnectionUrl)) {
LOGGER.log(
Level.WARNING,
"project.scm.connectionUrl should have a '/' after the github.com url");
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again why not just fix the root cause of the problem.

"project.scm.connectionUrl should not reference hudson project anymore (no"
+ " plugin repository there))");
} catch (IOException e) {
throw new UncheckedIOException(e);
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hudson has long been dead.

model.getParent().getArtifactId(),
model.getParent().getVersion());
} else {
parent = null;
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd wager this was fixed years ago.

Copy link
Member

@jtnord jtnord left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks ok pending downstream testing

Comment on lines -222 to -225
// ${project.artifactId}
transformedConnectionUrl =
transformedConnectionUrl.replaceAll(
"\\$\\{project\\.artifactId\\}", pomData.artifactId);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the repository and pluginsRepository section - not for scm? (not that it matters here - but if you we are no longer able to use properties in an SCM connection there are a lot of plugins that need to be fixed for maven 4.

@basil basil merged commit 99ba2aa into master Feb 7, 2023
@basil basil deleted the xpath branch February 7, 2023 15:58
jtnord added a commit to jtnord/plugin-compat-tester that referenced this pull request Feb 8, 2023
ammend jenkinsci#442 to allow use of project.artifactId and artifactId as
properties inside the SCM section

testing a project with maven 4.0.0-alpha4 showed no warnings or errors
about this use case, and we have many plugins that use it.

Whilst fixing all the plugin is nobale - that would unessescarily hold
up future improvements.
@jtnord jtnord mentioned this pull request Feb 8, 2023
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove custom XPath logic from PluginRemoting
3 participants