All,
I have a simple multi project build that I want to add the “license” plugin to. Here is my main build.gradle file:
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
}
allprojects {
version = 0.1
repositories {
mavenCentral()
}
}
subprojects {
ext.configDir = new File(rootDir, 'config')
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply from: "$rootDir/gradle/cobertura.gradle"
apply from: "$rootDir/gradle/checkstyle.gradle"
apply from: "$rootDir/gradle/pmd.gradle"
apply from: "$rootDir/gradle/findbugs.gradle"
apply from: "$rootDir/gradle/license.gradle"
sourceCompatibility = 1.6
configurations {
provided {
description = 'similar to the maven provided scope'
transitive = true;
visible = true;
}
}
project.sourceSets {
main.compileClasspath += project.configurations.provided
main.runtimeClasspath += project.configurations.provided
test.compileClasspath += project.configurations.provided
test.runtimeClasspath += project.configurations.provided
}
group = 'com.mycompany.incubator'
sourceSets.test.java.srcDir 'src/main/java'
tasks.withType(Javadoc).each {
it.classpath = sourceSets.main.compileClasspath
}
}
Because there is not any actual code in the parent project, only the child projects need to have the additional java/eclipse/idea etc. plugins. I have tried to separate some of the additional tools into their own files. I’d like you to focus in on the license.gradle file:
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath 'nl.javadude.gradle.plugins:license-gradle-plugin:0.7.0'
}
}
apply plugin: 'license'
ext.licenseConfigDir = "$configDir/license"
license {
header new File(licenseConfigDir, 'HEADER')
ext.year = Calendar.getInstance().get(Calendar.YEAR)
skipExistingHeaders true
}
When I run “gradle tasks”, the build complains that “Plugin with id ‘license’ not found.”. Looking at the license.gradle file above, I am correctly adding it to the classpath of the build script, but it doesn’t seem to be working as expected. If I add the same buildscript/dependency to the main gradle file, everything works. Can someone help me understand why this doesn’t work the way I have it configured above?
Thanks,
Joe