{"action":"opened","issue":{"url":"https://api.github.com/repos/bmuschko/gradle-docker-plugin/issues/387","repository_url":"https://api.github.com/repos/bmuschko/gradle-docker-plugin","labels_url":"https://api.github.com/repos/bmuschko/gradle-docker-plugin/issues/387/labels{/name}","comments_url":"https://api.github.com/repos/bmuschko/gradle-docker-plugin/issues/387/comments","events_url":"https://api.github.com/repos/bmuschko/gradle-docker-plugin/issues/387/events","html_url":"https://github.com/bmuschko/gradle-docker-plugin/issues/387","id":234119280,"number":387,"title":"DockerBuildIMage on subprojects fails with annot invoke method withClasspath() on null object","user":{"login":"seb-koch","id":19778637,"avatar_url":"https://avatars0.githubusercontent.com/u/19778637?v=3","gravatar_id":"","url":"https://api.github.com/users/seb-koch","html_url":"https://github.com/seb-koch","followers_url":"https://api.github.com/users/seb-koch/followers","following_url":"https://api.github.com/users/seb-koch/following{/other_user}","gists_url":"https://api.github.com/users/seb-koch/gists{/gist_id}","starred_url":"https://api.github.com/users/seb-koch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seb-koch/subscriptions","organizations_url":"https://api.github.com/users/seb-koch/orgs","repos_url":"https://api.github.com/users/seb-koch/repos","events_url":"https://api.github.com/users/seb-koch/events{/privacy}","received_events_url":"https://api.github.com/users/seb-koch/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-06-07T07:40:40Z","updated_at":"2017-06-07T07:40:40Z","closed_at":null,"body":"I am having an issue that was reported several times in a similar way, e.g. #280 but i wans't able to fix it with the described actions (e.g. different style of loading the plugin).\r\n\r\nI have a root project `sitecontroller` which has several docker images to be build in the subfolder `ci/images/<imagename>`. I included these subprojects in my `settings.gradle`\r\n\r\n```rootProject.name = 'sitecontroller'\r\n// sub projects for docker images\r\ninclude 'python-mosquitto', 'sitecontroller-mosquitto'\r\n```\r\n\r\nI'd like to reuse my docker tasks (building the image, starting containers and such) for these subprojects insteasd of having individual build files per subdirectory.\r\n\r\nMy simple build task runs fine for the root project but fails on the subprojects and i believe it is due to the way i am loading the plugin and defining the dependencies. Please see my `build.gradle`below.\r\n\r\n```description = 'Bootstrapping'\r\n\r\n// import com.bmuschko.gradle.docker.tasks.container.*\r\nimport com.bmuschko.gradle.docker.tasks.image.*\r\n\r\nbuildscript {\r\n\trepositories {\r\n\t\tmavenCentral()\r\n\t\tmaven {\r\n\t\t\turl \"https://plugins.gradle.org/m2/\"\r\n\t\t}\r\n\t\trepositories {\r\n        jcenter()\r\n    }\r\n\t}\r\n\tdependencies {\r\n\t\tclasspath group: 'net.saliman', name: 'gradle-properties-plugin', version: '1.4.5'\r\n\t\tclasspath group: 'com.cinnober.gradle', name: 'semver-git', version: '2.2.+'\r\n\t\tclasspath 'com.bmuschko:gradle-docker-plugin:3.0.7'\r\n\t}\r\n}\r\napply plugin: 'net.saliman.properties'\r\napply plugin: 'com.cinnober.gradle.semver-git'\r\napply plugin: 'maven-publish'\r\napply plugin: com.bmuschko.gradle.docker.DockerRemoteApiPlugin\r\n\r\ndocker {\r\n\tregistryCredentials {\r\n\t\t\tusername = dockerRegistryUsername\r\n\t\t\tpassword = dockerRegistryPassword\r\n\t}\r\n}\r\n\r\next {\r\n\tauthor = 'azeti Networks AG'\r\n\tgitdir = '-C ' + file(\".git\")\r\n\tif (System.env.JENKINS_HOME?.trim()) {\r\n\t\tgitdir = ''\r\n\t}\r\n\trevision =     \"git ${gitdir} rev-list --count HEAD\".execute().text.trim()\r\n\thash =         \"git ${gitdir} rev-parse --short HEAD\".execute().text.trim()\r\n\tbuildversion = \"${revision}#${hash}\"\r\n\trevltags =     \"git ${gitdir} rev-list --tags --max-count=1\".execute().text.trim()\r\n\ttagversion =   \"git ${gitdir} describe --tags ${revltags}\".execute().text.trim()\r\n\tif (project.hasProperty('gitBranch')) {\r\n\t\tbranch = project.getProperty('gitBranch')\r\n\t} else {\r\n\t\tbranch = \"git rev-parse --abbrev-ref HEAD\".execute().text.trim()\r\n\t}\r\n\tbuildtime = new Date().format(\"yyyy-MM-dd' 'HH:mm:ssZ\")\r\n\r\n\t/* master = product releases\r\n\tdevelop = nightly builds, curring edge\r\n\tbranches = feature or task specific */\r\n\tif (branch.equals('master')) {\r\n\t\t// SiteController-install-1.4.0\r\n\t\tdockerTag = \"azeti/${project.name}:${version}\"\r\n\t} else if (branch.equals('develop')) {\r\n\t\t// SiteController-install-develop-1.4.0\r\n\t\tproject.version = \"develop-${project.version}\"\r\n\t\tdockerTag = \"azeti/${project.name}:latest\"\r\n\t} else {\r\n\t\t// SiteController-install-1.4.0-task__SC-914-foo-bar-lorem-ipsum\r\n\t\text.snapshotSuffix = branch.replace(\"/\", \"__\")\r\n\t\tproject.version = \"${version}-${ext.snapshotSuffix}\"\r\n\t\tdockerTag = \"azeti/${project.name}:${ext.snapshotSuffix}\"\r\n\t}\r\n\r\n\tpackageName = \"SiteController-install-${project.version}\"\r\n\r\n\tif (System.env.DOCKER_USERNAME) {\r\n\t\tdockerRegistryUsername  = System.env.DOCKER_USERNAME?:dockerRegistryUsername\r\n\t\tdockerRegistryPassword  = System.env.DOCKER_PASSWORD?:dockerRegistryPassword\r\n\t}\r\n}\r\n\r\ntask wrapper(type: Wrapper) {\r\n  gradleVersion = '3.3'\r\n}\r\n\r\nallprojects {\r\n\t// task build_DockerImage(type: DockerBuildImage, dependsOn: [copy_ImageSource, prepare_ImageConfig]) {\r\n\ttask build_DockerImage(type: DockerBuildImage) {\r\n\t\tgroup 'Docker'\r\n\t\tdescription \"Builds the docker image: ${dockerTag} locally\"\r\n\t\tprintln \"Project: ${rootProject.projectDir}/ci/images/${project.name}\"\r\n\t\tinputDir = file(\"${rootProject.projectDir}/ci/images/${project.name}\")\r\n\t\ttag = dockerTag\r\n\t}\r\n}\r\n```\r\n\r\nIt fails with the known `classPath() on null object`error.\r\n\r\n```\r\nroot@db8c18347695:/sitecontroller-build# ./gradlew build_DockerImage --stacktrace\r\nProject: /sitecontroller-build/ci/images/sitecontroller\r\nProject: /sitecontroller-build/ci/images/python-mosquitto\r\nProject: /sitecontroller-build/ci/images/sitecontroller-mosquitto\r\n:build_DockerImage\r\nBuilding image using context '/sitecontroller-build/ci/images/sitecontroller'.\r\nUsing tag 'azeti/sitecontroller:task__SC-924-bitbucket-pipelines-build' for image.\r\nStep 1/6 : FROM azeti/python-lib:1\r\n---> e5b575f9797f\r\nStep 2/6 : ENV INSTALL_PATH /opt/azeti\r\n---> Using cache\r\n---> c9718891bb74\r\nStep 3/6 : WORKDIR $INSTALL_PATH\r\n---> Using cache\r\n---> fd8480bd1e74\r\nStep 4/6 : COPY SiteController-install $INSTALL_PATH/SiteController\r\n---> Using cache\r\n---> 02772876fbf4\r\nStep 5/6 : COPY init/docker-entrypoint.sh /\r\n---> Using cache\r\n---> 20388e63fef3\r\nStep 6/6 : ENTRYPOINT /docker-entrypoint.sh\r\n---> Using cache\r\n---> 7f2eee05e1a9\r\nSuccessfully built 7f2eee05e1a9\r\nCreated image with ID '7f2eee05e1a9'.\r\n:python-mosquitto:build_DockerImage FAILED\r\n\r\nFAILURE: Build failed with an exception.\r\n\r\n* What went wrong:\r\nExecution failed for task ':python-mosquitto:build_DockerImage'.\r\n> Cannot invoke method withClasspath() on null object\r\n\r\n* Try:\r\nRun with --info or --debug option to get more log output.\r\n\r\n* Exception is:\r\norg.gradle.api.tasks.TaskExecutionException: Execution failed for task ':python-mosquitto:build_DockerImage'.\r\n        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:84)\r\n        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:55)\r\n        at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)\r\n        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)\r\n        at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)\r\n        at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:46)\r\n        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:51)\r\n        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)\r\n        at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)\r\n        at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)\r\n        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.execute(DefaultTaskGraphExecuter.java:236)\r\n        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.execute(DefaultTaskGraphExecuter.java:228)\r\n        at org.gradle.internal.Transformers$4.transform(Transformers.java:169)\r\n        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106)\r\n        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:61)\r\n        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:228)\r\n        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:215)\r\n        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:77)\r\n        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:58)\r\n        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:32)\r\n        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:113)\r\n        at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37)\r\n        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)\r\n        at org.gradle.execution.DefaultBuildExecuter.access$000(DefaultBuildExecuter.java:23)\r\n        at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.java:43)\r\n        at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)\r\n        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)\r\n        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:30)\r\n        at org.gradle.initialization.DefaultGradleLauncher$3.execute(DefaultGradleLauncher.java:196)\r\n        at org.gradle.initialization.DefaultGradleLauncher$3.execute(DefaultGradleLauncher.java:193)\r\n        at org.gradle.internal.Transformers$4.transform(Transformers.java:169)\r\n        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106)\r\n        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:56)\r\n        at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:193)\r\n        at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:119)\r\n        at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:102)\r\n        at org.gradle.launcher.exec.GradleBuildController.run(GradleBuildController.java:71)\r\n        at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)\r\n        at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)\r\n        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:41)\r\n        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)\r\n        at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:75)\r\n        at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:49)\r\n        at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:44)\r\n        at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:29)\r\n        at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:67)\r\n        at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)\r\n        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)\r\n        at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:47)\r\n        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)\r\n        at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)\r\n        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)\r\n        at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)\r\n        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)\r\n        at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)\r\n        at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)\r\n        at org.gradle.util.Swapper.swap(Swapper.java:38)\r\n        at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)\r\n        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)\r\n        at org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:55)\r\n        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)\r\n        at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60)\r\n        at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)\r\n        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)\r\n        at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:72)\r\n        at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)\r\n        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)\r\n        at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)\r\n        at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:297)\r\n        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)\r\n        at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)\r\nCaused by: java.lang.NullPointerException: Cannot invoke method withClasspath() on null object\r\n        at com.bmuschko.gradle.docker.utils.ThreadContextClassLoader$withClasspath.call(Unknown Source)\r\n        at com.bmuschko.gradle.docker.tasks.AbstractDockerRemoteApiTask.runInDockerClassPath(AbstractDockerRemoteApiTask.groovy:62)\r\n        at com.bmuschko.gradle.docker.tasks.AbstractDockerRemoteApiTask$runInDockerClassPath.callCurrent(Unknown Source)\r\n        at com.bmuschko.gradle.docker.tasks.AbstractDockerRemoteApiTask.runReactiveStream(AbstractDockerRemoteApiTask.groovy:56)\r\n        at com.bmuschko.gradle.docker.tasks.AbstractReactiveStreamsTask.start(AbstractReactiveStreamsTask.groovy:50)\r\n        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)\r\n        at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.doExecute(DefaultTaskClassInfoStore.java:141)\r\n        at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)\r\n        at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:123)\r\n        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:632)\r\n        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:615)\r\n        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:95)\r\n        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:76)\r\n        ... 70 more\r\n\r\n\r\nBUILD FAILED\r\n\r\nTotal time: 8.292 secs\r\n```"}}
{"actor":{"display_login":"seb-koch"}}