Skip to content

Instantly share code, notes, and snippets.

@slahn
Created May 19, 2017 20:31
Show Gist options
  • Save slahn/3dbd252a179e601f53a42045bac016c7 to your computer and use it in GitHub Desktop.
Save slahn/3dbd252a179e601f53a42045bac016c7 to your computer and use it in GitHub Desktop.
SWT and JFace with Gradle and Kotlin
group 'example'
version '1.0-SNAPSHOT'
buildscript {
ext {
kotlin_version = '1.1.2-2'
osgi_platform = 'win32.win32.x86_64'
swt_version = '3.105.3'
}
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: 'java'
apply plugin: 'kotlin'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
configurations.all {
resolutionStrategy {
dependencySubstitution {
// The maven property ${osgi.platform} is not handled by Gradle
// so we replace the dependency, using the osgi platform from the project settings
substitute module('org.eclipse.platform:org.eclipse.swt.${osgi.platform}') with module("org.eclipse.platform:org.eclipse.swt.$osgi_platform:$swt_version")
}
}
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"
compile "org.eclipse.platform:org.eclipse.jface:3.12.2"
compile "org.eclipse.platform:org.eclipse.swt:$swt_version"
}
@slahn
Copy link
Author

slahn commented May 19, 2017

Note to self, next time I'm looking for info on SWT and Maven:
https://objectteams.wordpress.com/2017/01/09/eclipse-neon-2-is-on-maven-central/

@fab1an
Copy link

fab1an commented Jun 30, 2018

There is a much simple alternative to get SWT working:

dependencies {
    compile("org.eclipse.platform:org.eclipse.swt.win32.win32.x86_64:3.106.3) {
        transitive = false
    }
}

@lfarkas
Copy link

lfarkas commented Jul 10, 2019

There is a much simple alternative to get SWT working:

dependencies {
    compile("org.eclipse.platform:org.eclipse.swt.win32.win32.x86_64:3.106.3) {
        transitive = false
    }
}

for me it's not working while the first version working

@Barteks2x
Copy link

This appears to be the only sane way to also add java 9 moodules, depending directly on specific platorm doesn't really work with java module system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment