Gradle: unable to configure artifactory from external build script

I am new to gradle and would like to access my artificial repository. If I put all the configurations in one build script, the build will succeed. Here are the relevant parts of my build.gradle:

allprojects {
    apply plugin: 'java'
    apply plugin: 'eclipse'
    apply plugin: 'artifactory'
}

// ...

buildscript {
    repositories {
        maven { 
            url 'http://repo.jfrog.org/artifactory/gradle-plugins' 
        }

        maven {
            url artifactory_contextUrl + 'plugins-release'

            credentials {
                username = artifactory_user
                password = artifactory_password
            }
        }
    }

    dependencies {
        classpath(group: 'org.jfrog.buildinfo', name: 'build-info-extractor-gradle', version: '2.0.16')
    }
}


artifactory {
    contextUrl = artifactory_contextUrl

    publish {
        repository {
            repoKey = 'libs-release-local'
            username = artifactory_user
            password = artifactory_password
            maven = true
        }
    }

    resolve {
        repository {
            repoKey = 'libs-release'
            username = artifactory_user
            password = artifactory_password
            maven = true
        }
    }
}


dependencies {
    // My dependencies ...
}

// Rest of the build script ...

Now I would like to pull the artifactory part into a separate gradle script for a better organization. This is where the build goes wrong. It is very surprising that I get the following error, even if I copy the build.gradle file to foo.gradle and modify build.gradle to just contain a single line

apply from: 'foo.gradle'

Error

FAILURE: Build failed with an exception.

* Where:
Script '/path/to/my/project/foo.gradle' line: 5

* What went wrong:
A problem occurred evaluating script.
> Plugin with id 'artifactory' not found.

If this is not a mistake, can someone explain this gradle behavior apply fromand suggest a solution?

thank

+5
source share
2 answers

apply from , script , Gradle, , . buildscript script init script:

apply from : 'http://link.to/my/gradle.script'
+5

script:

buildscript {
    repositories {
         jcenter() 
         mavenCentral()
    }
    dependencies {
        classpath "com.adaptc.gradle:nexus-workflow:0.5"
        classpath "org.jfrog.buildinfo:build-info-extractor-gradle:2.2.4"
    }
}
apply plugin: org.jfrog.gradle.plugin.artifactory.ArtifactoryPublicationsPlugin
apply plugin: com.adaptc.gradle.nexusworkflow.NexusWorkflowPlugin

, Gradle , , .

Artifactory:

  • , .

  • artifactory-puplish.properties.

  • : implementation-class=org.jfrog.gradle.plugin.artifactory.ArtifactoryPublicationsPlugin

nexus-workflow , ,

plugins-gradle-master/nexus-workflow/src/main/groovy/com/adaptc/gradle/nexusworkflow/NexusWorkflowPlugin.groovy
+1

All Articles