Skip to content

Latest spring-boot-gradle-plugin breaks Gradle maven-publish plugin #9135

@asarkar

Description

@asarkar

After upgrading to Boot 1.5.3, all our projects are now failing with the following error message:

Error:Cannot configure the 'publishing' extension after it has been accessed.

There is some discussion about this error here and on SO. Part of the problem is that the Gradle team is "incubating" the publishing plugin for the last 3-4 years. That said, the previous versions of Spring Boot plugin didn't trigger this error and now it does, leaving us dead in the water.

Here's a Gradle file that can be used to reproduce this issue.

buildscript {
	ext {
		springBootVersion = '1.5.3.RELEASE'
	}
	repositories {
		jcenter()
	}
	dependencies {
		classpath(
				"org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}"
		)
	}
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'

version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8

repositories {
	mavenCentral()
}


ext {
	springCloudVersion = 'Dalston.RELEASE'
	artifactoryUrl = 'http://doesnotexist'
}

dependencies {
	testCompile('org.springframework.boot:spring-boot-starter-test')
}

dependencyManagement {
	imports {
		mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
	}
}

apply plugin: 'maven-publish'

project.publishing.publications {
	mavenJava(MavenPublication) {
		from components.java
	}
}

def isSnapshot = project.version.toString().toLowerCase().contains('snapshot')
logger.info("Publishing project version: ${project.version}")
def artifactoryUrl = "${artifactoryUrl}/${isSnapshot ? 'libs-snapshot-local' : 'libs-release-local'}"

project.publishing.repositories {
	maven {
		credentials {
			username "whatever"
			password "shhh"
		}
		url "${artifactoryUrl}"
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions