diff --git a/README.md b/README.md index 21fd4aa4..4823a33f 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ import java.awt.*; public class DarklafDemo { - public static void main(String[] args) { + public static void main(final String[] args) { SwingUtilities.invokeLater(() -> { LafManager.install(); @@ -80,6 +80,13 @@ property of the component. This LookAndFeel supports custom window decorations (only Windows at this point). In contrast to most other LaFs the native window behaviour is not compromised giving a seamless experience that still looks native. +# Build +To build the project replace the ````build.gradle```` script with the one +fitting your platform i.e. +- You only have a x86 cpp installation -> ````build_x86.gradle```` +- You only have a x64 cpp installation -> ````build_x64.gradle```` +- You have a 86x_64x_multilib installation -> ````build.gradle```` + # Contribute Here is a list of things that currently are not finished or need refinement. This list is a work in progress and being updated regulary. If you find any problems with the LaF feel free to submit an issue: diff --git a/build.gradle b/build.gradle index 738e977d..1438bcf9 100644 --- a/build.gradle +++ b/build.gradle @@ -18,6 +18,8 @@ if (signingKey.isEmpty()) { project.gradle.startParameter.excludedTaskNames.add('signArchives') } +project.gradle.startParameter.excludedTaskNames.add('jniplatformX86StaticLibrary') +project.gradle.startParameter.excludedTaskNames.add('jniplatformX64StaticLibrary') repositories { mavenLocal() @@ -157,17 +159,6 @@ model { tasks.publishMavenJavaPublicationToMavenRepository { dependsOn project.tasks.signArchives } -} - -println "Building on OS: " + System.properties['os.name'] -println "Using JDK: " + System.properties['java.home'] - -compileJava { - sourceCompatibility = 8 - targetCompatibility = 8 -} - -model { platforms { x86 { architecture 'x86' @@ -195,27 +186,33 @@ model { } } +println "Building on OS: " + System.properties['os.name'] +println "Using JDK: " + System.properties['java.home'] + +compileJava { + sourceCompatibility = 8 + targetCompatibility = 8 +} + tasks.withType(JavaCompile) { - dependsOn 'copyLibraries' + dependsOn 'buildLibraries' 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') - println "Copying libraries" from "${buildDir}/libs/jniplatform/shared" into "${projectDir}/src/main/resources/com/github/weisj/darklaf/platform/windows" + include "*.dll" +} + +task buildLibraries { + dependsOn('jniplatformX64SharedLibrary', 'jniplatformX86SharedLibrary') + finalizedBy(copyLibraries) } shadowJar { diff --git a/build_x64.gradle b/build_x64.gradle new file mode 100644 index 00000000..7ef410ce --- /dev/null +++ b/build_x64.gradle @@ -0,0 +1,229 @@ +import org.gradle.internal.jvm.Jvm + +plugins { + id 'com.github.johnrengelman.shadow' version '5.1.0' + id 'java' + id 'maven-publish' + id 'signing' + id 'idea' + id 'cpp' +} + +def signingKey = project.findProperty('signingKeyProp') ?: System.getenv('signingKeyProp') ?: "" +def signingPassword = project.findProperty('signingPasswordProp') ?: System.getenv('signingPasswordProp') ?: "" +def deployRepoUrl = project.findProperty('deployRepoUrlProp') ?: System.getenv('deployRepoUrlProp') ?: "" +def deployRepoUsername = project.findProperty('deployRepoUsernameProp') ?: System.getenv('deployRepoUsernameProp') ?: "" +def deployRepoPassword = project.findProperty('deployRepoPasswordProp') ?: System.getenv('deployRepoPasswordProp') ?: "" +if (signingKey.isEmpty()) { + project.gradle.startParameter.excludedTaskNames.add('signArchives') +} + +project.gradle.startParameter.excludedTaskNames.add('jniplatformStaticLibrary') + +repositories { + mavenLocal() + mavenCentral() + maven { + url = 'https://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' +} + +task sourceJar(type: Jar, dependsOn: classes) { + classifier 'sources' + from sourceSets.main.allSource +} + +artifacts { + archives jar + archives sourceJar +} + +signing { + def key = signingKey.replaceAll("#", "\n") + useInMemoryPgpKeys(key, signingPassword) + sign configurations.archives +} + +publishing { + publications { + mavenJava(MavenPublication) { + customizePom(pom) + groupId = 'com.github.weisj' + artifactId 'darklaf' + version = '1.3.1.4' + + from components.java + + // create the sign pom artifact + pom.withXml { + def pomFile = file("${project.buildDir}/generated-pom.xml") + writeTo(pomFile) + def pomAscFile = signing.sign(pomFile).signatureFiles[0] + artifact(pomAscFile) { + classifier = null + extension = 'pom.asc' + } + } + + artifact(sourceJar) { + classifier = 'sources' + } + + // create the signed artifacts + project.tasks.signArchives.signatureFiles.each { + artifact(it) { + def matcher = it.file =~ /-(sources|javadoc)\.jar\.asc$/ + if (matcher.find()) { + classifier = matcher.group(1) + } else { + classifier = null + } + extension = 'jar.asc' + } + } + } + } + repositories { + maven { + url = deployRepoUrl + credentials { + username = deployRepoUsername + password = deployRepoPassword + } + } + } +} + +def customizePom(pom) { + pom.withXml { + def root = asNode() + + // eliminate test-scoped dependencies (no need in maven central POMs) + root.dependencies.removeAll { dep -> + dep.scope == "test" + } + + // add all items necessary for maven central publication + root.children().last() + { + resolveStrategy = DELEGATE_FIRST + + description 'A themeable Look and Feel for java swing.' + name 'Darklaf' + url 'https://github.com/mautini/schemaorg-java' + organization { + name 'com.github.weisj' + url 'https://github.com/weisj' + } + issueManagement { + system 'GitHub' + url 'https://github.com/weisJ/darklaf/issues' + } + licenses { + license { + name 'MIT' + url 'https://github.com/weisJ/darklaf/blob/master/licence/LICENSE' + distribution 'repo' + } + } + scm { + url 'https://github.com/weisJ/darklaf' + connection 'scm:git:git://github.com/weisJ/darklaf.git' + developerConnection 'scm:git:ssh://git@github.com:weisj/darklaf.git' + } + developers { + developer { + name 'Jannis Weis' + } + } + } + } +} + +model { + tasks.generatePomFileForMavenJavaPublication { + destination = file("$buildDir/generated-pom.xml") + } + tasks.publishMavenJavaPublicationToMavenLocal { + dependsOn project.tasks.signArchives + } + tasks.publishMavenJavaPublicationToMavenRepository { + dependsOn project.tasks.signArchives + } + platforms { + x64 { + architecture 'x64' + } + } + components { + jniplatform(NativeLibrarySpec) { + 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 "dwmapi.lib" + linker.args "user32.lib" + linker.args "Gdi32.lib" + linker.args "-ldwmapi" + linker.args "-lGdi32" + linker.args "-luser32" + } + } + } +} + +println "Building on OS: " + System.properties['os.name'] +println "Using JDK: " + System.properties['java.home'] + +compileJava { + sourceCompatibility = 8 + targetCompatibility = 8 +} + +tasks.withType(JavaCompile) { + dependsOn 'buildLibraries' + configure(options) { + options.encoding = 'UTF-8' + options.compilerArgs += [ + '-h', file("${projectDir}/src/jniplatform/cpp"), + ] + } +} + +task copyLibraries(type: Copy) { + from "${buildDir}/libs/jniplatform/shared" + into "${projectDir}/src/main/resources/com/github/weisj/darklaf/platform/windows/x64" + include "*.dll" +} + +task buildLibraries { + dependsOn('jniplatformSharedLibrary') + finalizedBy(copyLibraries) +} + +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/' +} diff --git a/build_x86.gradle b/build_x86.gradle new file mode 100644 index 00000000..19d46fa5 --- /dev/null +++ b/build_x86.gradle @@ -0,0 +1,229 @@ +import org.gradle.internal.jvm.Jvm + +plugins { + id 'com.github.johnrengelman.shadow' version '5.1.0' + id 'java' + id 'maven-publish' + id 'signing' + id 'idea' + id 'cpp' +} + +def signingKey = project.findProperty('signingKeyProp') ?: System.getenv('signingKeyProp') ?: "" +def signingPassword = project.findProperty('signingPasswordProp') ?: System.getenv('signingPasswordProp') ?: "" +def deployRepoUrl = project.findProperty('deployRepoUrlProp') ?: System.getenv('deployRepoUrlProp') ?: "" +def deployRepoUsername = project.findProperty('deployRepoUsernameProp') ?: System.getenv('deployRepoUsernameProp') ?: "" +def deployRepoPassword = project.findProperty('deployRepoPasswordProp') ?: System.getenv('deployRepoPasswordProp') ?: "" +if (signingKey.isEmpty()) { + project.gradle.startParameter.excludedTaskNames.add('signArchives') +} + +project.gradle.startParameter.excludedTaskNames.add('jniplatformStaticLibrary') + +repositories { + mavenLocal() + mavenCentral() + maven { + url = 'https://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' +} + +task sourceJar(type: Jar, dependsOn: classes) { + classifier 'sources' + from sourceSets.main.allSource +} + +artifacts { + archives jar + archives sourceJar +} + +signing { + def key = signingKey.replaceAll("#", "\n") + useInMemoryPgpKeys(key, signingPassword) + sign configurations.archives +} + +publishing { + publications { + mavenJava(MavenPublication) { + customizePom(pom) + groupId = 'com.github.weisj' + artifactId 'darklaf' + version = '1.3.1.4' + + from components.java + + // create the sign pom artifact + pom.withXml { + def pomFile = file("${project.buildDir}/generated-pom.xml") + writeTo(pomFile) + def pomAscFile = signing.sign(pomFile).signatureFiles[0] + artifact(pomAscFile) { + classifier = null + extension = 'pom.asc' + } + } + + artifact(sourceJar) { + classifier = 'sources' + } + + // create the signed artifacts + project.tasks.signArchives.signatureFiles.each { + artifact(it) { + def matcher = it.file =~ /-(sources|javadoc)\.jar\.asc$/ + if (matcher.find()) { + classifier = matcher.group(1) + } else { + classifier = null + } + extension = 'jar.asc' + } + } + } + } + repositories { + maven { + url = deployRepoUrl + credentials { + username = deployRepoUsername + password = deployRepoPassword + } + } + } +} + +def customizePom(pom) { + pom.withXml { + def root = asNode() + + // eliminate test-scoped dependencies (no need in maven central POMs) + root.dependencies.removeAll { dep -> + dep.scope == "test" + } + + // add all items necessary for maven central publication + root.children().last() + { + resolveStrategy = DELEGATE_FIRST + + description 'A themeable Look and Feel for java swing.' + name 'Darklaf' + url 'https://github.com/mautini/schemaorg-java' + organization { + name 'com.github.weisj' + url 'https://github.com/weisj' + } + issueManagement { + system 'GitHub' + url 'https://github.com/weisJ/darklaf/issues' + } + licenses { + license { + name 'MIT' + url 'https://github.com/weisJ/darklaf/blob/master/licence/LICENSE' + distribution 'repo' + } + } + scm { + url 'https://github.com/weisJ/darklaf' + connection 'scm:git:git://github.com/weisJ/darklaf.git' + developerConnection 'scm:git:ssh://git@github.com:weisj/darklaf.git' + } + developers { + developer { + name 'Jannis Weis' + } + } + } + } +} + +model { + tasks.generatePomFileForMavenJavaPublication { + destination = file("$buildDir/generated-pom.xml") + } + tasks.publishMavenJavaPublicationToMavenLocal { + dependsOn project.tasks.signArchives + } + tasks.publishMavenJavaPublicationToMavenRepository { + dependsOn project.tasks.signArchives + } + platforms { + x86 { + architecture 'x86' + } + } + components { + jniplatform(NativeLibrarySpec) { + targetPlatform "x86" + binaries.all { + cppCompiler.args "-I${Jvm.current().javaHome}/include" + cppCompiler.args "-I${Jvm.current().javaHome}/include/win32" + cppCompiler.args "-std=c++11" + linker.args "dwmapi.lib" + linker.args "user32.lib" + linker.args "Gdi32.lib" + linker.args "-ldwmapi" + linker.args "-lGdi32" + linker.args "-luser32" + } + } + } +} + +println "Building on OS: " + System.properties['os.name'] +println "Using JDK: " + System.properties['java.home'] + +compileJava { + sourceCompatibility = 8 + targetCompatibility = 8 +} + +tasks.withType(JavaCompile) { + dependsOn 'buildLibraries' + configure(options) { + options.encoding = 'UTF-8' + options.compilerArgs += [ + '-h', file("${projectDir}/src/jniplatform/cpp"), + ] + } +} + +task copyLibraries(type: Copy) { + from "${buildDir}/libs/jniplatform/shared" + into "${projectDir}/src/main/resources/com/github/weisj/darklaf/platform/windows/x86" + include "*.dll" +} + +task buildLibraries { + dependsOn('jniplatformSharedLibrary') + finalizedBy(copyLibraries) +} + +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/' +} diff --git a/src/main/resources/com/github/weisj/darklaf/platform/windows/x64/jniplatform.dll b/src/main/resources/com/github/weisj/darklaf/platform/windows/x64/jniplatform.dll index 7db8238b..1f5a6dad 100644 Binary files a/src/main/resources/com/github/weisj/darklaf/platform/windows/x64/jniplatform.dll and b/src/main/resources/com/github/weisj/darklaf/platform/windows/x64/jniplatform.dll differ diff --git a/src/main/resources/com/github/weisj/darklaf/platform/windows/x64/jniplatform.exp b/src/main/resources/com/github/weisj/darklaf/platform/windows/x64/jniplatform.exp deleted file mode 100644 index dab615f9..00000000 Binary files a/src/main/resources/com/github/weisj/darklaf/platform/windows/x64/jniplatform.exp and /dev/null differ diff --git a/src/main/resources/com/github/weisj/darklaf/platform/windows/x64/jniplatform.lib b/src/main/resources/com/github/weisj/darklaf/platform/windows/x64/jniplatform.lib deleted file mode 100644 index a507748b..00000000 Binary files a/src/main/resources/com/github/weisj/darklaf/platform/windows/x64/jniplatform.lib and /dev/null differ diff --git a/src/main/resources/com/github/weisj/darklaf/platform/windows/x86/jniplatform.dll b/src/main/resources/com/github/weisj/darklaf/platform/windows/x86/jniplatform.dll index fc709b40..8656ba2f 100644 Binary files a/src/main/resources/com/github/weisj/darklaf/platform/windows/x86/jniplatform.dll and b/src/main/resources/com/github/weisj/darklaf/platform/windows/x86/jniplatform.dll differ diff --git a/src/main/resources/com/github/weisj/darklaf/platform/windows/x86/jniplatform.exp b/src/main/resources/com/github/weisj/darklaf/platform/windows/x86/jniplatform.exp deleted file mode 100644 index cb81aff4..00000000 Binary files a/src/main/resources/com/github/weisj/darklaf/platform/windows/x86/jniplatform.exp and /dev/null differ diff --git a/src/main/resources/com/github/weisj/darklaf/platform/windows/x86/jniplatform.lib b/src/main/resources/com/github/weisj/darklaf/platform/windows/x86/jniplatform.lib deleted file mode 100644 index 32e8fec8..00000000 Binary files a/src/main/resources/com/github/weisj/darklaf/platform/windows/x86/jniplatform.lib and /dev/null differ