First I am new to Gradle and I am lets say not your best Java programmer. I am trying to convert my Niagara AX modules and an having trouble making the jar file.
Computer: Win 8.1 Pro 64 bit.
Gradle: Ver 2.6
IDE:Intellij 15.0.3
My Gradle Build:
ext {
niagaraHome = System.getenv(“niagara_home”)
if (niagaraHome == null) {
logger.error(“niagara_home environment variable not set”)
}
}
//to enable idea/intellij or eclipse support, un-comment the lines below
apply from: “${System.getenv(“niagara_home”)}/etc/gradle/idea.gradle”
// apply from: “${System.getenv(“niagara_home”)}/etc/gradle/eclipse.gradle”
gradle.beforeProject { p ->
configure§ {
def vendorSettings = file("${rootDir}/vendor.gradle")
if (vendorSettings.exists()) {
apply from: vendorSettings
}
apply from: “${System.getenv(“niagara_home”)}/etc/gradle/niagara.gradle”
}
}
tasks.addRule(""“
Pattern: [jar[Test]|clean|]/[path]: Run a Gradle task against
a set of modules rooted at path.
”"") { String taskName ->
def matcher = taskName =~ /(.?)(Test)?/(.)/
if (matcher) {
def command = matcher.group(1)
def includeTestModules = matcher.group(2) == “Test"
def path = file(”${projectDir}/${matcher.group(3)}").toPath()
assert path.toFile().exists()
def targetProjects = subprojects.findAll {
it.projectDir.toPath().startsWith(path) }
// default is build command and build is an alias for Gradle"s jar task
if (command.isEmpty() || command == “build”) { command = “jar” }
// Create task for subproject
task(taskName, dependsOn: targetProjects.tasks[command])
if (includeTestModules && command == “jar”) {
tasks[taskName].dependsOn targetProjects.moduleTestJar
}
}
}
My Gradle settingd:
import groovy.io.FileVisitResult
import groovy.io.FileType
def discoveredProjects = [:] as Map<String, File>
ext {
// This will include ALL sub-folders as sub-projects.
niagaraRoots = [’.’]
// CONFIGURE any directories to exclude from search for nested sub-projects
excludeDirs = ['.hg', 'build', 'out', 'src', 'srcTest']
}
// OR set the ‘userRepos’ gradle property.
//
if (hasProperty(‘userRepos’)) {
settings.ext.niagaraRoots += userRepos.split(",").collect()
}
// my-settings.gradle.
//
def mySettings = file(‘my-settings.gradle’)
if (mySettings.exists()) {
apply from: mySettings
}
// DO NOT MODIFY the niagaraRoots configuration
niagaraRoots.collect({ file(it) }).findAll({ it.exists() }).each { File projectRoot ->
projectRoot.traverse(
type: FileType.DIRECTORIES,
preRoot: true,
preDir: { File projectDir ->
def projectName = projectDir.name
if (excludeDirs.contains(projectName)) {
return FileVisitResult.SKIP_SUBTREE
}
File buildScript = new File(projectDir, "${projectName}.gradle")
if (buildScript.exists()) {
discoveredProjects[projectName] = projectDir
include projectName
return FileVisitResult.SKIP_SUBTREE
}
}
)
}
// root project name
rootProject.name = 'FireFoxxTools’
rootProject.children.each { project ->
project.projectDir = discoveredProjects[project.name]
project.buildFileName = "${project.name}.gradle"
assert project.projectDir.isDirectory()
assert project.buildFile.isFile()
}
My error:
Microsoft Windows [Version 6.3.9600]
© 2013 Microsoft Corporation. All rights reserved.
c:\niagara\niagara-4.1.27.16>cd c:\N4_Projects\FireFoxxTools
c:\N4_Projects\FireFoxxTools>gradlew clean jar
FAILURE: Build failed with an exception.
-
What went wrong:
Task ‘clean’ is ambiguous in root project ‘FireFoxxTools’. Candidates are: ‘cleanIdea’, ‘cleanIdeaModule’, ‘cleanIdeaProject’, ‘cleanIdeaWorkspace’. -
Try:
Run gradlew tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 6.224 secs
c:\N4_Projects\FireFoxxTools>