| 1 |
apply plugin: 'java' |
| 2 |
apply plugin: 'idea' |
| 3 |
apply plugin: 'maven-publish' |
| 4 |
apply plugin: 'jacoco' |
| 5 |
apply plugin: 'distribution' |
| 6 |
apply plugin: 'checkstyle' |
| 7 |
|
| 8 |
sourceCompatibility = 1.6 |
| 9 |
targetCompatibility = 1.6 |
| 10 |
|
| 11 |
tasks.withType(JavaCompile) { options.encoding = "UTF-8" } |
| 12 |
|
| 13 |
task wrapper(type: Wrapper) { |
| 14 |
gradleVersion = '2.3' |
| 15 |
} |
| 16 |
|
| 17 |
repositories { |
| 18 |
mavenCentral() |
| 19 |
} |
| 20 |
|
| 21 |
sourceSets { |
| 22 |
main { |
| 23 |
java { |
| 24 |
srcDirs 'src', 'toolsrc', 'xmlimplsrc' |
| 25 |
} |
| 26 |
resources { |
| 27 |
srcDirs 'src', 'toolsrc' |
| 28 |
exclude "build.xml" |
| 29 |
exclude "manifest" |
| 30 |
} |
| 31 |
} |
| 32 |
|
| 33 |
test { |
| 34 |
java { |
| 35 |
srcDirs "testsrc", 'examples' |
| 36 |
exclude 'tests/**' |
| 37 |
} |
| 38 |
resources { |
| 39 |
srcDirs "testsrc" |
| 40 |
} |
| 41 |
} |
| 42 |
} |
| 43 |
|
| 44 |
dependencies { |
| 45 |
testCompile "junit:junit:4.12" |
| 46 |
testCompile "org.yaml:snakeyaml:1.15" |
| 47 |
testCompile "net.trajano.caliper:caliper:1.2.1" |
| 48 |
} |
| 49 |
|
| 50 |
if (JavaVersion.current().isJava8Compatible()) { |
| 51 |
allprojects { |
| 52 |
tasks.withType(Javadoc) { |
| 53 |
options.addStringOption('Xdoclint:none', '-quiet') |
| 54 |
} |
| 55 |
} |
| 56 |
} |
| 57 |
|
| 58 |
test { |
| 59 |
exclude "**/benchmarks/**" |
| 60 |
systemProperty 'java.awt.headless', 'true' |
| 61 |
systemProperty 'mozilla.js.tests', 'testsrc/tests' |
| 62 |
systemProperty 'mozilla.js.tests.timeout', 60000 |
| 63 |
systemProperty 'user.language', 'en' |
| 64 |
systemProperty 'user.country', 'US' |
| 65 |
systemProperty 'user.timezone', 'America/Los_Angeles' |
| 66 |
systemProperty 'file.encoding', 'UTF-8' |
| 67 |
maxHeapSize = "256m" |
| 68 |
testLogging.showStandardStreams = true |
| 69 |
} |
| 70 |
|
| 71 |
task sunSpiderBenchmark(type: JavaExec) { |
| 72 |
main "com.google.caliper.runner.CaliperMain" |
| 73 |
systemProperty 'rhino.benchmark.report', "${buildDir.absolutePath}" |
| 74 |
args "-Cresults.upload.class=org.mozilla.javascript.benchmarks.ResultPlotter", "-i", "runtime", "org.mozilla.javascript.benchmarks.CaliperSpiderBenchmark.Spider" |
| 75 |
classpath sourceSets.test.runtimeClasspath |
| 76 |
} |
| 77 |
|
| 78 |
task testBenchmark(type: Test) { |
| 79 |
jacoco { |
| 80 |
enabled = false |
| 81 |
} |
| 82 |
include "**/benchmarks/V8Benchmark*" |
| 83 |
systemProperty 'rhino.benchmark.report', "${buildDir.absolutePath}" |
| 84 |
systemProperty 'file.encoding', 'UTF-8' |
| 85 |
workingDir = file("testsrc/benchmarks") |
| 86 |
maxHeapSize = "256m" |
| 87 |
testLogging.showStandardStreams = true |
| 88 |
forkEvery = 1 |
| 89 |
} |
| 90 |
testBenchmark.dependsOn sunSpiderBenchmark |
| 91 |
|
| 92 |
task microBenchmark(type: JavaExec) { |
| 93 |
main "com.google.caliper.runner.CaliperMain" |
| 94 |
args "-i", "runtime", "org.mozilla.javascript.benchmarks.CaliperObjectBenchmark.FieldAccess", "-DstringKeys=100,1000", "-DintKeys=0,10,1000" |
| 95 |
classpath sourceSets.test.runtimeClasspath |
| 96 |
} |
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
idea { |
| 101 |
module { |
| 102 |
excludeDirs += file('testsrc/tests/src') |
| 103 |
excludeDirs += file('buildGradle') |
| 104 |
excludeDirs += file('build') |
| 105 |
excludeDirs += file('.idea') |
| 106 |
excludeDirs += file('lib') |
| 107 |
} |
| 108 |
} |
| 109 |
|
| 110 |
jar { |
| 111 |
from "LICENSE.txt" |
| 112 |
manifest { |
| 113 |
attributes( |
| 114 |
"Manifest-Version": "1.0", |
| 115 |
"Main-Class": "org.mozilla.javascript.tools.shell.Main", |
| 116 |
"Implementation-Version": project.version, |
| 117 |
"Implementation-Title": "Mozilla Rhino", |
| 118 |
"Implementation-Vendor": "Mozilla Foundation", |
| 119 |
"Implementation-URL": "http://www.mozilla.org/rhino", |
| 120 |
"Built-Date": new Date().format("yyyy-MM-dd"), |
| 121 |
"Built-Time": new Date().format("HH:mm:ss") |
| 122 |
) |
| 123 |
} |
| 124 |
} |
| 125 |
|
| 126 |
task sourceJar(type: Jar) { |
| 127 |
from sourceSets.main.allJava |
| 128 |
} |
| 129 |
|
| 130 |
task rhinoJavadoc(type: Javadoc) { |
| 131 |
source = sourceSets.main.allJava |
| 132 |
if (JavaVersion.current().isJava8Compatible()) { |
| 133 |
options.addStringOption('Xdoclint:none', '-quiet') |
| 134 |
} |
| 135 |
} |
| 136 |
|
| 137 |
task rhinoJavadocJar(type: Jar, dependsOn: rhinoJavadoc) { |
| 138 |
from rhinoJavadoc.destinationDir |
| 139 |
} |
| 140 |
|
| 141 |
publishing { |
| 142 |
publications { |
| 143 |
rhino(MavenPublication) { |
| 144 |
groupId 'org.mozilla' |
| 145 |
artifactId 'rhino' |
| 146 |
|
| 147 |
pom.withXml { |
| 148 |
def root = asNode() |
| 149 |
|
| 150 |
root.appendNode('description', """ |
| 151 |
Rhino is an open-source implementation of JavaScript written entirely in Java. |
| 152 |
It is typically embedded into Java applications to provide scripting to end users. |
| 153 |
""") |
| 154 |
root.appendNode("url", "https://developer.mozilla.org/en/Rhino") |
| 155 |
|
| 156 |
def p = root.appendNode("parent") |
| 157 |
p.appendNode("groupId", "org.sonatype.oss") |
| 158 |
p.appendNode("artifactId", "oss-parent") |
| 159 |
p.appendNode("version", "7") |
| 160 |
|
| 161 |
def l = root.appendNode("licenses").appendNode("license") |
| 162 |
l.appendNode("name", "Mozilla Public License, Version 2.0") |
| 163 |
l.appendNode("url", "http://www.mozilla.org/MPL/2.0/index.txt") |
| 164 |
|
| 165 |
def scm = root.appendNode("scm") |
| 166 |
scm.appendNode("connection", "scm:git:[email protected]:mozilla/rhino.git") |
| 167 |
scm.appendNode("developerConnection", "scm:git:[email protected]:mozilla/rhino.git") |
| 168 |
scm.appendNode("url", "[email protected]:mozilla/rhino.git") |
| 169 |
|
| 170 |
def o = root.appendNode("organization") |
| 171 |
o.appendNode("name", "The Mozilla Foundation") |
| 172 |
o.appendNode("url", "http://www.mozilla.org") |
| 173 |
|
| 174 |
} |
| 175 |
from components.java |
| 176 |
artifact sourceJar { |
| 177 |
classifier "sources" |
| 178 |
} |
| 179 |
artifact rhinoJavadocJar { |
| 180 |
classifier "javadoc" |
| 181 |
} |
| 182 |
} |
| 183 |
} |
| 184 |
|
| 185 |
if (project.hasProperty("mavenPassword")) { |
| 186 |
repositories { |
| 187 |
maven { |
| 188 |
credentials { |
| 189 |
username mavenUser |
| 190 |
password mavenPassword |
| 191 |
} |
| 192 |
if (project.version.endsWith('-SNAPSHOT')) { |
| 193 |
url mavenSnapshotRepo |
| 194 |
} else { |
| 195 |
url mavenReleaseRepo |
| 196 |
} |
| 197 |
} |
| 198 |
} |
| 199 |
} |
| 200 |
} |
| 201 |
|
| 202 |
jacoco { |
| 203 |
toolVersion = "0.7.4.201502262128" |
| 204 |
} |
| 205 |
|
| 206 |
jacocoTestReport.dependsOn test |
| 207 |
jacocoTestReport { |
| 208 |
reports { |
| 209 |
html.destination "${buildDir}/jacocoHtml" |
| 210 |
} |
| 211 |
} |
| 212 |
|
| 213 |
checkstyle { |
| 214 |
configFile = file("${projectDir}/checkstyle.xml") |
| 215 |
sourceSets = [project.sourceSets.main] |
| 216 |
} |
| 217 |
|
| 218 |
distributions { |
| 219 |
main { |
| 220 |
contents { |
| 221 |
from(sourceSets.main.java) { |
| 222 |
exclude 'man' |
| 223 |
into 'rhino' + project.version + '/src' |
| 224 |
} |
| 225 |
from(sourceSets.main.resources) { |
| 226 |
exclude '**/*.java' |
| 227 |
into 'rhino' + project.version + '/src' |
| 228 |
} |
| 229 |
from(javadoc.destinationDir) { |
| 230 |
into 'rhino' + project.version + '/docs' |
| 231 |
} |
| 232 |
from(jar.outputs.files) { |
| 233 |
into 'rhino' + project.version + '/lib' |
| 234 |
} |
| 235 |
from(sourceSets.main.allSource) { |
| 236 |
include 'man/*.1' |
| 237 |
into 'rhino' + project.version |
| 238 |
} |
| 239 |
from(file(".")) { |
| 240 |
include '*.txt', '*.md', 'build.gradle', 'build.properties', 'gradle.properties', |
| 241 |
'gradle/**', 'gradlew' |
| 242 |
into 'rhino' + project.version |
| 243 |
} |
| 244 |
into "/" |
| 245 |
} |
| 246 |
} |
| 247 |
} |
| 248 |
|
| 249 |
distZip.dependsOn javadoc, jar |