codemp/dist/java/build.gradle

186 lines
3.8 KiB
Groovy
Raw Normal View History

plugins {
2024-08-08 00:29:54 +02:00
id 'java-library'
2024-10-16 15:21:20 +02:00
id "com.vanniktech.maven.publish.base" version "0.30.0"
2024-09-18 13:57:07 +02:00
id 'com.google.osdetector' version '1.7.3'
}
group = 'mp.code'
2024-10-26 19:46:16 +02:00
version = '0.8.2'
2024-08-08 00:29:54 +02:00
2024-10-15 00:26:01 +02:00
tasks.register('windowsJar', Jar) {
outputs.upToDateWhen { false }
archiveClassifier = 'windows-x86_64'
from sourceSets.main.runtimeClasspath
from('artifacts') {
include('*.dll')
into('natives/')
}
doFirst {
if(!(new File('artifacts/codemp.dll').exists())) {
throw new GradleException("The required file does not exist!")
}
}
}
tasks.register('macosJar', Jar) {
outputs.upToDateWhen { false }
archiveClassifier = 'osx-aarch_64'
from sourceSets.main.runtimeClasspath
from('artifacts') {
include('*.dylib')
into('natives/')
}
doFirst {
if(!(new File('artifacts/libcodemp.dylib').exists())) {
throw new GradleException("The required file does not exist!")
}
}
}
tasks.register('linuxJar', Jar) {
outputs.upToDateWhen { false }
archiveClassifier = 'linux-x86_64'
from sourceSets.main.runtimeClasspath
from('artifacts') {
include('*.so')
into('natives/')
}
doFirst {
if(!(new File('artifacts/libcodemp.so').exists())) {
throw new GradleException("The required file does not exist! Maybe you need to `cargo build` the main library first?")
}
}
}
2024-10-16 01:07:34 +02:00
tasks.register('multiplatformJar', Jar) {
outputs.upToDateWhen { false }
archiveClassifier = 'all'
from sourceSets.main.runtimeClasspath
from('artifacts') {
include('*')
into('natives/')
}
}
2024-10-15 00:26:01 +02:00
configurations {
windowsJar {
canBeConsumed = true
canBeResolved = false
extendsFrom implementation, runtimeOnly
}
linuxJar {
canBeConsumed = true
canBeResolved = false
extendsFrom implementation, runtimeOnly
}
macosJar {
canBeConsumed = true
canBeResolved = false
extendsFrom implementation, runtimeOnly
}
2024-10-16 01:07:34 +02:00
multiplatformJar {
canBeConsumed = true
canBeResolved = false
extendsFrom implementation, runtimeOnly
}
2024-10-15 00:26:01 +02:00
}
2024-08-08 00:29:54 +02:00
java {
2024-09-18 13:21:13 +02:00
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_11
2024-10-16 01:07:34 +02:00
withSourcesJar()
withJavadocJar()
}
artifacts {
archives jar
archives sourcesJar
archives javadocJar
windowsJar(windowsJar)
macosJar(macosJar)
linuxJar(linuxJar)
multiplatformJar(multiplatformJar)
}
repositories {
mavenCentral()
}
sourceSets {
main.java.srcDirs = ['src/']
}
dependencies {
compileOnly 'org.projectlombok:lombok:1.18.34'
annotationProcessor 'org.projectlombok:lombok:1.18.34'
}
tasks.register('cargoBuild', Exec) {
workingDir '.'
commandLine 'cargo', 'build', '--release', '--features=java'
}
def rustDir = projectDir.toPath()
2024-08-08 00:29:54 +02:00
.parent
.parent
.resolve('target')
.resolve('release')
.toFile()
2024-10-15 00:26:01 +02:00
tasks.register('nativeBuild', Jar) {
archiveClassifier = osdetector.classifier
dependsOn cargoBuild
2024-10-15 00:26:01 +02:00
from sourceSets.main.runtimeClasspath
from(rustDir) {
include('*.dll')
include('*.so')
2024-09-09 20:59:07 +02:00
include('*dylib')
into('natives/')
}
}
2024-10-16 01:07:34 +02:00
publishing {
publications {
mavenJava(MavenPublication) {
artifact jar
artifact sourcesJar
artifact javadocJar
artifact windowsJar
artifact linuxJar
artifact macosJar
artifact multiplatformJar
}
}
}
import com.vanniktech.maven.publish.SonatypeHost
2024-09-18 13:57:07 +02:00
mavenPublishing {
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL, true)
2024-10-16 15:21:20 +02:00
signAllPublications()
2024-09-18 13:57:07 +02:00
coordinates(project.group, rootProject.name, project.version)
pom {
name = rootProject.name
description = "A collaborative editor plugin ecosystem"
inceptionYear = "2022"
url = "https://code.mp/"
licenses {
license {
name = "The GNU General Public License v3.0"
url = "https://www.gnu.org/licenses/gpl-3.0.txt"
}
}
developers {
developer {
id = "zaaarf"
name = "zaaarf"
email = "zaaarf@codemp.dev"
}
}
scm {
url = "https://github.com/hexedtech/codemp/"
connection = "scm:git:git://github.com/hexedtech/codemp.git"
developerConnection = "scm:git:ssh://git@github.com/hexedtech/codemp.git"
}
}
}