1 /* 2 * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 /** 27 * Build file for buildSrc project. The buildSrc project contains the annotation 28 * processor that is used to generate the decora compiler used for effects, 29 * and various annotations we use for FXML, etc. It also contains build script logic such 30 * as for compiling native code. Nothing in buildSrc should *ever* be shipped with the runtime. 31 */ 32 33 /** 34 * If the given named property is not defined, then this method will define 35 * it with the given defaultValue. Any properties defined by this method can 36 * be substituted on the command line by using -P, or by specifying a 37 * gradle.properties file in the user home dir 38 * 39 * @param name The name of the property to define 40 * @param defaultValue The default value to assign the property 41 */ 42 void defineProperty(String name, String defaultValue) { 43 if (!project.hasProperty(name)) { 44 project.ext.set(name, defaultValue); 45 } 46 } 47 48 def closedDir = file("../../rt-closed") 49 def buildClosed = closedDir.isDirectory() 50 51 if (buildClosed) { 52 File supplementalBuildFile = new File("../../rt-closed/closed-properties.gradle"); 53 apply from: supplementalBuildFile 54 } 55 56 apply plugin: "java" 57 58 59 repositories { 60 if (buildClosed) { 61 ivy { 62 url jfxRepositoryURL 63 layout "pattern", { 64 artifact "[artifact]-[revision].[ext]" 65 artifact "[artifact].[ext]" 66 } 67 } 68 } else { 69 mavenCentral() 70 } 71 } 72 73 // Include the to-be-generated antlr source files in the source set. We will generate 74 // the antlr sources first before compilation. 75 sourceSets { 76 main.java.srcDirs = ["src/main/java", "$buildDir/generated-src/antlr"] 77 } 78 79 // Workaround for lack of Antlr 3 support in Gradle. By defining a configuration, 80 // we can then give it a class path and use that classpath to execute a java command 81 getConfigurations().create("antlr3"); 82 83 dependencies { 84 compile group: "org.antlr", name: "antlr", version: "3.1.3" 85 testCompile group: "junit", name: "junit", version: "4.8.2" 86 antlr3 group: "org.antlr", name: "antlr-runtime", version: "3.1.3" 87 antlr3 group: "org.antlr", name: "stringtemplate", version: "3.2" 88 antlr3 group: "org.antlr", name: "antlr", version: "3.1.3" 89 } 90 91 // At the moment the ASM library shipped with Gradle that is used to 92 // discover the different test classes fails on Java 8, so in order 93 // to have sourceCompatibility set to 1.8 I have to also turn scanForClasses off 94 // and manually specify the includes / excludes. At the moment we use 95 // Java 7 but when we switch to 8 this will be needed, and probably again when 96 // we start building with Java 9. 97 test { 98 enableAssertions = true; 99 testLogging.exceptionFormat = "full"; 100 scanForTestClasses = false; 101 include("**/*Test.*"); 102 exclude("**/DepthTest.*"); 103 exclude("**/*Abstract*.*"); 104 } 105 106 // This is the task that will call antlr to generate the sources 107 task generateGrammarSource(type: JavaExec) { 108 description = "Generate JSL parser from Antlr3 grammars" 109 String dest = "$buildDir/generated-src/antlr/com/sun/scenario/effect/compiler" 110 String src = "src/main/antlr" 111 inputs.dir file(src) 112 outputs.dir file(dest) 113 def grammars = fileTree(src).include("**/*.g") 114 main = "org.antlr.Tool" 115 classpath = configurations.antlr3 116 args = ["-o", dest, grammars.files].flatten() 117 // See RT-30955. This should be removed when JDK-8015656 is fixed 118 ignoreExitValue = true 119 } 120 121 // Configure the compileJava task so that it relies on the task for generating 122 // the grammar source (gotta have it prior to compilation) 123 compileJava { 124 dependsOn(generateGrammarSource); 125 }