codemp/dist/java/build.gradle

103 lines
2.1 KiB
Groovy

plugins {
id 'java-library'
id 'maven-publish'
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'com.palantir.git-version' version '3.1.0'
}
group = 'mp.code'
version = versionDetails().lastTag.substring(1)
java {
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8
}
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
sourceSets {
main.java.srcDirs = ['src/']
}
dependencies {
implementation 'com.github.adamheinrich:native-utils:master-SNAPSHOT'
compileOnly 'org.projectlombok:lombok:1.18.34'
annotationProcessor 'org.projectlombok:lombok:1.18.34'
}
shadowJar {
archiveClassifier.set('')
dependencies {
include(dependency('com.github.adamheinrich:native-utils:master-SNAPSHOT'))
}
}
def rustDir = projectDir.toPath()
.parent
.parent
.resolve('target')
.resolve('release')
.toFile()
processResources {
outputs.upToDateWhen { false } // no caching
from(rustDir) {
include('*.dll')
include('*.so')
include('*dylib')
into('natives/')
}
}
tasks.register('cargoBuild', Exec) {
workingDir '.'
commandLine 'cargo', 'build', '--release', '--features=java'
}
processResources.dependsOn cargoBuild
build.finalizedBy shadowJar
publishing {
publications {
mavenJava(MavenPublication) {
artifactId = 'my-library'
from components.java
versionMapping {
usage('java-api') {
fromResolutionOf('runtimeClasspath')
}
usage('java-runtime') {
fromResolutionResult()
}
}
pom {
name = 'My Library'
description = 'A concise description of my library'
url = 'http://www.example.com/library'
properties = [
myProp: "value",
"prop.with.dots": "anotherValue"
]
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'johnd'
name = 'John Doe'
email = 'john.doe@example.com'
}
}
scm {
connection = 'scm:git:git://example.com/my-library.git'
developerConnection = 'scm:git:ssh://example.com/my-library.git'
url = 'http://example.com/my-library/'
}
}
}
}
}