-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.gradle
118 lines (93 loc) · 3.07 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
group 'org.duktape'
version '0.0.0'
apply plugin: 'java'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath group: 'org.bytedeco', name: 'javacpp', version: '1.2.1'
}
}
import org.bytedeco.javacpp.tools.Builder
import org.duktape.duktapejava.generator.Generator
dependencies {
compile group: 'org.bytedeco', name: 'javacpp', version: '1.2.1'
testCompile group: 'junit', name: 'junit', version: '4.12'
}
jar {
actions = []
dependsOn = []
dependsOn('fatJar')
}
compileJava.dependsOn('generateJava')
def nativeArtifactDir = new File("$buildDir/native/")
task fatJar(type: Jar, dependsOn: 'natives') {
baseName = project.name
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
from(nativeArtifactDir) {
include '**/*'
}
with jar
manifest {
attributes 'Implementation-Version': version
}
}
task natives(dependsOn: 'generateJava') {
doFirst {
nativeArtifactDir.deleteDir()
nativeArtifactDir.mkdirs()
}
doLast {
// buildNative(nativeArtifactDir, null, "linux-x86_64-debug.properties")
buildNative(nativeArtifactDir, null, null)
}
}
def buildNative(nativeArtifactDir, platformName, platformFileName) {
def nativeTmpDir = new File("$buildDir/tmp/native/")
nativeTmpDir.deleteDir()
nativeTmpDir.mkdirs()
new groovy.util.AntBuilder().copy(todir: nativeTmpDir) {
fileset(dir: "src/main/c/")
}
def builder = new Builder()
def propertiesField = Builder.class.getDeclaredField("properties")
propertiesField.setAccessible(true)
def properties = propertiesField.get(builder);
def platform = properties.get("platform")
builder.classPaths(sourceSets.main.runtimeClasspath.collect { it.getAbsolutePath() }.toArray(new String[0]))
builder.outputDirectory(nativeTmpDir)
if (platformName != null) builder.properties((String) platformName)
if (platformFileName != null) builder.propertyFile((String) platformFileName)
builder.outputName("duktape-java-$platform")
builder.classesOrPackages('org.duktape.duktapejava.Duktape')
def file = builder.build()[0]
builder.compile(false)
builder.build()
new groovy.util.AntBuilder().copy(file: file, tofile: new File(nativeArtifactDir, file.getName()))
}
task generateJava(type: Generator) {
outputs.upToDateWhen { false }
apiDirectory = new File("duktape-api/")
headerFile = new File("duktape-api/constants.h")
outputDirectory = new File("src/main/java")
}
//if (JavaVersion.current().isJava8Compatible()) {
// allprojects {
// tasks.withType(Javadoc) {
// options.addStringOption('Xdoclint:none', '-quiet')
// }
// }
//}
task generateDocumntation(type: Javadoc, dependsOn: 'build') {
classpath = sourceSets.main.runtimeClasspath
source = sourceSets.main.allJava
}
task generateDocumntationWithoutBuild(type: Javadoc) {
classpath = sourceSets.main.runtimeClasspath
source = sourceSets.main.allJava
}