Make gradle support SWT on Windows/Linux

This ought to make AppleCommander build properly using gradle on Windows
and Linux, and makes adding other platforms pretty easy too.
This commit is contained in:
T. Joseph Carter 2017-11-18 01:24:55 -08:00
parent 3ed8f0b974
commit 9a88c1264f

View File

@ -8,6 +8,29 @@ apply plugin: 'application'
// Define the main class for the application
mainClassName = 'com.webcodepro.applecommander.ui.AppleCommander'
// Configure build for each supported platform
def os = System.getProperty("os.name").toLowerCase()
def arch = System.getProperty("os.arch")
ext {
if (os.contains("windows")) {
swtGUI = "win32.win32.$arch"
} else if (os.contains("mac os x")) {
swtGUI = "cocoa.macosx.$arch"
} else if (os.contains("linux")) {
swtGUI = "gtk.linux.$arch"
} else {
throw new GradleException("Don't know how to build for this platform:\n" +
" os = \"$os\"\n" +
" arch = \"$arch\"\n\n" +
"Edit build.gradle to add support")
/* At least you'll need to define swtGUI for your os and
* probably your arch too. Most SWT backend GUI descriptions
* take the form of <widgetset>.<os-tag>.<arch>.
*/
}
}
// In this section you declare where to find the dependencies of your project
repositories {
mavenCentral()
@ -17,7 +40,7 @@ repositories {
}
dependencies {
compile "org.eclipse.swt:org.eclipse.swt.cocoa.macosx.x86_64:$swtVersion"
compile "org.eclipse.swt:org.eclipse.swt.$swtGUI:$swtVersion"
compileOnly "org.apache.ant:ant:$antVersion"