eclipse-platform / eclipse.platform.swt

Eclipse SWT
https://www.eclipse.org/swt/
Eclipse Public License 2.0
118 stars 137 forks source link

SWT pom should list its fragements as requirements #992

Open laeubi opened 9 months ago

laeubi commented 9 months ago

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 commented 9 months ago

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

merks commented 9 months ago

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

merks commented 9 months ago

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

laeubi commented 9 months ago

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 commented 9 months ago

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.

merks commented 9 months ago

This works:

image

but this fails:

image

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

merks commented 9 months ago

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...

laeubi commented 9 months ago

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

merks commented 9 months ago

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

Bananeweizen commented 4 months ago

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.

merks commented 4 months ago

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