diff --git a/src/dorkbox/gradle/StaticMethodsAndTools.kt b/src/dorkbox/gradle/StaticMethodsAndTools.kt index 5bd188d..d9ab6d1 100644 --- a/src/dorkbox/gradle/StaticMethodsAndTools.kt +++ b/src/dorkbox/gradle/StaticMethodsAndTools.kt @@ -317,26 +317,23 @@ open class StaticMethodsAndTools(private val project: Project) { // org.eclipse.swt.cocoa.macosx.x86_64 val currentOS = org.gradle.internal.os.OperatingSystem.current() - val windowingTk = when { - currentOS.isWindows -> "win32" - currentOS.isMacOsX -> "cocoa" - else -> "gtk" - } - - val platform = when { - currentOS.isWindows -> "win32" - currentOS.isMacOsX -> "macosx" - else -> "linux" + val swtType = if (System.getProperty("os.arch").matches(".*64.*".toRegex())) { + when { + currentOS.isWindows -> SwtType.WIN_64 + currentOS.isMacOsX -> SwtType.MAC_64 + else -> SwtType.LINUX_64 + } + } else { + when { + currentOS.isWindows -> SwtType.WIN_32 + currentOS.isMacOsX -> SwtType.MAC_64 // not possible on mac, but here for completeness + else -> SwtType.LINUX_32 + } } - var arch = System.getProperty("os.arch") - arch = when { - arch.matches(".*64.*".toRegex()) -> "x86_64" - else -> "x86" - } + val fullId = swtType.fullId("Asd") - val mavenId = "$windowingTk.$platform.$arch" if (!fixedSWT) { fixedSWT = true @@ -348,14 +345,14 @@ open class StaticMethodsAndTools(private val project: Project) { // The maven property ${osgi.platform} is not handled by Gradle for the SWT builds // so we replace the dependency, using the osgi platform from the project settings sub.substitute(sub.module("org.eclipse.platform:org.eclipse.swt.\${osgi.platform}")) - .with(sub.module("org.eclipse.platform:org.eclipse.swt.$mavenId:$version")) + .with(sub.module(fullId)) } } } } } - return "org.eclipse.platform:org.eclipse.swt.$mavenId:$version" + return fullId } private fun idea(project: Project, configure: org.gradle.plugins.ide.idea.model.IdeaModel.() -> Unit): Unit = diff --git a/src/dorkbox/gradle/SwtType.kt b/src/dorkbox/gradle/SwtType.kt new file mode 100644 index 0000000..9ecbb3c --- /dev/null +++ b/src/dorkbox/gradle/SwtType.kt @@ -0,0 +1,30 @@ +package dorkbox.gradle + +/** + * contains the different SWT maven configurations that we support + */ +enum class SwtType(val id: String) { + // SEE: https://repo1.maven.org/maven2/org/eclipse/platform/ + + // windows + // org.eclipse.swt.win32.win32.x86 + // org.eclipse.swt.win32.win32.x86_64 + + // linux + // org.eclipse.swt.gtk.linux.x86 + // org.eclipse.swt.gtk.linux.x86_64 + + // macoxs + // org.eclipse.swt.cocoa.macosx.x86_64 + + LINUX_32("org.eclipse.swt.gtk.linux.x86"), + LINUX_64("org.eclipse.swt.gtk.linux.x86_64"), + MAC_64("org.eclipse.swt.cocoa.macosx.x86_64"), + WIN_32("org.eclipse.swt.win32.win32.x86"), + WIN_64("org.eclipse.swt.win32.win32.x86_64"); + + + fun fullId(version: String): String { + return "org.eclipse.platform:org.eclipse.swt.$id:$version" + } +}