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

Import-Package and other requirements not translated as Maven #71

Merged
merged 1 commit into from
Aug 30, 2022

Conversation

merks
Copy link
Contributor

@merks merks commented Jul 11, 2022

dependencies when generating pom

Reduce the number of MavenMappings.

Use the new CBI aggregators features described here to map based Maven
metadata in p2 and to build Maven dependencies from java.package
requirements:

eclipse-cbi/p2repo-aggregator#11

Disable the validation repositories because they're not needed given the
platform repository itself contains all requirements, and keeping them
also results analysis anomalies because Orbit IUs are resolved where
direct-from-Maven IUs are actually in the repository.

#67

@merks merks requested a review from mickaelistria July 11, 2022 14:12
@merks
Copy link
Contributor Author

merks commented Jul 11, 2022

Note that this requires the latest tools from https://download.eclipse.org/cbi/updates/p2-aggregator/tools/nightly/latest to try it in the IDE. Installing these will allow to edit both the resources in their structured editors:

image

I used the analyzer to ensure that every dependency maps to an artifact and that every version range resolves to an actual version that actually exists in Maven. The view gives an overview of all the generated poms. Here you can see how a package import is mapped to a dependency:

image

The log will contain information about potential problems or cases where a mapping is no longer needed.

Copy link
Contributor

@mickaelistria mickaelistria left a comment

Choose a reason for hiding this comment

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

See question inline. Overall, I'm questioning whether the fact of adding more rules is a good smell.

<mavenMappings namePattern="org.w3c.dom.events" groupId="org.eclipse.orbit.bundles" artifactId="org.w3c.dom.events"/>
<mavenMappings namePattern="org.w3c.dom.smil" groupId="org.eclipse.orbit.bundles" artifactId="org.w3c.dom.smil"/>
<mavenMappings namePattern="org.w3c.dom.svg" groupId="org.eclipse.orbit.bundles" artifactId="org.w3c.dom.svg"/>
<mavenMappings namePattern=".*" groupId="\$maven-groupId\$" artifactId="\$maven-artifactId\$" versionPattern=".*" versionTemplate="\$maven-version\$"/>
Copy link
Contributor

Choose a reason for hiding this comment

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

I would rather not having such rule explicitly defined. Is there any chance someone needs/wants to set things differently? It seems to me we don't want to offer flexibility here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I asked via email for your feedback in here but none was forthcoming:

eclipse-cbi/p2repo-aggregator#11

I think we/you can live with this explicit opt-in rule. I want to offer that flexibility to ensure that new behavior is opt-in rather than "we think this is best for you so you get it whether you want it or not."

Copy link
Contributor

Choose a reason for hiding this comment

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

"we think this is best for you so you get it whether you want it or not."

IMO, this usually results in better results. More configuration is more complexity, more room for errors; it is often less productive. I think this is the case here, and I don't see addition of this rule as an added-value over the current state (where this rule is hardcoded as default when possible) but more as an extra complication that doesn't make maintenance of this .aggr file, nor of the aggregator itself, easier.

Copy link
Contributor Author

@merks merks Jul 14, 2022

Choose a reason for hiding this comment

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

Sometimes opinions differ. This option does not and will not require further/future maintenance.

The editor offers these pre-configured (correct) mappings to enable using p2 properties and to enable java,package requirement resolution:

image

Comment on lines +61 to +58
<mavenDependencyMapping iuNamePattern="(?!.*(org\.eclipse\.)).*|org\.eclipse\.emf.*|org\.eclipse\.ecf.*|org\.eclipse\.jetty.*" namespacePattern=".*" namePattern=".*" groupId="!" artifactId="!"/>
<mavenDependencyMapping namespacePattern="java\.package" namePattern="(org.eclipse.jdt).internal.(compiler\.(apt|tool))" groupId="$1" artifactId="$1.$2"/>
<mavenDependencyMapping namespacePattern="java\.package" namePattern="(org.eclipse.jdt).internal.(compiler\.apt)\..*" groupId="$1" artifactId="$1.$2"/>
<mavenDependencyMapping namespacePattern="java\.package" namePattern="(org.eclipse.jdt)(.internal|.core)?.compiler.*" groupId="$1" artifactId="$1.core"/>
<mavenDependencyMapping namespacePattern="java\.package" namePattern=".*" groupId="*" artifactId="*" versionRangePattern="(.*)"/>
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't fully get why those parts would be necessary over what's existing.The CBI aggregator resolves a requirement to a bundle and the mavenMappings resolve those into a GAV. Why is this extra type/configuration necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This (mapping of package requirements and requirements in general) was described here:

eclipse-cbi/p2repo-aggregator#11 (comment)

But I already drew attention to that in the comment of this PR.

dependencies when generating pom

Reduce the number of MavenMappings.

Use the new CBI aggregator's features described here to map based Maven
metadata in p2 and to build Maven dependencies from java.package
requirements:

eclipse-cbi/p2repo-aggregator#11

Disable the validation repositories because they're not needed given the
platform repository itself contains all requirements, and keeping them
also results analysis anomalies because Orbit IUs are resolved where
direct-from-Maven IUs are actually in the repository.
@merks
Copy link
Contributor Author

merks commented Aug 28, 2022

@akurtakov

This version I've checked with the aggregator analysis editor that all generated Maven dependencies resolve to ones that exist in Maven. The ones that don't are marked with ** and from the wrapped search you can see only the new never-before-published-to-maven plugin is marked that way:

image

This additionally generates dependencies based on package imports which seems important given how much bundle requirements are being replaced by package imports.

Publishing should of course use the latest version of the aggregator for the package import support (as well as for the new support to use the Maven coordinates from the p2 metadata):

https://download.eclipse.org/cbi/updates/p2-aggregator/products/nightly/latest

@merks
Copy link
Contributor Author

merks commented Aug 29, 2022

@akurtakov Should I merge this now?

@akurtakov
Copy link
Member

I would defer the decision to @mickaelistria or @sravanlakkimsetti as they spent time in this cycle to investigate publishing.

@mickaelistria
Copy link
Contributor

While I have shared some concerns about the current approach compared to my "ideal" expectation, I still trust that @merks tested this well, and I reckon the current state is an improvement over current state. So I would be fine merging it if Ed is confident as well.

@merks merks merged commit b25099b into eclipse-platform:master Aug 30, 2022
@merks merks deleted the issue-11 branch August 30, 2022 06:00
@merks
Copy link
Contributor Author

merks commented Aug 31, 2022

@sravanlakkimsetti

I'd like to understand the maven publishing process better. Where can I learn more about how it works? The steps for EMF publishing to Maven are really quite complicated, and I only publish a small subset...

@mickaelistria
Copy link
Contributor

There is https://wiki.eclipse.org/Platform-releng/Publish_To_Maven_Central which is more or less up-to-date. The effective entry point is /eclipse.platform.releng/publish-to-maven-central/CBIaggregator.sh , it does contain a bit of documentation inline about the process.

@merks
Copy link
Contributor Author

merks commented Sep 1, 2022

@sravanlakkimsetti

One concern I have is with the pom enriching logic...

In particular I think this assumes that there is not already a name element.

public String toPomFragment() {
try {
fixData();
StringBuilder buf = new StringBuilder();
String indent = INDENT;
element("name", indent, buf, this.name);

That method is called from here which assumes there is necessarily a description element:

if (!detailsInserted) {
if (line.contains("</description>")) {
out.append(info.toPomFragment());
detailsInserted = true;
}
}
}

I changed the logic to properly populate the name element and the description element, but plugins generally don't generally have a description so that element would be missing. I ran into this issue publishing EMF to Maven yesterday where the final Nexus check complained about the description being missing. I modified the EMF pom enhancer to set the description to the name if the description was missing, but now I've also restored the logic in the aggregator such that if there is no description the name will be used as the description, so the aggregator produces a pom like this:

image

This is what leads me to be concerned that the current enhancer logic will create two name elements.

Note too that org.eclipse.platform.releng.maven.pom.ArtifactInfo is full of assumptions about git.eclipse.org as the SCM.

I suppose it would be better to create a new issue...

@mickaelistria
Copy link
Contributor

@merks can you please open a dedicated issue about the name/description concerns?

@merks
Copy link
Contributor Author

merks commented Sep 9, 2022

@merks can you please open a dedicated issue about the name/description concerns?

I’m out of the office the rest of the day with only my iPhone. So not until much later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants