Gradle will not make a jar

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>

Do you actually have the java plugin applied in your build? I don’t see it anywhere in what you posted.

apply plugin: 'java'

The java plugin contributes the jar task, although you’re not even getting to the point of trying to run jar due to the error finding a clean task. The java plugin is one way for a clean task to be added as well.

Thanks that produced a jar file, not where I wanted it and it only had the manifest in it, but it is progress.

The “jar” task is provided by a task rule it looks like. The rule delegates to target projects.

@firefoxx I have two suggestions:

  1. Please indent the sample code with 4 spaces so that the whitespace isn’t collapsed. At the moment, it’s hard to read the code.

  2. Try to explain what you are trying to achieve with this in a bit more detail. Is this a multiproject build? Are they all Java projects? If it is a multiproject build, are they your projects or third-party ones? Is this based on something that Niagara AX provides?

The build looks very unconventional for Gradle, so there may be a better way of doing what you want.

BTW, the error message you’re seeing is unrelated to the jar task. As the message says, you have multiple tasks that start with the text “clean”, so Gradle doesn’t know which one you want to execute. Applying the Java plugin fixes that problem because it adds a task whose name is exactly “clean”. When there’s an exact match between the task name you requested and a task in the build, there is no ambiguity.

First thank you for responding.
So what is happening here is that Niagara has changed the way they are building the .jar file or modules that are used for their system and have adopted the gradle build. Prior to this we could build are own modules using Eclipse and add are 3rd party modules to the system. They just moved from their AX version to the N4 release and everything has changed we are now required to use gradle to build are 3rd party modules and this is proving difficult. Now we have to produce two jar files where before there was only one, now I must have a FireFoxxTools-rt.jar and a FireFoxxTools-wb.jar. The build file that I am using came from a third party that claimed this is the way to do it, but it is not working and I cannot get support from the third party. So far support from Niagara has been poor on this as I have not been able to find any example files on the best way to do this.

I see that this is a multiproject build, where each subdirectory of the root is treated as a subproject. It does not build a standalone project. You’ll need a Gradle build file for your module that creates the two jar files.

I’m afraid this is something specific to Niagara, so you need to get help from someone who knows the Niagara system. Sorry.