buildscript { repositories { mavenCentral() } } plugins { id "java-library" id "com.adarshr.test-logger" version "2.1.1" id "maven-publish" id "signing" id "biz.aQute.bnd.builder" version "5.3.0" } version = '4.1.3' group = 'com.github.tschoonj' sourceCompatibility = '1.8' targetCompatibility = '1.8' libsDirName = '..' repositories { mavenCentral() } dependencies { api 'org.apache.commons:commons-math3:3.6.1' testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.1' testImplementation 'org.junit.jupiter:junit-jupiter-params:5.7.1' testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.1' } sourceSets { main { java { srcDir '@srcdir@' exclude 'tests/**' exclude 'gradle/**' } resources { srcDir '@builddir@' include 'xraylib.dat' } } test { java { srcDir '@srcdir@/tests' } } } jar { manifest { attributes('Bundle-Vendor': 'Tom Schoonjans', 'Bundle-SymbolicName': 'com.github.tschoonj.xraylib', 'Automatic-Module-Name': 'com.github.tschoonj.xraylib', 'Bundle-Name': project.name, 'Export-Package': 'com.github.tschoonj.xraylib', '-noee': true ) } } task checkCompile(type: JavaCompile) { source = fileTree('@top_srcdir@/example/') include 'xrlexample7.java' classpath = sourceSets.main.runtimeClasspath options.sourcepath = files('@top_srcdir@/example') destinationDir = file('.') } task checkRun(dependsOn: 'checkCompile', type: JavaExec) { main = 'xrlexample7' classpath = sourceSets.main.runtimeClasspath + files('.') } test { useJUnitPlatform() } // based on https://blog.benoitblanchon.fr/gradle-how-to-make-a-flat-source-jar/ task flatSources(type: Copy) { from sourceSets.main.allJava into "$buildDir/flatSrc/com/github/tschoonj/xraylib" } task sourcesJar(type: Jar, dependsOn: flatSources) { from "$buildDir/flatSrc" archiveClassifier = 'sources' } task javadocJar(type: Jar) { from javadoc archiveClassifier = 'javadoc' } publishing { publications { maven(MavenPublication) { from components.java artifact sourcesJar artifact javadocJar pom { name = 'xraylib' description = 'A library for X-ray matter interaction cross sections for X-ray fluorescence applications' url = 'https://github.com/tschoonj/xraylib' licenses { license { name = '3-Clause BSD License' url = 'https://opensource.org/licenses/BSD-3-Clause' } } developers { developer { id = 'tschoonj' name = 'Tom Schoonjans' email = 'Tom.Schoonjans@gmail.com' } } scm { connection = 'scm:git:git://github.com/tschoonj/xraylib.git' developerConnection = 'scm:git:git://github.com/tschoonj/xraylib.git' url = 'https://github.com/tschoonj/xraylib.git' } } } } repositories { maven { name = 'Sonatype' url "https://oss.sonatype.org/service/local/staging/deploy/maven2" credentials { username System.getenv('SONATYPE_USERNAME') password System.getenv('SONATYPE_PASSWORD') } } } } signing { sign publishing.publications.maven }