import org.gradle.internal.jvm.Jvm plugins { id 'com.github.johnrengelman.shadow' version '5.1.0' id 'java' id 'maven-publish' id 'idea' id 'cpp' } repositories { mavenLocal() mavenCentral() maven { url = 'http://repo.maven.apache.org/maven2' } } dependencies { compile 'com.metsci.ext.com.kitfox.svg:svg-salamander:[0.1.19,)' compile 'org.jetbrains:annotations:16.0.1' compile 'net.java.dev.jna:jna:4.1.0' compile 'org.swinglabs:jxlayer:3.0.4' compileOnly 'org.swinglabs:swingx:1.6.1' testCompile 'org.swinglabs:swingx:1.6.1' } group = 'com.weis' version = '1.0-SNAPSHOT' println "Building on OS: " + System.properties['os.name'] println "Using JDK: " + System.properties['java.home'] model { platforms { x86 { architecture 'x86' } x64 { architecture 'x86_64' } } } compileJava { sourceCompatibility = 11 targetCompatibility = 11 } model { components { jniplatform(NativeLibrarySpec) { targetPlatform "x86" targetPlatform "x64" binaries.all { cppCompiler.args "-I${Jvm.current().javaHome}/include" cppCompiler.args "-I${Jvm.current().javaHome}/include/win32" cppCompiler.args "-std=c++11" linker.args "-ldwmapi" linker.args "-lGdi32" } } } } publishing { publications { maven(MavenPublication) { from(components.java) } } } tasks.withType(JavaCompile) { dependsOn 'copyLibraries' configure(options) { options.encoding = 'UTF-8' options.compilerArgs += [ '-h', file("${projectDir}/src/jniplatform/cpp"), ] options.compilerArgs += [ '--add-exports=java.desktop/sun.awt=ALL-UNNAMED', '--add-exports=java.desktop/com.sun.java.swing=ALL-UNNAMED', '--add-exports=java.desktop/sun.swing=ALL-UNNAMED', '--add-exports=java.desktop/sun.awt.shell=ALL-UNNAMED' ] } } task copyLibraries(type: Copy) { dependsOn('jniplatformX64SharedLibrary', 'jniplatformX86SharedLibrary') from "${buildDir}/libs/jniplatform/shared" into "${projectDir}/src/main/resources/library" } shadowJar { exclude 'help/' exclude 'icons/' exclude 'org/jdesktop/jxlayer/plaf/ext/images/' exclude 'com/sun/jna/darwin/' exclude 'com/sun/jna/freebsd-x86/' exclude 'com/sun/jna/freebsd-x86-64/' exclude 'com/sun/jna/linux-arm/' exclude 'com/sun/jna/linux-x86/' exclude 'com/sun/jna/linux-x86-64/' exclude 'com/sun/jna/openbsd-x86/' exclude 'com/sun/jna/openbsd-x86-64/' exclude 'com/sun/jna/sunos-sparc/' exclude 'com/sun/jna/sunos-sparcv9/' exclude 'com/sun/jna/sunos-x86/' exclude 'com/sun/jna/sunos-x86-64/' minimize() }