forked from stleary/JSON-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
188 lines (171 loc) · 5.36 KB
/
build.gradle
File metadata and controls
188 lines (171 loc) · 5.36 KB
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
buildscript {
println "gradle version: " + gradle.gradleVersion
println "JDK: " + System.getProperty("java.home")
}
plugins {
id 'maven-publish'
}
def sourceEncoding = 'utf-8'
def documentEncoding = 'utf-8'
def env = System.env
def gver = gradle.gradleVersion
def osname = System.getProperty('os.name').toLowerCase()
def osarch = System.getProperty("os.arch")
def userHome = System.getProperty("user.home")
allprojects {
apply plugin: 'java'
sourceSets.main.java.srcDirs = ['src']
sourceSets.main.resources.srcDirs = ['resources']
sourceSets.test.java.srcDirs = ['test']
if (gver < '5.0') {
sourceSets.main.output.classesDir = 'build/classes'
sourceSets.main.output.resourcesDir = 'build/resources'
sourceSets.test.output.classesDir = 'build/test-classes'
sourceSets.test.output.resourcesDir = 'build/test-resources'
}
repositories {
mavenLocal()
mavenCentral()
}
tasks.withType(JavaCompile) {
// options.compilerArgs << '-Xlint:unchecked,divzero'
options.deprecation = false
options.encoding = sourceEncoding
doFirst {
if (sourceCompatibility == '1.7' && env.JRE7_HOME != null) {
options.fork = true
if (gver < '5.0')
options.bootClasspath = "${env.JRE7_HOME}/lib/rt.jar"
// ↑ for gradle 4.x with JDK7
else
options.bootstrapClasspath = files("${env.JRE7_HOME}/lib/rt.jar")
// ↑ for gradle 5.x with JDK8
}
else if (sourceCompatibility == '1.6' && env.JRE6_HOME != null) {
options.fork = true
if (gver < '5.0')
options.bootClasspath = "${env.JRE6_HOME}/lib/rt.jar"
else
options.bootstrapClasspath = files("${env.JRE6_HOME}/lib/rt.jar")
}
else if (sourceCompatibility == '1.5' && env.JRE5_HOME != null) {
options.fork = true
if (gver < '5.0')
options.bootClasspath = "${env.JRE5_HOME}/lib/rt.jar"
else
options.bootstrapClasspath = files("${env.JRE5_HOME}/lib/rt.jar")
}
else if (sourceCompatibility == '1.4' && env.JRE4_HOME != null) {
options.fork = true
if (gver < '5.0')
options.bootClasspath = "${env.JRE4_HOME}/lib/rt.jar"
else
options.bootstrapClasspath = files("${env.JRE4_HOME}/lib/rt.jar")
}
else if (sourceCompatibility == '1.3' && env.JRE3_HOME != null) {
options.fork = true
if (gver < '5.0')
options.bootClasspath = "${env.JRE3_HOME}/lib/rt.jar"
else
options.bootstrapClasspath = files("${env.JRE3_HOME}/lib/rt.jar")
}
}
}
javadoc {
source = sourceSets.main.allJava
classpath = sourceSets.main.compileClasspath
options.charSet = documentEncoding
options.encoding = sourceEncoding
options.source = "1.5"
if (env.DEBUG != null) options.memberLevel = JavadocMemberLevel.PACKAGE
options.addStringOption('Xdoclint:none', '-quiet')
if (env.JDK6_HOME != null) executable = file("${env.JDK6_HOME}/bin/javadoc.exe")
doLast {
println "INFO: open ${project.docsDir}/javadoc/index.html"
}
}
task zipdoc(type: Zip, dependsOn: javadoc) {
description 'javadoc を zipでアーカイブする'
destinationDir = file('../apidocs')
classifier = "apidoc-" + new Date().format('yyyy-MMdd')
extension = 'zip'
from "${project.docsDir}/javadoc"
excludes = ['build', '.*']
doLast {
println "INFO: created: ${archivePath}"
}
}
task copylib(type: Copy) {
description '依存するライブラリを収集して lib フォルダに格納する'
// from (configurations.compile + configurations.testCompile)
from configurations.compile
into "lib"
}}
project(':json-org4') {
description 'A reference implementation of a JSON package in Java.'
version = '1.4.0'
sourceCompatibility = '1.4'
dependencies{
testCompile group: 'junit', name: 'junit', version: '3.+'
}
publishing {
publications {
mavenJava4(MavenPublication) {
from components.java
groupId = 'org.json'
// artifactId = archivesBaseName
artifactId = 'json'
version = '1.4.0'
}
}
repositories {
maven {
name = "localRepo"
url = uri("${userHome}/.m2/repository")
// url = uri("${buildDir}/repo")
// ここをローカルやリモートの Maven リポジトリ URL に変更可能
}
}}}
project(':json-org') {
description 'A reference implementation of a JSON package in Java.'
version = '1.5.0'
sourceCompatibility = '1.5'
def copiedSrcDir = "$buildDir/generated/src"
// sourceSets.main.java.srcDirs = [ '../json-org4/src', 'src' ]
// ↑ 期待した振る舞いにならない
sourceSets.main.java.srcDirs = [ copiedSrcDir ]
task copySources(type: Copy) {
// doFirst { file("$copiedSrcDir").mkdirs() }
from '../json-org4/src'
into "$copiedSrcDir"
println "org4/src copy to $copiedSrcDir"
}
task copySources2(type: Copy) {
from '../json-org/src'
into "$copiedSrcDir"
println "src copy to $copiedSrcDir"
}
compileJava.dependsOn copySources
copySources.dependsOn copySources2
dependencies{
// implementation project(":json-org4")
testCompile group: 'junit', name: 'junit', version: '3.+'
}
publishing {
publications {
mavenJava5(MavenPublication) {
from components.java
groupId = 'org.json'
// artifactId = archivesBaseName
artifactId = 'json'
version = '1.5.0'
}
}
repositories {
maven {
name = "localRepo"
url = uri("${userHome}/.m2/repository")
// url = uri("${buildDir}/repo")
// ここをローカルやリモートの Maven リポジトリ URL に変更可能
}
}}}