Continuous Delivery pipeline - download from Artifactory - method war()

I asked this question as a reply to the blog that introduced Building a Continuous Delivery Pipeline with Gradle and Jenkins - https://discuss.gradle.org/t/building-a-continuous-delivery-pipeline-with-gradle-and-jenkins/9488 though with no reply I’m creating a separate topic for this.

At around 1:06 in this video is this gradle script to download from Artifactory:

configurations {
	war
}

dependencies {
	war "$project.group:$project.name:$project.version"
}

task downloadBinaryArchive(type: Copy) {
	from configurations.war
	into "$buildDir/download"
}

When I run this I get:

A problem occurred evaluating root project 'the_project'.
> Could not find method war() for arguments [the_group:the_project:1.0] on root project 'the_project'.

I have that code in my main build.gradle script that includes the war plugin.

What am I missing?

I get the impression that the example above (which I can find no issues with) is slightly different than how it is arranged in your actual build script. Are you perhaps trying to declare the configuration after the dependency?

No, the order I’ve written is what I have. If I remove the configuration part I still receive the same error - like the configuration isn’t being picked up.

Any other ideas?

I’ve gone back to basics. I created a new WEB Spring Starter project and inserted those same lines. There is NO LOCATION i can insert those lines that doesn’t give me that same error. Can you see what is wrong with this simple example?:

buildscript {
    ext {
        springBootVersion = '1.2.5.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 
        classpath("io.spring.gradle:dependency-management-plugin:0.5.2.RELEASE")
    }
}

apply plugin: 'java'
apply plugin: 'eclipse-wtp'
apply plugin: 'idea'
apply plugin: 'spring-boot' 
apply plugin: 'io.spring.dependency-management' 
apply plugin: 'war'

version=1.0
group="tester"

war {
    baseName = 'demo'
    version = '0.0.1-SNAPSHOT'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8


repositories {
    mavenCentral()
}

configurations {
    providedRuntime
}

configurations {
 	war
}

dependencies {
	war "$project.group:$project.name:$project.version"
}

task downloadBinaryArchive(type: Copy) {
	from configurations.war
 	into "$buildDir/download"
}


dependencies {
    compile("org.springframework.boot:spring-boot-starter-web")
    providedRuntime("org.springframework.boot:spring-boot-starter-tomcat")
    testCompile("org.springframework.boot:spring-boot-starter-test") 
}


eclipse {
    classpath {
         containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER')
         containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8'
    }
}

task wrapper(type: Wrapper) {
    gradleVersion = '2.3'
}

Solved.

When I changed the configuration name from war to ANYTHING ELSE (except say resources and possibly other reserved words) it worked as expected. So this worked:

repositories {
    maven { url "${artifactory_contextUrl}/libs-release-local" }	
    mavenCentral()
}
configurations {
    downloadWar
}

dependencies {
	downloadWar(group: 'the_group', name: 'the_name', version: '1.0')
    // OR this of course
	downloadWar('the_group:the_name:1.0')
}

task downloadBinaryArchive(type: Copy) {
	from configurations.downloadWar
 	into "$buildDir/download"
}

NOTE that I needed to choose an artifact that exists in the artifactory repository or else I received an error about could not resolve all dependencies.

Now the question is, why does war configuration work for Peter N but not for I? I tried Gradle 2.3, 2.4 and 2.5.