palantir / gradle-docker

a Gradle plugin for orchestrating docker builds and pushes.
Apache License 2.0
746 stars 159 forks source link

Caused by: java.lang.ClassNotFoundException: org.gradle.api.model.ObjectFactory #233

Open W0lfbane opened 5 years ago

W0lfbane commented 5 years ago

When I include id "com.palantir.docker" version "0.21.0" in my build.gradle, I am greeted with this error Caused by: java.lang.ClassNotFoundException: org.gradle.api.model.ObjectFactory.

This is the stacktrace:

org.gradle.api.plugins.InvalidPluginException: An exception occurred applying plugin request [id: 'com.palantir.docker', version: '0.21.0']
        at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.applyPlugin(DefaultPluginRequestApplicator.java:178)
        at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.applyPlugins(DefaultPluginRequestApplicator.java:130)
        at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:137)
        at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:38)
        at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:25)
        at org.gradle.configuration.project.ConfigureActionsProjectEvaluator.evaluate(ConfigureActionsProjectEvaluator.java:34)
        at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:55)
        at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:532)
        at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:93)
        at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:42)
        at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:35)
        at org.gradle.initialization.DefaultGradleLauncher$2.run(DefaultGradleLauncher.java:125)
        at org.gradle.internal.Factories$1.create(Factories.java:22)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:52)
        at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:122)
        at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:32)
        at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:99)
        at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:93)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:62)
        at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:93)
        at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:82)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:94)
        at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
        at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:43)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28)
        at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:75)
        at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:45)
        at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:51)
        at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:28)
        at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:43)
        at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:170)
        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237)
        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210)
        at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)
        at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
        at org.gradle.launcher.Main.doAction(Main.java:33)
        at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
        at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
        at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:30)
        at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:127)
        at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:56)
Caused by: org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin [id 'com.palantir.docker']
        at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:153)
        at org.gradle.api.internal.plugins.DefaultPluginManager.apply(DefaultPluginManager.java:112)
        at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator$5.run(DefaultPluginRequestApplicator.java:132)
        at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.applyPlugin(DefaultPluginRequestApplicator.java:166)
        ... 49 more
Caused by: org.gradle.api.plugins.PluginInstantiationException: Could not create plugin of type 'PalantirDockerPlugin'.
        at org.gradle.api.internal.plugins.DefaultPluginManager.instantiatePlugin(DefaultPluginManager.java:61)
        at org.gradle.api.internal.plugins.DefaultPluginManager.producePluginInstance(DefaultPluginManager.java:162)
        at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:131)
        ... 52 more
Caused by: java.lang.NoClassDefFoundError: org/gradle/api/model/ObjectFactory
        at org.gradle.api.internal.DependencyInjectingInstantiator.selectConstructor(DependencyInjectingInstantiator.java:83)
        at org.gradle.api.internal.DependencyInjectingInstantiator.newInstance(DependencyInjectingInstantiator.java:44)
        at org.gradle.api.internal.plugins.DefaultPluginManager.instantiatePlugin(DefaultPluginManager.java:59)
        ... 54 more
Caused by: java.lang.ClassNotFoundException: org.gradle.api.model.ObjectFactory
        ... 57 more

This is the build.gradle file:

import com.nike.retail.common.plugins.gradle.redwiggler.BuildInfo
import org.gradle.api.plugins.jetty.internal.Monitor

buildscript {
    apply from: file('gradle/buildscript.gradle'), to: buildscript
}

plugins {
    id "com.github.samueltbrown.cucumber" version "0.8"
    id "com.palantir.docker" version "0.21.0"
}

apply plugin: 'java'
apply plugin: 'scala'
apply plugin: 'jetty'
apply from: file('gradle/blueprint.gradle')
apply from: file('gradle/qma.gradle')
apply from: file('gradle/cucumber.gradle')
apply from: file('gradle/fortify.gradle')
apply from: file('gradle/performance.gradle')
apply plugin: 'scala'
apply plugin: 'com.nike.retail.common.plugins.gradle.cloudformation'
apply plugin: 'com.nike.retail.common.plugins.gradle.redwiggler'

cloudformation {
    dynamoPort = Integer.valueOf(freePort1)
}

redwiggler {
    dataDirectory = new File(redWigglerOutput)
    output = new File(redWigglerOutput, "redwiggler_report.html")
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

configurations {
    all*.exclude group: "ch.qos.logback", module: "logback-classic"
    all*.exclude group: "org.slf4j", module: "slf4j-simple"
    all*.exclude group: "org.slf4j", module: "slf4j-log4j12"
    all*.exclude group: "log4j"
    all*.exclude group: "com.netflix.rxjava", module: "rxjava-core"
    all*.exclude group: "com.nike.skeletor", module: "skeletor"
    all*.exclude group: "asm", module: "asm"
    all*.exclude group: "asm", module: "asm-all"
}

def cloudformationVersion = "[2.9.72, 3)"
configurations.all {
    resolutionStrategy {
        force "com.nike.sim:cloudformation-mock_2.11:$cloudformationVersion"
        force "com.nike.sim:microservice_2.11:$cloudformationVersion"
        force "com.nike.sim:template_2.11:$cloudformationVersion"
    }
}

configurations.all {
    resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}

dependencies {

    compile 'com.fasterxml.jackson.core:jackson-annotations:2.8.6'
    compile 'com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:2.8.6'
    compile 'com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:2.8.6'

    compile 'org.apache.commons:commons-lang3:3.4'
    compile 'com.nike.phylon:spindle-core:9.0.0.+'
    compile 'com.nike.phylon:spindle-dynamodb:9.0.0.+'
    compile 'com.amazonaws:aws-java-sdk-dynamodb:1.10.59'

    compile 'com.nike.retail:retail-common:4.2.113'

    compile "org.hibernate:hibernate-validator:5.1.3.Final"
    compile 'com.couchbase.client:java-client:2.1.4'
    compile 'io.reactivex:rxjava:1.0.14'

    runtime "com.nike.shera:shera:1.0.0.+"

    compile 'com.sun.jersey:jersey-servlet:1.19'
    compile 'com.netflix.karyon:karyon-core:1.0.27'

    testCompile 'com.nike.retail:retail-qa-common:2.+'
    testCompile "com.nike.redwiggler:redwiggler-restassured:${BuildInfo.RED_WIGGLER_VERSION}"

    testCompile 'nl.jqno.equalsverifier:equalsverifier:1.7.5'
    testCompile 'io.gatling.highcharts:gatling-charts-highcharts:2.0.0-RC2'
    testCompile 'org.assertj:assertj-core:2.0.0'
    testCompile 'info.cukes:cucumber-guice:1.2.2'
    testCompile 'info.cukes:cucumber-junit:1.2.2'
    testCompile 'org.apache.velocity:velocity:1.7'

    testRuntime "info.cukes:cucumber-html:0.2.3"
    testRuntime "javax.el:javax.el-api:2.2.4"
    testRuntime "org.glassfish.web:javax.el:2.2.4"

    runtime ('com.nike.monitoring:monitoring:1.3.0.+') {
        exclude group: 'com.netflix.karyon', module: 'karyon-core'
        exclude group: 'com.netflix.karyon', module: 'karyon-eureka'
        exclude group: 'com.netflix.karyon', module: 'karyon-spi'
    }

    runtime 'com.netflix.servo:servo-core:0.9.+'
    runtime 'com.netflix.servo:servo-graphite:0.9.+'
    runtime 'com.netflix.servo:servo-aws:0.9.+'
    runtime 'com.netflix.archaius:archaius-core:0.6.1'
    runtime 'com.netflix.archaius:archaius-aws:0.6.1'
    runtime 'com.netflix.eureka:eureka-client:1.1.138'
    runtime 'com.netflix.hystrix:hystrix-core:1.3.16'
    runtime 'com.netflix.ribbon:ribbon-core:0.3.12'
    runtime 'com.netflix.ribbon:ribbon-eureka:0.3.12'
    runtime 'com.netflix.ribbon:ribbon-httpclient:0.3.12'
    runtime 'com.netflix.governator:governator:1.3.0'

    runtime 'org.apache.xbean:xbean-finder:4.5'
    compile 'org.ow2.asm:asm:5.0.3'
    compile 'com.nike.ris:lls-publisher:2.1.+'
}

tasks.withType(Test) { systemProperty 'log4j.configurationFile', 'log4j2-local.xml' }

task jettyDaemon() {
    onlyIf {
        'localhost'.equalsIgnoreCase(System.getProperty('integration.server', 'localhost'))
    }
    description = 'Starts Jetty in daemon mode'
    group = 'web application'

    doLast {
        System.setProperty('archaius.deployment.applicationId', "cartonitemservice")
        System.setProperty('archaius.deployment.version', version)
        System.setProperty('archaius.deployment.environment', 'local')
        System.setProperty('log4j.configurationFile', 'log4j2-local.xml')

        jettyRun.daemon = true
    }

    finalizedBy jettyRun
}

jettyRun {
    doFirst {
        ant.replace(file: 'build/resources/main/log4j2-local.xml', token: '@@RELEASE@@', value: releaseVersion)
    }

    System.setProperty('archaius.deployment.applicationId', "cartonitemservice")
    System.setProperty('archaius.deployment.version', version)
    System.setProperty('archaius.deployment.environment', 'local')
    System.setProperty('log4j.configurationFile', 'log4j2-local.xml')
    System.setProperty('jettyHttpPort', jettyHttpPort)
    System.setProperty('movementServicePort', freePort2)
    System.setProperty('dynamodb.port', freePort1)
    System.setProperty('lls.endpoint', llsPublishEndpoint)
    System.setProperty('lls.port', freePort3)
    System.setProperty('sqs.port', freePort4)

    contextPath = '/'
}

[jettyRun]*.httpPort = Integer.valueOf(jettyHttpPort)
[jettyRun, jettyStop]*.stopPort = Integer.valueOf(jettyStopPort)
[jettyRun, jettyStop]*.stopKey = rootProject.name
[jettyRun]*.doLast {
    /**
     * When running Jetty in daemon mode a monitor for the stopPort is not started,
     * which prevent Jetty from stopping on jettyStop. Ensuring a monitor is in
     * place.
     */
    if (getStopPort() != null && getStopPort() > 0 && getStopKey() != null) {
        Monitor monitor = new Monitor(getStopPort(), getStopKey(), server.getProxiedObject());
        monitor.start();
    }
}

jettyStop {
    stopPort = Integer.valueOf(jettyStopPort)
    stopKey = rootProject.name
}

task integrationTest(dependsOn: ['cucumber']) {}

I am newish to gradle and I am probably just missing something silly.

Any help would be greatly appreciated, thank you.

gravelld commented 3 years ago

Getting the same thing. org.gradle.api.model.ObjectFactory was introduced in Gradle 4.0, but I'm using an older version. I guess it's that.