The allprojects
closure in the root build.gradle
script defines configuration settings and tasks that are executed for each Commerce Store Accelerator module.
Plugin Configuration
The allprojects
closure applies three Gradle plugins that provide access to tasks that the Commerce Store Accelerator build process uses:
apply plugin: 'java' apply plugin: 'eclipse' apply plugin: com.eriwen.gradle.js.JsPlugin
The java
plugin includes tasks that compile classes, create JAR files, run unit tests, and so on. For more information on this plugin, see http://www.gradle.org/docs/current/userguide/java_plugin.html.
The eclipse
plugin generates files that are used by the Eclipse IDE. These files are necessary in order to build a Gradle project from within Eclipse. For more information on this plugin, see http://www.gradle.org/docs/current/userguide/eclipse_plugin.html.
The com.eriwen.gradle.js.JsPlugin
plugin is a third-party plugin that includes useful JavaScript tasks such as gradle jshint
, a task that validates JavaScript code style and formatting. For more information on this plugin, see https://github.com/eriwen/gradle-js-plugin.
Repository Configuration
The repositories
script block of the allprojects
task defines the public mavenCentral
repository as the location from which third-party libraries that the build tasks depend on, such as junit
, should be retrieved from:
repositories { mavenCentral() }
Java Source Code and Resource File Locations
Any Java source code that is required to build a module should be placed in that module’s /src/main/java
directory. The following configuration in the allprojects
task tells the Gradle build system to look in each module’s /src/main/java
directory for Java source code:
sourceSets.main.java.srcDirs = ["src/main/java"];
Likewise, the Gradle build system needs to know where to find resource files. Because Oracle Commerce resource files can be included in the Java source code, the Gradle build system needs to look in both the <module>/src/main/java
directories as well as in Gradle’s default location of <module>/src/main/resources
for resource files. The following configuration in the allprojects
task tells the Gradle build system to look in both locations for resource files:
sourceSets.main.resources.srcDirs = ["src/main/java", "src/main/resources"];
Dependencies Configuration
The specific JAR files, classpaths, and arguments used during the execution of various build process tasks are defined in the dependencies
script block of the allprojects
task:
dependencies { //------------------------- /** * Unit test dependencies. */ testCompile( [group: "junit", name: "junit", version: "4.11"], [group: "hsqldb", name: "hsqldb", version: "1.8.0.7"], [group: "org.apache.ddlutils", name: "ddlutils", version: "1.0"], files("$project.rootDir/lib/atgdust-1.2.2.jar") ) //------------------------- /** * Java compile dependencies. */ compile( files(dynamoclasspath.split(System.getProperty("path.separator")), "$project.rootDir/lib/testUtils-3.1.2.jar") ) //------------------------- /** * Java compilation configuration. */ compileJava { // Save the compiler from re-compiling everything, even if only one // Java source file changes. options.useDepend=true // Fork your compilation into a child process. options.fork = true } }
Logging Level for Unit Tests
The test
script block sets the logging level for unit tests to ensure that meaningful reasons are returned for failed tests. It also configures logging to record “PASSED” for unit tests that are successful.
test { testLogging { exceptionFormat 'full' events 'passed' }