core 0.1-beta
This commit is contained in:
+266
@@ -0,0 +1,266 @@
|
||||
import static org.apache.tools.ant.taskdefs.condition.Os.*
|
||||
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'maven-publish'
|
||||
id 'signing'
|
||||
}
|
||||
|
||||
group = 'net.fokinatorr.sparkle'
|
||||
version = '0.1-beta'
|
||||
description = """The core module of SPJF (code name Sparkle).
|
||||
|
||||
Sparkle is a framework for creating graphical applications, with an API similar to the functionality MIT Scratch
|
||||
offers. There are also a lot more features and flexibility.
|
||||
|
||||
To run Sparkle, you only need this module; if you want additional functionality, see other modules with group ID
|
||||
'$group'."""
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = 25
|
||||
targetCompatibility = 25
|
||||
}
|
||||
|
||||
sourceSets.register('natives')
|
||||
|
||||
def lombokVersion = "1.18.44"
|
||||
def lwjglVersion = "3.4.1"
|
||||
def lwjglNatives = findLWJGLNatives()
|
||||
def lwjglVersionNatives = "$lwjglVersion:$lwjglNatives"
|
||||
|
||||
def lwjglNativeLibs = [
|
||||
"org.lwjgl:lwjgl:$lwjglVersionNatives",
|
||||
"org.lwjgl:lwjgl-glfw:$lwjglVersionNatives",
|
||||
"org.lwjgl:lwjgl-nanovg:$lwjglVersionNatives",
|
||||
"org.lwjgl:lwjgl-openal:$lwjglVersionNatives",
|
||||
"org.lwjgl:lwjgl-opengl:$lwjglVersionNatives",
|
||||
"org.lwjgl:lwjgl-stb:$lwjglVersionNatives"
|
||||
]
|
||||
|
||||
dependencies {
|
||||
implementation 'it.unimi.dsi:fastutil:8.5.15'
|
||||
implementation 'org.slf4j:slf4j-api:2.0.16'
|
||||
implementation 'org.joml:joml:1.10.8'
|
||||
implementation 'net.fokinatorr:poly2tri:0.7.0'
|
||||
implementation 'net.fokinatorr:lwjgl-exceptions:1.0-SNAPSHOT'
|
||||
implementation "org.lwjgl:lwjgl:$lwjglVersion"
|
||||
implementation "org.lwjgl:lwjgl-glfw:$lwjglVersion"
|
||||
implementation "org.lwjgl:lwjgl-nanovg:$lwjglVersion"
|
||||
implementation "org.lwjgl:lwjgl-openal:$lwjglVersion"
|
||||
implementation "org.lwjgl:lwjgl-opengl:$lwjglVersion"
|
||||
implementation "org.lwjgl:lwjgl-stb:$lwjglVersion"
|
||||
|
||||
runtimeOnly 'ch.qos.logback:logback-classic:1.5.18' // SLF4J implementation
|
||||
|
||||
lwjglNativeLibs.forEach {lib ->
|
||||
compileOnly lib
|
||||
}
|
||||
compileOnly "org.projectlombok:lombok:$lombokVersion"
|
||||
annotationProcessor "org.projectlombok:lombok:$lombokVersion"
|
||||
|
||||
testImplementation 'io.github.hakky54:logcaptor:2.12.6'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter:5.11.4'
|
||||
|
||||
testRuntimeOnly 'ch.qos.logback:logback-classic:1.5.18' // SLF4J implementation
|
||||
testRuntimeOnly 'org.junit.platform:junit-platform-launcher:6.1.0'
|
||||
lwjglNativeLibs.forEach {lib ->
|
||||
testRuntimeOnly lib
|
||||
}
|
||||
|
||||
testCompileOnly "org.projectlombok:lombok:$lombokVersion"
|
||||
testAnnotationProcessor "org.projectlombok:lombok:$lombokVersion"
|
||||
}
|
||||
|
||||
test {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
processResources {
|
||||
doLast {
|
||||
copy {
|
||||
from file('./LICENSE')
|
||||
into destinationDir
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
processTestResources {
|
||||
dependsOn processResources
|
||||
doLast {
|
||||
copy {
|
||||
from processResources.destinationDir
|
||||
into destinationDir
|
||||
}
|
||||
copy {
|
||||
from destinationDir
|
||||
into compileTestJava.destinationDirectory.get().asFile
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register('generateNativesModule') {
|
||||
doLast {
|
||||
println "OS Name: ${System.getProperty('os.name')}"
|
||||
println "OS Arch: ${System.getProperty('os.arch')}"
|
||||
println "LWJGL natives: $lwjglNatives"
|
||||
def nativesNameLower = lwjglNatives.replace('natives-', '').replace('-', '.')
|
||||
def nativesName = String.valueOf(nativesNameLower.charAt(0)).toUpperCase(Locale.ENGLISH) + nativesNameLower.substring(1)
|
||||
def sourcesDir = new File(temporaryDir, 'java')
|
||||
def resourcesDir = new File(temporaryDir, 'resources')
|
||||
|
||||
copy {
|
||||
from new File(projectDir, '/src/nativeTemplate/java')
|
||||
into sourcesDir
|
||||
|
||||
filter { String line ->
|
||||
line
|
||||
.replace('NATIVES_NAME_LOWER', nativesNameLower)
|
||||
.replace('NATIVES_NAME', nativesName)
|
||||
}
|
||||
|
||||
include '**/*.java'
|
||||
}
|
||||
|
||||
sourceSets.natives.java.srcDir sourcesDir
|
||||
|
||||
def nativesDir = new File(resourcesDir, "natives/$nativesNameLower")
|
||||
sourceSets.main.compileClasspath.files.each { jar ->
|
||||
if (jar.name.contains('natives')) {
|
||||
copy {
|
||||
from zipTree(jar).files // flatten
|
||||
include '*.so', '*.dll', '*.dylib'
|
||||
into nativesDir
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets.natives.resources.srcDir resourcesDir
|
||||
}
|
||||
}
|
||||
|
||||
compileNativesJava {
|
||||
dependsOn generateNativesModule, jar
|
||||
doFirst {
|
||||
def coreJar = files(new File(layout.buildDirectory.get().asFile, "libs/${project.name}-${version}.jar"))
|
||||
sourceSets.natives.compileClasspath += coreJar
|
||||
sourceSets.natives.runtimeClasspath += coreJar
|
||||
classpath += coreJar
|
||||
}
|
||||
}
|
||||
|
||||
processNativesResources {
|
||||
dependsOn generateNativesModule
|
||||
}
|
||||
|
||||
jar {
|
||||
dependsOn compileJava
|
||||
from compileJava.destinationDirectory.get().asFile, processResources.destinationDir
|
||||
}
|
||||
|
||||
tasks.register('jarSources', Jar) {
|
||||
archiveClassifier = 'sources'
|
||||
from sourceSets.main.java.asFileTree
|
||||
}
|
||||
|
||||
tasks.register('jarNatives', Jar) {
|
||||
dependsOn compileNativesJava, processNativesResources
|
||||
archiveClassifier = lwjglNatives
|
||||
from compileNativesJava.destinationDirectory.get().asFile, processNativesResources.destinationDir
|
||||
}
|
||||
|
||||
assemble {
|
||||
dependsOn jarSources, jarNatives
|
||||
}
|
||||
|
||||
def project = project // prevent 'cannot resolve' warnings
|
||||
|
||||
publishing {
|
||||
repositories {
|
||||
maven {
|
||||
name = 'Central'
|
||||
url = 'https://oss.sonatype.org/service/local/staging/deploy/maven2'
|
||||
credentials {
|
||||
username = project.findProperty('ossrh.username') ?: System.getenv('OSSRH_USERNAME')
|
||||
password = project.findProperty('ossrh.password') ?: System.getenv('OSSRH_PASSWORD')
|
||||
}
|
||||
}
|
||||
maven {
|
||||
name = 'GitHubPackages'
|
||||
url = 'https://maven.pkg.github.com/SparkleJ-Framework/sparkle-core'
|
||||
credentials {
|
||||
username = project.findProperty('gpr.user') ?: System.getenv('GITHUB_ACTOR')
|
||||
password = project.findProperty('gpr.token') ?: System.getenv('GITHUB_TOKEN')
|
||||
}
|
||||
}
|
||||
}
|
||||
publications {
|
||||
register('maven', MavenPublication) {
|
||||
// publish once
|
||||
pom {
|
||||
name = 'Sparkle Core Module'
|
||||
description = project.description
|
||||
url = 'https://sparkle.fokinatorr.net'
|
||||
licenses {
|
||||
license {
|
||||
name = 'MIT License'
|
||||
url = 'https://opensource.org/license/mit'
|
||||
}
|
||||
}
|
||||
developers {
|
||||
developer {
|
||||
name = 'Fokinatorr_'
|
||||
url = 'https://fokinatorr.net'
|
||||
}
|
||||
}
|
||||
scm {
|
||||
connection = 'scm:git:git://github.com/SparkleJ-Framework/sparkle-core.git'
|
||||
developerConnection = 'scm:git:ssh://github.com/SparkleJ-Framework/sparkle-core.git'
|
||||
url = 'https://github.com/SparkleJ-Framework/sparkle-core'
|
||||
}
|
||||
}
|
||||
from project.components.java
|
||||
artifact(jarSources) {
|
||||
classifier = 'sources'
|
||||
}
|
||||
artifact(jarNatives) {
|
||||
classifier = lwjglNatives
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//signing {
|
||||
// useInMemoryPgpKeys(
|
||||
// project.findProperty('signingKey').toString() ?: System.getenv('SIGNING_KEY'),
|
||||
// project.findProperty('signingPassword').toString() ?: System.getenv('SIGNING_PASSWORD')
|
||||
// )
|
||||
// sign publishing.publications
|
||||
//}
|
||||
|
||||
static String findLWJGLNatives() {
|
||||
String lwjglNatives = null
|
||||
if (isArch("amd64")) {
|
||||
if (isFamily("unix") && isName("linux")) {
|
||||
lwjglNatives = "natives-linux"
|
||||
} else if (isFamily("windows")) {
|
||||
lwjglNatives = "natives-windows"
|
||||
}
|
||||
} else if (isFamily("mac")) {
|
||||
if (isArch("aarch64")) {
|
||||
lwjglNatives = "natives-macos-arm64"
|
||||
} else if (isArch("x86_64")) {
|
||||
// maybe remove this in the future
|
||||
lwjglNatives = "natives-macos"
|
||||
}
|
||||
// Add MoltenVK here when Vulkan gets added
|
||||
}
|
||||
if (!lwjglNatives) {
|
||||
throw new IllegalStateException("Unsupported OS")
|
||||
}
|
||||
return lwjglNatives
|
||||
}
|
||||
Reference in New Issue
Block a user