Browse Source

Split projects, migrate to Kotlin DSL

pull/33/head v1.3.3.4-rc2
Vladimir Sitnikov 5 years ago
parent
commit
3ae99e44fc
  1. 29
      .editorconfig
  2. 15
      .gitignore
  3. 273
      build.gradle
  4. 294
      build.gradle.kts
  5. 3
      buildSrc/.gitattributes
  6. 16
      buildSrc/build.gradle.kts
  7. 0
      buildSrc/settings.gradle.kts
  8. 86
      buildSrc/src/main/kotlin/jni-library.gradle.kts
  9. 267
      build_x64.gradle
  10. 267
      build_x86.gradle
  11. 37
      dependencies-bom/build.gradle.kts
  12. 21
      gradle.properties
  13. BIN
      gradle/wrapper/gradle-wrapper.jar
  14. 11
      gradle/wrapper/gradle-wrapper.properties
  15. 29
      gradlew
  16. 21
      licenses/NATIVEUTIL_LICENSE.txt
  17. 12
      native-utils/build.gradle.kts
  18. 2
      native-utils/src/main/java/com/github/weisj/darklaf/platform/NativeUtil.java
  19. 19
      native-utils/src/main/java/com/github/weisj/darklaf/platform/SystemInfo.java
  20. 1
      settings.gradle
  21. 29
      settings.gradle.kts
  22. 77
      src/jniplatform/cpp/com_github_weisj_darklaf_platform_windows_JNIDecorations.h
  23. 2
      src/main/java/com/github/weisj/darklaf/DarkLaf.java
  24. 2
      src/main/java/com/github/weisj/darklaf/theme/IntelliJTheme.java
  25. 2
      src/main/java/com/github/weisj/darklaf/theme/Theme.java
  26. 2
      src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonUI.java
  27. 2
      src/main/java/com/github/weisj/darklaf/ui/checkbox/DarkCheckBoxBorder.java
  28. 2
      src/main/java/com/github/weisj/darklaf/ui/radiobutton/DarkRadioButtonBorder.java
  29. 2
      src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeUI.java
  30. 51
      src/main/java/com/github/weisj/darklaf/util/StringUtil.java
  31. 2
      src/test/java/theme/MyCustomTheme.java
  32. 33
      windows/build.gradle.kts
  33. 0
      windows/src/main/cpp/JNIDecorations.cpp
  34. 0
      windows/src/main/cpp/JNIDecorations.h
  35. 13
      windows/src/main/java/com/github/weisj/darklaf/platform/windows/JNIDecorations.java

29
.editorconfig

@ -0,0 +1,29 @@
root = true
[*]
trim_trailing_whitespace = true
insert_final_newline = true
charset = utf-8
indent_style = space
[*.md]
indent_size = 4
trim_trailing_whitespace = false
[{*.sh,gradlew}]
end_of_line = lf
[{*.bat,*.cmd}]
end_of_line = crlf
[{*.kts,*.kt}]
ij_kotlin_code_style_defaults = KOTLIN_OFFICIAL
ij_kotlin_name_count_to_use_star_import = 999
ij_kotlin_name_count_to_use_star_import_for_members = 999
[*.java]
# Doc: https://youtrack.jetbrains.com/issue/IDEA-170643#focus=streamItem-27-3708697.0-0
#"static ", "java.", "org.javacc.", ""
#ij_java_imports_layout = $*,|,java.**,|,org.javacc.**,|,*
#ij_java_use_single_class_imports = true
indent_size = 4

15
.gitignore vendored

@ -21,7 +21,9 @@ repo/
# intelliJ
.idea/
out/
/out/
/buildSrc/out/
/*/out/
# VS Code
.vscode/
@ -30,9 +32,10 @@ out/
target/
# gradle
/build
/.gradle
gradle.properties
/.gradle/
/build/
/buildSrc/.gradle/
/*/build/
# Python
venv/
@ -46,4 +49,6 @@ Thumbs.db
/key.gpg
# Project
bin/
/bin/
/buildSrc/bin/
/*/bin/

273
build.gradle

@ -1,273 +0,0 @@
import org.gradle.internal.jvm.Jvm
import org.apache.tools.ant.taskdefs.condition.Os
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') ?: "") as String
def signingPassword = (project.findProperty('signingPasswordProp')
?: System.getenv('signingPasswordProp') ?: "") as String
def deployRepoUrl = (project.findProperty('deployRepoUrlProp')
?: System.getenv('deployRepoUrlProp') ?: "") as String
def deployRepoUsername =( project.findProperty('deployRepoUsernameProp')
?: System.getenv('deployRepoUsernameProp') ?: "") as String
def deployRepoPassword = (project.findProperty('deployRepoPasswordProp')
?: System.getenv('deployRepoPasswordProp') ?: "") as String
if (signingKey.isEmpty()) {
project.gradle.startParameter.excludedTaskNames.add('signArchives')
}
project.gradle.startParameter.excludedTaskNames.add('jniplatformX86StaticLibrary')
project.gradle.startParameter.excludedTaskNames.add('jniplatformX64StaticLibrary')
if (!Os.is(Os.FAMILY_WINDOWS)) {
project.gradle.startParameter.excludedTaskNames.add('jniplatformX86SharedLibrary')
project.gradle.startParameter.excludedTaskNames.add('jniplatformX64SharedLibrary')
}
repositories {
mavenLocal()
mavenCentral()
maven {
url = 'https://repo.maven.apache.org/maven2'
}
}
dependencies {
compile 'com.formdev:svgSalamander:1.1.2.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
}
task packageJavadoc(type: Jar) {
classifier 'javadoc'
from javadoc
}
javadoc {
if (JavaVersion.current().isJava9Compatible()) {
options.addStringOption('-add-exports java.desktop/sun.swing=ALL-UNNAMED ' +
'--add-exports java.desktop/sun.awt=ALL-UNNAMED ' +
'--add-exports java.desktop/com.sun.java.swing=ALL-UNNAMED ' +
'--add-exports java.desktop/sun.awt.shell=ALL-UNNAMED', '-quiet')
}
}
artifacts {
archives jar
archives sourceJar
archives packageJavadoc
}
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.3.4'
from components.java
// create the sign pom artifact
pom.withXml {
def pomFile = file("${project.buildDir}/generated-pom.xml")
def projectPom = file("pom.xml")
writeTo(pomFile)
writeTo(projectPom)
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'
}
x64 {
architecture 'x64'
}
}
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 "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) {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
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"
include "*/*.dll"
}
task buildLibraries {
dependsOn('jniplatformX64SharedLibrary', 'jniplatformX86SharedLibrary')
finalizedBy(copyLibraries)
}
tasks.withType(Jar) {
from(project.projectDir) {
include("LICENSE")
into("META-INF/license")
}
from("${project.projectDir}/licenses") {
include("*")
into("META-INF/license")
}
}
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/'
}

294
build.gradle.kts

@ -0,0 +1,294 @@
import com.github.vlsi.gradle.crlf.CrLfSpec
import com.github.vlsi.gradle.crlf.LineEndings
import com.github.vlsi.gradle.properties.dsl.props
plugins {
`java-library`
id("com.github.johnrengelman.shadow")
id("com.github.vlsi.crlf")
id("com.github.vlsi.gradle-extensions")
id("com.github.vlsi.stage-vote-release")
}
val skipJavadoc by props()
val enableMavenLocal by props()
val enableGradleMetadata by props()
val String.v: String get() = rootProject.extra["$this.version"] as String
val buildVersion = "darklaf".v + releaseParams.snapshotSuffix
println("Building Darklaf $buildVersion")
println(" JDK: " + System.getProperty("java.home"))
releaseParams {
tlp.set("darklaf")
organizationName.set("weisJ")
componentName.set("darklaf")
prefixForProperties.set("gh")
svnDistEnabled.set(false)
sitePreviewEnabled.set(false)
nexus {
mavenCentral()
}
voteText.set {
"""
${it.componentName} v${it.version}-rc${it.rc} is ready for preview.
Git SHA: ${it.gitSha}
Staging repository: ${it.nexusRepositoryUri}
""".trimIndent()
}
}
allprojects {
group = "com.github.weisj"
version = buildVersion
repositories {
if (enableMavenLocal) {
mavenLocal()
}
mavenCentral()
}
tasks.withType<AbstractArchiveTask>().configureEach {
// Ensure builds are reproducible
isPreserveFileTimestamps = false
isReproducibleFileOrder = true
dirMode = "775".toInt(8)
fileMode = "664".toInt(8)
}
plugins.withType<JavaLibraryPlugin> {
dependencies {
// cpp-library is not compatible with java-library
// they both use api and implementation configurations
val bom = platform(project(":darklaf-dependencies-bom"))
if (!plugins.hasPlugin("cpp-library")) {
api(bom)
} else {
// cpp-library does not know these configurations, so they are for Java
compileOnly(bom)
runtimeOnly(bom)
}
}
}
plugins.withId("cpp-library") {
tasks.withType<PublishToMavenRepository>()
.matching {
it.name.startsWith("publishMain") ||
it.name.startsWith("signMain") ||
it.name.startsWith("generatePomFileForMain") ||
it.name.startsWith("generateMetadataFileForMain")
}
.configureEach {
// We don't need to publish CPP artifacts (e.g. header files)
enabled = false
}
}
if (!enableGradleMetadata) {
tasks.withType<GenerateModuleMetadata> {
enabled = false
}
}
plugins.withType<JavaPlugin> {
configure<JavaPluginExtension> {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
withSourcesJar()
if (!skipJavadoc) {
withJavadocJar()
}
}
apply(plugin = "maven-publish")
tasks {
withType<JavaCompile>().configureEach {
options.encoding = "UTF-8"
}
withType<Jar>().configureEach {
manifest {
attributes["Bundle-License"] = "MIT"
attributes["Implementation-Title"] = project.name
attributes["Implementation-Version"] = project.version
attributes["Specification-Vendor"] = "Darklaf"
attributes["Specification-Version"] = project.version
attributes["Specification-Title"] = "Darklaf"
attributes["Implementation-Vendor"] = "Darklaf"
attributes["Implementation-Vendor-Id"] = "com.github.weisj"
}
CrLfSpec(LineEndings.LF).run {
into("META-INF") {
filteringCharset = "UTF-8"
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
// This includes either project-specific license or a default one
if (file("$projectDir/LICENSE").exists()) {
textFrom("$projectDir/LICENSE")
} else {
textFrom("$rootDir/LICENSE")
}
}
}
}
withType<Javadoc>().configureEach {
(options as StandardJavadocDocletOptions).apply {
// -add-exports requires target 9
// The library is built with target=1.8, so add-exports
if (project.the<JavaPluginExtension>().targetCompatibility.isJava9Compatible) {
addStringOption("-add-exports", "java.desktop/sun.swing=ALL-UNNAMED")
addStringOption("-add-exports", "java.desktop/sun.awt=ALL-UNNAMED")
addStringOption("-add-exports", "java.desktop/com.sun.java.swing=ALL-UNNAMED")
addStringOption("-add-exports", "java.desktop/sun.awt.shell=ALL-UNNAMED")
}
quiet()
locale = "en"
docEncoding = "UTF-8"
charSet = "UTF-8"
encoding = "UTF-8"
docTitle = "Darklaf ${project.name} API"
windowTitle = "Darklaf ${project.name} API"
header = "<b>Darklaf</b>"
addBooleanOption("Xdoclint:none", true)
addStringOption("source", "8")
if (JavaVersion.current().isJava9Compatible) {
addBooleanOption("html5", true)
links("https://docs.oracle.com/javase/9/docs/api/")
} else {
links("https://docs.oracle.com/javase/8/docs/api/")
}
}
}
}
configure<PublishingExtension> {
if (project.path.startsWith(":darklaf-dependencies-bom")) {
// We don't it to Central for now
return@configure
}
publications {
create<MavenPublication>(project.name) {
artifactId = project.name
version = rootProject.version.toString()
description = project.description
from(project.components.get("java"))
}
withType<MavenPublication> {
// Use the resolved versions in pom.xml
// Gradle might have different resolution rules, so we set the versions
// that were used in Gradle build/test.
versionMapping {
usage(Usage.JAVA_RUNTIME) {
fromResolutionResult()
}
usage(Usage.JAVA_API) {
fromResolutionOf("runtimeClasspath")
}
}
pom {
withXml {
val sb = asString()
var s = sb.toString()
// <scope>compile</scope> is Maven default, so delete it
s = s.replace("<scope>compile</scope>", "")
// Cut <dependencyManagement> because all dependencies have the resolved versions
s = s.replace(
Regex(
"<dependencyManagement>.*?</dependencyManagement>",
RegexOption.DOT_MATCHES_ALL
),
""
)
sb.setLength(0)
sb.append(s)
// Re-format the XML
asNode()
}
description.set(
project.description
?: "A themeable Look and Feel for java swing"
)
name.set(
(project.findProperty("artifact.name") as? String)
?: project.name.capitalize().replace("-", " ")
)
url.set("https://github.com/weisJ/darklaf")
organization {
name.set("com.github.weisj")
url.set("https://github.com/weisj")
}
issueManagement {
system.set("GitHub")
url.set("https://github.com/weisJ/darklaf/issues")
}
licenses {
license {
name.set("MIT")
url.set("https://github.com/weisJ/darklaf/blob/master/LICENSE")
distribution.set("repo")
}
}
scm {
url.set("https://github.com/weisJ/darklaf")
connection.set("scm:git:git://github.com/weisJ/darklaf.git")
developerConnection.set("scm:git:ssh://git@github.com:weisj/darklaf.git")
}
developers {
developer {
name.set("Jannis Weis")
}
}
}
}
}
}
}
}
dependencies {
implementation(project(":darklaf-native-utils"))
implementation(project(":darklaf-windows"))
implementation("com.formdev:svgSalamander")
implementation("net.java.dev.jna:jna")
implementation("org.swinglabs:jxlayer")
compileOnly("org.swinglabs:swingx")
testImplementation("org.swinglabs:swingx")
}
tasks.jar {
CrLfSpec(LineEndings.LF).run {
into("META-INF") {
filteringCharset = "UTF-8"
textFrom("licenses/NOTICE.txt")
textFrom("licenses/PBJAR_LICENSE.txt")
textFrom("licenses/INTELLIJ_LICENSE.txt")
}
}
}
tasks.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/")
}

3
buildSrc/.gitattributes vendored

@ -0,0 +1,3 @@
# For some reason Gradle requires LF eol for precompiled script plugins
# Otherwise buildSrc compilation fails on Windows
/src/main/kotlin/**/*.gradle.kts text eol=lf

16
buildSrc/build.gradle.kts

@ -0,0 +1,16 @@
plugins {
`kotlin-dsl`
}
dependencies {
implementation(kotlin("gradle-plugin"))
}
repositories {
mavenCentral()
gradlePluginPortal()
}
configure<KotlinDslPluginOptions> {
experimentalWarning.set(false)
}

0
buildSrc/settings.gradle.kts

86
buildSrc/src/main/kotlin/jni-library.gradle.kts

@ -0,0 +1,86 @@
import org.gradle.internal.jvm.Jvm
plugins {
`cpp-library`
`java-library`
}
// This configuration might be used for adding cpp-only dependencies
val jniImplementation by configurations.creating
configurations.matching {
it.name.startsWith("cppCompile") ||
it.name.startsWith("nativeLink") ||
it.name.startsWith("nativeRuntime")
}.all {
extendsFrom(jniImplementation)
}
tasks.compileJava {
options.headerOutputDirectory.convention(
project.layout.buildDirectory.dir("generated/jni-headers")
)
// The nested output is not marked automatically as an output of the task regarding task dependencies.
// So we mark it manually here.
// See https://github.com/gradle/gradle/issues/6619.
outputs.dir(options.headerOutputDirectory);
// Cannot do incremental header generation, since the pattern for cleaning them up is currently wrong.
// See https://github.com/gradle/gradle/issues/12084.
options.isIncremental = false;
}
tasks.withType<CppCompile>().configureEach {
includes(tasks.compileJava.flatMap { it.options.headerOutputDirectory })
}
library {
binaries.configureEach {
val targetOs = targetMachine.operatingSystemFamily
compileTask.get().apply {
val javaHome = Jvm.current().javaHome.canonicalPath
includes("$javaHome/include")
includes(when {
targetOs.isMacOs -> listOf("$javaHome/include/darwin")
targetOs.isLinux -> listOf("$javaHome/include/linux")
targetOs.isWindows -> listOf("$javaHome/include/win32")
else -> emptyList()
})
}
}
}
/**
* Gradle does not support [Provider] for [JavaForkOptions.systemProperty], so
* we pass an object that overrides [Any.toString].
*/
fun Provider<String>.overrideToString() = object {
override fun toString() = orNull ?: ""
}
// Gradle populates library.binaries in afterEvaluate, so we can't access it earlier
afterEvaluate {
// C++ library is built for Windows only, so we skip it otherwise
library.developmentBinary.orNull?.let { it as CppSharedLibrary }?.let { developmentBinary ->
tasks.test {
dependsOn(developmentBinary.linkTask)
val libraryDir = developmentBinary.runtimeFile
.map { it.asFile.parentFile.absolutePath }
systemProperty("java.library.path", libraryDir.overrideToString())
}
}
tasks.jar {
// Publish non-optimized, debuggable binary to simplify analysis in case of crashes
library.binaries.get()
.filter { it.isDebuggable && !it.isOptimized }
.filterIsInstance<CppSharedLibrary>()
.forEach { binary ->
dependsOn(binary.linkTask)
val variantName = binary.targetMachine.let {
"${it.operatingSystemFamily}-${it.architecture}"
}
into("com/github/weisj/darklaf/platform/${project.name}/$variantName") {
from(binary.runtimeFile)
}
}
}
}

267
build_x64.gradle

@ -1,267 +0,0 @@
import org.gradle.internal.jvm.Jvm
import org.apache.tools.ant.taskdefs.condition.Os
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') ?: "") as String
def signingPassword = (project.findProperty('signingPasswordProp')
?: System.getenv('signingPasswordProp') ?: "") as String
def deployRepoUrl = (project.findProperty('deployRepoUrlProp')
?: System.getenv('deployRepoUrlProp') ?: "") as String
def deployRepoUsername =( project.findProperty('deployRepoUsernameProp')
?: System.getenv('deployRepoUsernameProp') ?: "") as String
def deployRepoPassword = (project.findProperty('deployRepoPasswordProp')
?: System.getenv('deployRepoPasswordProp') ?: "") as String
if (signingKey.isEmpty()) {
project.gradle.startParameter.excludedTaskNames.add('signArchives')
}
project.gradle.startParameter.excludedTaskNames.add('jniplatformStaticLibrary')
if (!Os.is(Os.FAMILY_WINDOWS)) {
project.gradle.startParameter.excludedTaskNames.add('jniplatformSharedLibrary')
}
repositories {
mavenLocal()
mavenCentral()
maven {
url = 'https://repo.maven.apache.org/maven2'
}
}
dependencies {
compile 'com.formdev:svgSalamander:1.1.2.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
}
task packageJavadoc(type: Jar) {
classifier 'javadoc'
from javadoc
}
javadoc {
if (JavaVersion.current().isJava9Compatible()) {
options.addStringOption('-add-exports java.desktop/sun.swing=ALL-UNNAMED ' +
'--add-exports java.desktop/sun.awt=ALL-UNNAMED ' +
'--add-exports java.desktop/com.sun.java.swing=ALL-UNNAMED ' +
'--add-exports java.desktop/sun.awt.shell=ALL-UNNAMED', '-quiet')
}
}
artifacts {
archives jar
archives sourceJar
archives packageJavadoc
}
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.3.4'
from components.java
// create the sign pom artifact
pom.withXml {
def pomFile = file("${project.buildDir}/generated-pom.xml")
def projectPom = file("pom.xml")
writeTo(pomFile)
writeTo(projectPom)
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) {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
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)
}
tasks.withType(Jar) {
from(project.projectDir) {
include("LICENSE")
into("META-INF/license")
}
from("${project.projectDir}/licenses") {
include("*")
into("META-INF/license")
}
}
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/'
}

267
build_x86.gradle

@ -1,267 +0,0 @@
import org.gradle.internal.jvm.Jvm
import org.apache.tools.ant.taskdefs.condition.Os
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') ?: "") as String
def signingPassword = (project.findProperty('signingPasswordProp')
?: System.getenv('signingPasswordProp') ?: "") as String
def deployRepoUrl = (project.findProperty('deployRepoUrlProp')
?: System.getenv('deployRepoUrlProp') ?: "") as String
def deployRepoUsername =( project.findProperty('deployRepoUsernameProp')
?: System.getenv('deployRepoUsernameProp') ?: "") as String
def deployRepoPassword = (project.findProperty('deployRepoPasswordProp')
?: System.getenv('deployRepoPasswordProp') ?: "") as String
if (signingKey.isEmpty()) {
project.gradle.startParameter.excludedTaskNames.add('signArchives')
}
project.gradle.startParameter.excludedTaskNames.add('jniplatformStaticLibrary')
if (!Os.is(Os.FAMILY_WINDOWS)) {
project.gradle.startParameter.excludedTaskNames.add('jniplatformSharedLibrary')
}
repositories {
mavenLocal()
mavenCentral()
maven {
url = 'https://repo.maven.apache.org/maven2'
}
}
dependencies {
compile 'com.formdev:svgSalamander:1.1.2.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
}
task packageJavadoc(type: Jar) {
classifier 'javadoc'
from javadoc
}
javadoc {
if (JavaVersion.current().isJava9Compatible()) {
options.addStringOption('-add-exports java.desktop/sun.swing=ALL-UNNAMED ' +
'--add-exports java.desktop/sun.awt=ALL-UNNAMED ' +
'--add-exports java.desktop/com.sun.java.swing=ALL-UNNAMED ' +
'--add-exports java.desktop/sun.awt.shell=ALL-UNNAMED', '-quiet')
}
}
artifacts {
archives jar
archives sourceJar
archives packageJavadoc
}
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.3.4'
from components.java
// create the sign pom artifact
pom.withXml {
def pomFile = file("${project.buildDir}/generated-pom.xml")
def projectPom = file("pom.xml")
writeTo(pomFile)
writeTo(projectPom)
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) {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
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)
}
tasks.withType(Jar) {
from(project.projectDir) {
include("LICENSE")
into("META-INF/license")
}
from("${project.projectDir}/licenses") {
include("*")
into("META-INF/license")
}
}
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/'
}

37
dependencies-bom/build.gradle.kts

@ -0,0 +1,37 @@
plugins {
`java-platform`
}
val String.v: String get() = rootProject.extra["$this.version"] as String
// Note: Gradle allows to declare dependency on "bom" as "api",
// and it makes the contraints to be transitively visible
// However Maven can't express that, so the approach is to use Gradle resolution
// and generate pom files with resolved versions
// See https://github.com/gradle/gradle/issues/9866
fun DependencyConstraintHandlerScope.apiv(
notation: String,
versionProp: String = notation.substringAfterLast(':')
) =
"api"(notation + ":" + versionProp.v)
fun DependencyConstraintHandlerScope.runtimev(
notation: String,
versionProp: String = notation.substringAfterLast(':')
) =
"runtime"(notation + ":" + versionProp.v)
dependencies {
// Parenthesis are needed here: https://github.com/gradle/gradle/issues/9248
(constraints) {
// api means "the dependency is for both compilation and runtime"
// runtime means "the dependency is only for runtime, not for compilation"
// In other words, marking dependency as "runtime" would avoid accidental
// dependency on it during compilation
apiv("net.java.dev.jna:jna")
apiv("org.swinglabs:jxlayer")
apiv("org.swinglabs:swingx")
apiv("com.formdev:svgSalamander")
}
}

21
gradle.properties

@ -0,0 +1,21 @@
# Gradle
org.gradle.parallel=true
kotlin.code.style=official
# See https://github.com/gradle/gradle/pull/11358 , https://issues.apache.org/jira/browse/INFRA-14923
# repository.apache.org does not yet support .sha256 and .sha512 checksums
systemProp.org.gradle.internal.publish.checksums.insecure=true
# Darklaf version
darklaf.version=1.3.3.4
# Plugins
shadow.version=5.1.0
com.github.vlsi.vlsi-release-plugins.version=1.54
com.github.johnrengelman.shadow.version=5.1.0
# Dependencies
jna.version=4.1.0
jxlayer.version=3.0.4
swingx.version=1.6.1
svgSalamander.version=1.1.2.1

BIN
gradle/wrapper/gradle-wrapper.jar vendored

Binary file not shown.

11
gradle/wrapper/gradle-wrapper.properties vendored

@ -1,6 +1,5 @@
#Tue Oct 01 16:12:24 CEST 2019
distributionUrl = https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
distributionBase = GRADLE_USER_HOME
distributionPath = wrapper/dists
zipStorePath = wrapper/dists
zipStoreBase = GRADLE_USER_HOME
distributionSha256Sum=10065868c78f1207afb3a92176f99a37d753a513dff453abb6b5cceda4058cda
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists

29
gradlew vendored

@ -154,19 +154,19 @@ if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
i=`expr $i + 1`
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
@ -175,14 +175,9 @@ save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"

21
licenses/NATIVEUTIL_LICENSE.txt

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2012 Adam Heinrich <adam@adamh.cz>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

12
native-utils/build.gradle.kts

@ -0,0 +1,12 @@
plugins {
`java-library`
}
tasks.jar {
com.github.vlsi.gradle.crlf.CrLfSpec(com.github.vlsi.gradle.crlf.LineEndings.LF).run {
into("META-INF") {
filteringCharset = "UTF-8"
textFrom("$rootDir/licenses/NATIVEUTIL_LICENSE.txt")
}
}
}

2
src/main/java/com/github/weisj/darklaf/platform/NativeUtil.java → native-utils/src/main/java/com/github/weisj/darklaf/platform/NativeUtil.java

@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2020 Jannis Weis
* Copyright (c) 2012 Adam Heinrich <adam@adamh.cz>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

19
src/main/java/com/github/weisj/darklaf/util/SystemInfo.java → native-utils/src/main/java/com/github/weisj/darklaf/platform/SystemInfo.java

@ -21,8 +21,9 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.weisj.darklaf.util;
package com.github.weisj.darklaf.platform;
import java.util.regex.Pattern;
/**
* @author Konstantin Bulenkov
@ -109,12 +110,12 @@ public class SystemInfo {
}
public static boolean isJavaVersionAtLeast(final String v) {
return StringUtil.compareVersionNumbers(JAVA_RUNTIME_VERSION, v) >= 0;
return compareVersionNumbers(JAVA_RUNTIME_VERSION, v) >= 0;
}
private static boolean isOracleJvm() {
String vendor = getJavaVmVendor();
return vendor != null && StringUtil.containsIgnoreCase(vendor, "Oracle");
return vendor != null && containsIgnoreCase(vendor, "Oracle");
}
public static String getJavaVmVendor() {
@ -123,11 +124,17 @@ public class SystemInfo {
private static boolean isSunJvm() {
String vendor = getJavaVmVendor();
return vendor != null && StringUtil.containsIgnoreCase(vendor, "Sun") && StringUtil.containsIgnoreCase(vendor, "Microsystems");
return vendor != null && containsIgnoreCase(vendor, "Sun") &&
containsIgnoreCase(vendor, "Microsystems");
}
private static boolean isAppleJvm() {
String vendor = getJavaVmVendor();
return vendor != null && StringUtil.containsIgnoreCase(vendor, "Apple");
return vendor != null && containsIgnoreCase(vendor, "Apple");
}
}
private static boolean containsIgnoreCase(String text, String pattern) {
return Pattern.compile(pattern, Pattern.LITERAL | Pattern.CASE_INSENSITIVE)
.matcher(text).find();
}
}

1
settings.gradle

@ -1 +0,0 @@
rootProject.name = 'darklaf'

29
settings.gradle.kts

@ -0,0 +1,29 @@
pluginManagement {
plugins {
fun String.v() = extra["$this.version"].toString()
fun PluginDependenciesSpec.idv(id: String, key: String = id) = id(id) version key.v()
idv("com.github.johnrengelman.shadow")
idv("com.github.vlsi.crlf", "com.github.vlsi.vlsi-release-plugins")
idv("com.github.vlsi.gradle-extensions", "com.github.vlsi.vlsi-release-plugins")
idv("com.github.vlsi.ide", "com.github.vlsi.vlsi-release-plugins")
idv("com.github.vlsi.license-gather", "com.github.vlsi.vlsi-release-plugins")
idv("com.github.vlsi.stage-vote-release", "com.github.vlsi.vlsi-release-plugins")
}
}
rootProject.name = "darklaf"
include(
"dependencies-bom",
"native-utils",
"windows"
)
for (p in rootProject.children) {
if (p.children.isEmpty()) {
// Rename leaf projects only
// E.g. we don't expect to publish examples as a Maven module
p.name = "darklaf-" + p.name
}
}

77
src/jniplatform/cpp/com_github_weisj_darklaf_platform_windows_JNIDecorations.h

@ -1,77 +0,0 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class com_github_weisj_darklaf_platform_windows_JNIDecorations */
#ifndef _Included_com_github_weisj_darklaf_platform_windows_JNIDecorations
#define _Included_com_github_weisj_darklaf_platform_windows_JNIDecorations
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: com_github_weisj_darklaf_platform_windows_JNIDecorations
* Method: updateValues
* Signature: (JIII)V
*/
JNIEXPORT void JNICALL Java_com_github_weisj_darklaf_platform_windows_JNIDecorations_updateValues
(JNIEnv *, jclass, jlong, jint, jint, jint);
/*
* Class: com_github_weisj_darklaf_platform_windows_JNIDecorations
* Method: setResizable
* Signature: (JZ)V
*/
JNIEXPORT void JNICALL Java_com_github_weisj_darklaf_platform_windows_JNIDecorations_setResizable
(JNIEnv *, jclass, jlong, jboolean);
/*
* Class: com_github_weisj_darklaf_platform_windows_JNIDecorations
* Method: setBackground
* Signature: (JIII)V
*/
JNIEXPORT void JNICALL Java_com_github_weisj_darklaf_platform_windows_JNIDecorations_setBackground
(JNIEnv *, jclass, jlong, jint, jint, jint);
/*
* Class: com_github_weisj_darklaf_platform_windows_JNIDecorations
* Method: minimize
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_com_github_weisj_darklaf_platform_windows_JNIDecorations_minimize
(JNIEnv *, jclass, jlong);
/*
* Class: com_github_weisj_darklaf_platform_windows_JNIDecorations
* Method: maximize
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_com_github_weisj_darklaf_platform_windows_JNIDecorations_maximize
(JNIEnv *, jclass, jlong);
/*
* Class: com_github_weisj_darklaf_platform_windows_JNIDecorations
* Method: restore
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_com_github_weisj_darklaf_platform_windows_JNIDecorations_restore
(JNIEnv *, jclass, jlong);
/*
* Class: com_github_weisj_darklaf_platform_windows_JNIDecorations
* Method: installDecorations
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_com_github_weisj_darklaf_platform_windows_JNIDecorations_installDecorations
(JNIEnv *, jclass, jlong);
/*
* Class: com_github_weisj_darklaf_platform_windows_JNIDecorations
* Method: uninstallDecorations
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_com_github_weisj_darklaf_platform_windows_JNIDecorations_uninstallDecorations
(JNIEnv *, jclass, jlong);
#ifdef __cplusplus
}
#endif
#endif

2
src/main/java/com/github/weisj/darklaf/DarkLaf.java

@ -28,7 +28,7 @@ import com.github.weisj.darklaf.platform.windows.JNIDecorations;
import com.github.weisj.darklaf.theme.Theme;
import com.github.weisj.darklaf.ui.popupmenu.DarkPopupMenuUI;
import com.github.weisj.darklaf.util.PropertyLoader;
import com.github.weisj.darklaf.util.SystemInfo;
import com.github.weisj.darklaf.platform.SystemInfo;
import sun.awt.AppContext;
import javax.swing.*;

2
src/main/java/com/github/weisj/darklaf/theme/IntelliJTheme.java

@ -24,7 +24,7 @@
package com.github.weisj.darklaf.theme;
import com.github.weisj.darklaf.util.PropertyLoader;
import com.github.weisj.darklaf.util.SystemInfo;
import com.github.weisj.darklaf.platform.SystemInfo;
import javax.swing.*;
import java.util.Properties;

2
src/main/java/com/github/weisj/darklaf/theme/Theme.java

@ -26,7 +26,7 @@ package com.github.weisj.darklaf.theme;
import com.github.weisj.darklaf.DarkLaf;
import com.github.weisj.darklaf.DarkMetalTheme;
import com.github.weisj.darklaf.util.PropertyLoader;
import com.github.weisj.darklaf.util.SystemInfo;
import com.github.weisj.darklaf.platform.SystemInfo;
import javax.swing.*;
import javax.swing.plaf.metal.MetalLookAndFeel;

2
src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonUI.java

@ -26,7 +26,7 @@ package com.github.weisj.darklaf.ui.button;
import com.github.weisj.darklaf.util.DarkUIUtil;
import com.github.weisj.darklaf.util.GraphicsContext;
import com.github.weisj.darklaf.util.GraphicsUtil;
import com.github.weisj.darklaf.util.SystemInfo;
import com.github.weisj.darklaf.platform.SystemInfo;
import sun.swing.SwingUtilities2;
import javax.swing.*;

2
src/main/java/com/github/weisj/darklaf/ui/checkbox/DarkCheckBoxBorder.java

@ -25,7 +25,7 @@ package com.github.weisj.darklaf.ui.checkbox;
import com.github.weisj.darklaf.util.DarkUIUtil;
import com.github.weisj.darklaf.util.SystemInfo;
import com.github.weisj.darklaf.platform.SystemInfo;
import javax.swing.*;
import javax.swing.border.Border;

2
src/main/java/com/github/weisj/darklaf/ui/radiobutton/DarkRadioButtonBorder.java

@ -25,7 +25,7 @@ package com.github.weisj.darklaf.ui.radiobutton;
import com.github.weisj.darklaf.util.DarkUIUtil;
import com.github.weisj.darklaf.util.SystemInfo;
import com.github.weisj.darklaf.platform.SystemInfo;
import javax.swing.*;
import javax.swing.border.Border;

2
src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeUI.java

@ -24,7 +24,7 @@
package com.github.weisj.darklaf.ui.tree;
import com.github.weisj.darklaf.util.DarkUIUtil;
import com.github.weisj.darklaf.util.SystemInfo;
import com.github.weisj.darklaf.platform.SystemInfo;
import javax.swing.*;
import javax.swing.plaf.ComponentUI;

51
src/main/java/com/github/weisj/darklaf/util/StringUtil.java

@ -185,57 +185,6 @@ public final class StringUtil {
}
}
public static int compareVersionNumbers(final String v1, final String v2) {
if (v1 == null && v2 == null) {
return 0;
} else if (v1 == null) {
return -1;
} else if (v2 == null) {
return 1;
} else {
String[] part1 = v1.split("[._\\-]");
String[] part2 = v2.split("[._\\-]");
int idx;
for (idx = 0; idx < part1.length && idx < part2.length; ++idx) {
String p1 = part1[idx];
String p2 = part2[idx];
int cmp;
if (p1.matches("\\d+") && p2.matches("\\d+")) {
cmp = (Integer.valueOf(p1)).compareTo(Integer.valueOf(p2));
} else {
cmp = part1[idx].compareTo(part2[idx]);
}
if (cmp != 0) {
return cmp;
}
}
if (part1.length == part2.length) {
return 0;
} else {
boolean left = part1.length > idx;
for (String[] parts = left ? part1 : part2; idx < parts.length; ++idx) {
String p = parts[idx];
int cmp;
if (p.matches("\\d+")) {
cmp = (Integer.valueOf(p)).compareTo(0);
} else {
cmp = 1;
}
if (cmp != 0) {
return left ? cmp : -cmp;
}
}
return 0;
}
}
}
public static boolean isBlank(final String s) {
return s.trim().length() == 0;
}

2
src/test/java/theme/MyCustomTheme.java

@ -24,7 +24,7 @@
package theme;
import com.github.weisj.darklaf.theme.Theme;
import com.github.weisj.darklaf.util.SystemInfo;
import com.github.weisj.darklaf.platform.SystemInfo;
import javax.swing.*;
import java.util.Properties;

33
windows/build.gradle.kts

@ -0,0 +1,33 @@
plugins {
`jni-library`
}
fun DependencyHandlerScope.javaImplementation(dep: Any) {
compileOnly(dep)
runtimeOnly(dep)
}
dependencies {
javaImplementation(project(":darklaf-native-utils"))
javaImplementation("net.java.dev.jna:jna")
}
library {
targetMachines.addAll(machines.windows.x86, machines.windows.x86_64)
binaries.configureEach {
compileTask.get().compilerArgs.addAll(toolChain.let {
if (it is Gcc || it is Clang) listOf("--std=c++11")
else emptyList()
})
}
binaries.whenElementFinalized(CppSharedLibrary::class) {
linkTask.get().linkerArgs.addAll(
"dwmapi.lib",
"user32.lib",
"Gdi32.lib",
"-ldwmapi",
"-lGdi32",
"-luser32"
)
}
}

0
src/jniplatform/cpp/JNIDecorations.cpp → windows/src/main/cpp/JNIDecorations.cpp

0
src/jniplatform/cpp/JNIDecorations.h → windows/src/main/cpp/JNIDecorations.h

13
src/main/java/com/github/weisj/darklaf/platform/windows/JNIDecorations.java → windows/src/main/java/com/github/weisj/darklaf/platform/windows/JNIDecorations.java

@ -23,9 +23,8 @@
*/
package com.github.weisj.darklaf.platform.windows;
import com.github.weisj.darklaf.DarkLaf;
import com.github.weisj.darklaf.platform.NativeUtil;
import com.github.weisj.darklaf.util.SystemInfo;
import com.github.weisj.darklaf.platform.SystemInfo;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
@ -81,15 +80,15 @@ public class JNIDecorations {
}
private static boolean loadLibrary() {
if (!SystemInfo.isWindows || !DarkLaf.isDecorationsEnabled()) {
if (!SystemInfo.isWindows) {
return false;
}
if (loaded) return true;
try {
if (SystemInfo.isX86) {
NativeUtil.loadLibraryFromJar("/com/github/weisj/darklaf/platform/windows/x86/jniplatform.dll");
NativeUtil.loadLibraryFromJar("/com/github/weisj/darklaf/platform/darklaf-windows/windows-x86/darklaf-windows.dll");
} else if (SystemInfo.isX64) {
NativeUtil.loadLibraryFromJar("/com/github/weisj/darklaf/platform/windows/x64/jniplatform.dll");
NativeUtil.loadLibraryFromJar("/com/github/weisj/darklaf/platform/darklaf-windows/windows-x86-64/darklaf-windows.dll");
} else {
LOGGER.warning("Could not determine jre model '"
+ SystemInfo.jreArchitecture
@ -97,10 +96,10 @@ public class JNIDecorations {
return false;
}
loaded = true;
LOGGER.info("Loaded jniplatform.dll. Decorations are enabled.");
LOGGER.info("Loaded darklaf-windows.dll. Decorations are enabled.");
return true;
} catch (IOException e) {
LOGGER.log(Level.SEVERE, "Could not load decorations library. Decorations will be disabled",
LOGGER.log(Level.SEVERE, "Could not load decorations library darklaf-windows.dll. Decorations will be disabled",
e.getMessage());
return false;
}
Loading…
Cancel
Save