Existing plugins broken by leakage of org/gradle/api/internal/DynamicObject into bytecode


(Danny Thomas) #1

Appears that some call sites caused this class to be included in generated bytecode, and the relocation of the class for Gradle 3.0 causes them to break:

https://travis-ci.org/nebula-plugins/gradle-ospackage-plugin/builds/139806511

General error during class generation: java.lang.NoClassDefFoundError: Unable to load class com.bmuschko.gradle.docker.tasks.image.DockerBuildImage due to missing dependency org/gradle/api/internal/DynamicObject

java.lang.RuntimeException: java.lang.NoClassDefFoundError: Unable to load class com.bmuschko.gradle.docker.tasks.image.DockerBuildImage due to missing dependency org/gradle/api/internal/DynamicObject
	at org.codehaus.groovy.control.CompilationUnit.convertUncaughtExceptionToCompilationError(CompilationUnit.java:1089)
	at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1067)
	at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:591)
	at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:569)
	at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:546)
	at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:525)
	at org.gradle.api.internal.tasks.compile.ApiGroovyCompiler.execute(ApiGroovyCompiler.java:173)
	at org.gradle.api.internal.tasks.compile.ApiGroovyCompiler.execute(ApiGroovyCompiler.java:59)
	at org.gradle.api.internal.tasks.compile.daemon.CompilerDaemonServer.execute(CompilerDaemonServer.java:31)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.gradle.process.internal.worker.request.WorkerAction.run(WorkerAction.java:87)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
	at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:377)
	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
	at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoClassDefFoundError: Unable to load class com.bmuschko.gradle.docker.tasks.image.DockerBuildImage due to missing dependency org/gradle/api/internal/DynamicObject
	at org.codehaus.groovy.vmplugin.v5.Java5.configureClassNode(Java5.java:392)
	at org.codehaus.groovy.ast.ClassNode.lazyClassInit(ClassNode.java:277)
	at org.codehaus.groovy.ast.ClassNode.getUnresolvedSuperClass(ClassNode.java:1006)
	at org.codehaus.groovy.ast.ClassNode.getUnresolvedSuperClass(ClassNode.java:1001)
	at org.codehaus.groovy.ast.ClassNode.getSuperClass(ClassNode.java:995)
	at org.codehaus.groovy.ast.ClassNode.isDerivedFrom(ClassNode.java:938)
	at org.codehaus.groovy.classgen.asm.InvocationWriter.castToNonPrimitiveIfNecessary(InvocationWriter.java:858)
	at org.codehaus.groovy.classgen.asm.OperandStack.doConvertAndCast(OperandStack.java:345)
	at org.codehaus.groovy.classgen.asm.OperandStack.doGroovyCast(OperandStack.java:282)
	at org.codehaus.groovy.classgen.asm.BinaryExpressionHelper.evaluateEqual(BinaryExpressionHelper.java:344)
	at org.codehaus.groovy.classgen.AsmClassGenerator.visitDeclarationExpression(AsmClassGenerator.java:633)
	at org.codehaus.groovy.ast.expr.DeclarationExpression.visit(DeclarationExpression.java:89)
	at org.codehaus.groovy.classgen.asm.StatementWriter.writeExpressionStatement(StatementWriter.java:612)
	at org.codehaus.groovy.classgen.asm.OptimizingStatementWriter.writeExpressionStatement(OptimizingStatementWriter.java:357)
	at org.codehaus.groovy.classgen.AsmClassGenerator.visitExpressionStatement(AsmClassGenerator.java:620)
	at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:42)
	at org.codehaus.groovy.classgen.asm.StatementWriter.writeBlockStatement(StatementWriter.java:84)
	at org.codehaus.groovy.classgen.asm.OptimizingStatementWriter.writeBlockStatement(OptimizingStatementWriter.java:158)
	at org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:566)
	at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:71)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:104)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:115)
	at org.codehaus.groovy.classgen.AsmClassGenerator.visitStdMethod(AsmClassGenerator.java:430)
	at org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:387)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:126)
Exception executing org.gradle.api.internal.tasks.compile.ApiGroovyCompiler@607425eb in compiler daemon: org.gradle.api.internal.tasks.compile.CompilationFailedException: Compilation failed; see the compiler error output for details..	at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethod(AsmClassGenerator.java:507)

	at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1078)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:53)
	at org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:233)
	at org.codehaus.groovy.control.CompilationUnit$16.call(CompilationUnit.java:813)
	at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1053)
	... 24 more

(Eric Wendelin) #2

Thanks Danny for reporting.

I’ve created GRADLE-3493 to be fixed for 3.0.

Cheers,
Eric


(Benjamin Muschko) #3

Hi Danny,

The Docker plugin version you are using is fairly old. I tried the OSPackage plugin with the latest version of the Docker plugin (3.0.1) and it compiles fine. Could you please upgrade?

BTW: Somewhere in your plugin stack you are forcing the version “2.0.3” of the Docker plugin so just changing the compile dependency won’t help.

:dependencyInsight
com.bmuschko:gradle-docker-plugin:2.0.3 (selected by rule)

com.bmuschko:gradle-docker-plugin:3.0.1 -> 2.0.3
\--- compile

Cheers,

Ben


(Benjamin Muschko) #4

Hi Danny,

Did an upgrade fix your issue?

Thanks,

Ben


(Rob Spieldenner) #5

Updating the gradle-docker-plugin to 3.0.1 fixes the issue. Thanks