I’m writing some integration tests for a plugin using Nebula’s IntegrationSpec. I have a plugin that configures Protocol Buffers for a project and does something like this:
dependencies {
compile gradleApi()
compile 'com.google.protobuf:protobuf-gradle-plugin:0.7.7'
testCompile 'com.netflix.nebula:nebula-test:4.0.0'
}
@Override
void apply(Project project) {
project.allprojects {
it.getLogger().info("ProtosPlugin configuring ${it.name}")
it.apply plugin: 'com.google.protobuf'
protobuf {
generatedFilesBaseDir = "$projectDir/generated_protos"
...
}
}
and then my test:
class ProtosPluginTests extends IntegrationSpec {
def standardBuildFile = '''
apply plugin: 'protocol-buffers'
'''.stripIndent()
def 'can apply protos plugin and compile protos'() {
when:
buildFile << standardBuildFile
writeHelloWorld('project.hello')
writeProtoFile()
writeUnitTest(false)
then:
runTasksSuccessfully('assemble')
fileExists("build/classes/main/com/project/protos/services/HelloWorldProto.class")
}
}
When I run this test from IntelliJ, it works just fine but when I do ./gradlew test
it errors:
org.gradle.api.GradleException: Build aborted because of an internal error.
at nebula.test.functional.internal.DefaultExecutionResult.rethrowFailure(DefaultExecutionResult.groovy:97)
at nebula.test.IntegrationSpec.runTasksSuccessfully(IntegrationSpec.groovy:265)
... 32 more
Caused by: java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils
at com.google.protobuf.gradle.Utils.getConfigName(Utils.groovy:42)
... 50 more
Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang.StringUtils
... 93 more
It seems like the transitive dependencies from the com.google.protobuf
plugin do not get loaded when running the tests but I can’t seem to figure out why. Any thoughts? I’ve tried forking the tests to avoid class loader issues, but that didn’t seem to help.