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:
parent
3ed8f0b974
commit
9a88c1264f
29
build.gradle
29
build.gradle
|
@ -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,8 +40,8 @@ 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"
|
||||
|
||||
testCompile "junit:junit:$junitVersion"
|
||||
|
@ -27,7 +50,7 @@ dependencies {
|
|||
jar {
|
||||
manifest {
|
||||
attributes 'Main-Class': "$mainClassName"
|
||||
}
|
||||
}
|
||||
doFirst {
|
||||
from { configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) } }
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue