Closed harmanea closed 4 years ago
manually specify the platform I want to build for
Here's how we do that for durian-swt:
Hey cool! Sorry this is a bit OT but ive just recently been rx-ing my Java and have been on the lookout. I Will need to look more into durian for sure!
Thanks for the link. I used it as a hint to write my own solution (some parts omitted for brevity):
plugins {
id 'java'
id 'com.diffplug.gradle.eclipse.mavencentral' version '3.17.7'
...
}
ext.swtRelease = project.properties['swtRelease'] ?: '4.12.0'
ext.swtPlatform = project.properties['swtPlatform'] ?: 'gtk.linux.x86_64'
eclipseMavenCentral {
release "$swtRelease", {
implementation 'org.eclipse.swt'
implementation 'org.eclipse.jface'
}
}
repositories {
mavenCentral()
...
}
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
if (details.requested.name.contains('${osgi.platform}')) {
details.useTarget(details.requested.group + ':' + details.requested.name.replace('${osgi.platform}', "$swtPlatform") + ':' + details.requested.version)
}
}
}
dependencies {
...
}
task fatJar(type: Jar) {
exclude 'META-INF/*.RSA', 'META-INF/*.SF','META-INF/*.DSA'
manifest {
attributes(
...
)
}
appendix = "$swtPlatform"
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}
Everything now works when running locally and I can call gradle -PswtRelease=<release> -PswtPlatform=<platform> fatJar
to build with the given swt platform and release. I call this in a shell script loop for the required combinations.
Let me know if this can be done in a simpler way. Otherwise feel free to close this. Thank you!
I think that's a great way, thanks for sharing it.
I'm using the
eclipseMavenCentral
plugin to declare swt dependencies. UsinguseNativesForRunningPlatform
works like a charm but I was wondering if there is a way to manually specify the platform I want to build for. Ideally I'd like to end up with a script that builds an executable jar for each swt-compatible platform and packages everything correctly.Is something like that possible with this awesome plugin?