133 lines
3.3 KiB
Groovy
133 lines
3.3 KiB
Groovy
buildscript {
|
|
repositories {
|
|
mavenCentral()
|
|
gradlePluginPortal()
|
|
}
|
|
}
|
|
|
|
plugins {
|
|
id 'maven-publish'
|
|
id 'biz.aQute.bnd.builder' version '6.0.0'
|
|
}
|
|
|
|
group = 'com.fazecast'
|
|
archivesBaseName = 'jSerialComm'
|
|
version = '2.9.2'
|
|
ext.moduleName = 'com.fazecast.jSerialComm'
|
|
|
|
if (hasProperty('manualBuild'))
|
|
{
|
|
assert hasProperty('java6Home'): "Set the property 'java6Home' in your gradle.properties file pointing to a Java 6 JDK installation"
|
|
assert hasProperty('java9Home'): "Set the property 'java9Home' in your gradle.properties file pointing to a Java 9 JDK installation"
|
|
}
|
|
|
|
sourceCompatibility = 1.6
|
|
targetCompatibility = 1.6
|
|
javadoc.options.links("https://docs.oracle.com/javase/9/docs/api/")
|
|
javadoc.options.addBooleanOption('html4', true)
|
|
|
|
if (hasProperty('manualBuild'))
|
|
{
|
|
def java6ExecutablesPath = new File(java6Home, 'bin')
|
|
def java9ExecutablesPath = new File(java9Home, 'bin')
|
|
def java6Executables = [:].withDefault { execName ->
|
|
def executable = new File(java6ExecutablesPath, execName)
|
|
executable
|
|
}
|
|
def java9Executables = [:].withDefault { execName ->
|
|
def executable = new File(java9ExecutablesPath, execName)
|
|
executable
|
|
}
|
|
|
|
tasks.withType(JavaCompile) {
|
|
options.with {
|
|
fork = true
|
|
forkOptions.javaHome = file(java6Home)
|
|
}
|
|
}
|
|
tasks.withType(Javadoc) {
|
|
executable = java9Executables.javadoc
|
|
}
|
|
tasks.withType(Test) {
|
|
executable = java6Executables.java
|
|
}
|
|
tasks.withType(JavaExec) {
|
|
executable = java6Executables.java
|
|
}
|
|
}
|
|
|
|
sourceSets {
|
|
main {
|
|
java {
|
|
srcDirs = ['src/main/java']
|
|
}
|
|
}
|
|
moduleInfo {
|
|
java {
|
|
srcDirs = ['src/moduleInfo/java']
|
|
}
|
|
}
|
|
}
|
|
|
|
compileModuleInfoJava {
|
|
sourceCompatibility = 9
|
|
targetCompatibility = 9
|
|
inputs.property("moduleName", moduleName)
|
|
|
|
doFirst {
|
|
classpath = files()
|
|
options.fork = true
|
|
options.forkOptions.javaHome = file(java9Home)
|
|
options.sourcepath = files(sourceSets.moduleInfo.java.srcDirs)
|
|
options.compilerArgs = [
|
|
'--module-path', classpath.asPath,
|
|
'-d', sourceSets.main.output.classesDirs.asPath
|
|
]
|
|
}
|
|
}
|
|
|
|
jar {
|
|
from sourceSets.main.output
|
|
from sourceSets.moduleInfo.output
|
|
|
|
bnd (
|
|
'-exportcontents': 'com.fazecast.jSerialComm;version="' + archiveVersion.get() + '"',
|
|
'Bundle-Name': 'jSerialComm',
|
|
'Bundle-SymbolicName': 'com.fazecast.jSerialComm',
|
|
'Bundle-Description': 'Java Serial Communications Library',
|
|
'Bundle-Vendor': 'Fazecast, Inc.',
|
|
'Require-Capability': 'osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.6))"',
|
|
'Implementation-Title': 'jSerialComm: Java Serial Communications Library',
|
|
'Implementation-Version': archiveVersion.get(),
|
|
'Implementation-Vendor': 'Fazecast, Inc.',
|
|
'Sealed': 'true'
|
|
)
|
|
}
|
|
|
|
task testJar(type: Jar) {
|
|
classifier = 'test'
|
|
from sourceSets.test.output, sourceSets.main.output
|
|
|
|
manifest {
|
|
attributes 'Main-Class': 'com.fazecast.jSerialComm.SerialPortTest',
|
|
'Implementation-Title': 'jSerialComm: Java Serial Communications Library',
|
|
'Implementation-Version': archiveVersion.get(),
|
|
'Implementation-Vendor': 'Fazecast, Inc.',
|
|
'Sealed': 'true'
|
|
}
|
|
}
|
|
|
|
task javadocJar(type: Jar) {
|
|
classifier = 'javadoc'
|
|
from javadoc
|
|
}
|
|
|
|
task sourcesJar(type: Jar) {
|
|
classifier = 'sources'
|
|
from sourceSets.main.allSource
|
|
}
|
|
|
|
artifacts {
|
|
archives jar, javadocJar, sourcesJar, testJar
|
|
}
|