eclipse.platform.swt icon indicating copy to clipboard operation
eclipse.platform.swt copied to clipboard

SWT pom should list its fragements as requirements

Open laeubi opened this issue 1 year ago • 11 comments

If one looks here:

https://repo1.maven.org/maven2/org/eclipse/platform/org.eclipse.swt/3.124.200/org.eclipse.swt-3.124.200.pom

the pom list a dependency to

<dependency>
   <groupId>org.eclipse.platform</groupId>
   <artifactId>org.eclipse.swt.${osgi.platform}</artifactId>
   <version>3.124.200</version>
</dependency>

while this can work if some plugin defines osgi.platform it does not work in a plain maven build.

One way would be to define all platforms inside a profile that is activated on the OS as seen here: https://github.com/jzy3d/jzy3d-api/blob/9e0f93aa958472e355b731c6ef7428088eb9c7a4/jzy3d-native-jogl-swt/pom.xml#L49-L115

laeubi avatar Jan 21 '24 12:01 laeubi

Even if I use this with Tycho maven complains:

[WARNING] The POM for org.eclipse.platform:org.eclipse.swt:jar:3.124.200 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details

laeubi avatar Jan 21 '24 13:01 laeubi

Doesn't specifying -Dosgi.platform=... would work?

merks avatar Jan 21 '24 13:01 merks

Note that this pom is generated from the p2 metadata...

merks avatar Jan 21 '24 13:01 merks

It would work of course but that's really annoying to do on every build that wants to use SWT especially as the values are not obvious to the usual user, Tycho only specify by default these properties: https://tycho.eclipseprojects.io/doc/latest/TychoProperties.html

laeubi avatar Jan 21 '24 13:01 laeubi

Doesn't specifying -Dosgi.platform=... would work?

I tried that but maven complains:

'dependencies.dependency.artifactId' for org.eclipse.platform:org.eclipse.swt.${osgi.platform}:jar with value 'org.eclipse.swt.${osgi.platform}' does not match a valid id pattern.

So it seems property expansion does not work in a consumed pom.

laeubi avatar Jan 21 '24 13:01 laeubi

This works:

image

but this fails:

image

This seems to suggest that expansion is being done as expected...

merks avatar Jan 21 '24 14:01 merks

Looking more generally in my .m2 folder, POMs like this one would not work at all without some kind of substitution kicking in:

https://repo1.maven.org/maven2/com/github/spotbugs/spotbugs-maven-plugin/4.7.3.4/spotbugs-maven-plugin-4.7.3.4.pom

It seems to me that the pom I see is often the one they are actually using to do a build...

merks avatar Jan 21 '24 14:01 merks

The difference is that the swt.pom does not define the property at all....

laeubi avatar Jan 21 '24 14:01 laeubi

That is a difference. Why does dependency:get work without a property definition? Because that's not a "consumed pom"?

merks avatar Jan 21 '24 14:01 merks

For me the definition of the property works fine (I have it in aggregatordir/.mvn/maven.config, which is automatically picked up by maven). I still believe that those poms are invalid. It's okay to have variables in the local poms, but during deployment to Maven Central those must all be resolved AFAIK.

Bananeweizen avatar Jun 24 '24 15:06 Bananeweizen

Have you ever looked at what people publish/dump to Maven central? It appears to me like it's "anything goes".

merks avatar Jun 24 '24 21:06 merks