spring-projects / spring-boot

Spring Boot helps you to create Spring-powered, production-grade applications and services with absolute minimum fuss.
https://spring.io/projects/spring-boot
Apache License 2.0
75.19k stars 40.69k forks source link

I am using Kotlin + Spring Boot Gradle Project , Getting error Cannot access 'publish': it is private in 'BootBuildImage' #25453

Closed pugazhendhit closed 3 years ago

pugazhendhit commented 3 years ago

I am using Kotlin + Spring Boot Gradle Project , Getting error Cannot access 'publish': it is private in 'BootBuildImage' when adding this BootBuildImage task plugin , any advise ?

build.gradle.kts:98:2: Cannot access 'publish': it is private in 'BootBuildImage'

image


import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.springframework.boot.gradle.tasks.bundling.BootBuildImage

plugins {
    id("org.springframework.boot") version "2.4.3"
    id("io.spring.dependency-management") version "1.0.10.RELEASE"
    kotlin("jvm") version "1.4.31"
    kotlin("plugin.spring") version "1.4.31"
}

repositories {
    mavenLocal()
    mavenCentral()
    maven("https://repo.spring.io/milestone")
    maven("https://repo.spring.io/snapshot")
}

dependencyManagement {
    imports {
        mavenBom("org.springframework.cloud:spring-cloud-dependencies:${Versions.springCloud}")
    }
}

dependencies {
    implementation("org.springframework.boot:spring-boot-starter-actuator")
    implementation("org.springframework.boot:spring-boot-starter-webflux")
    implementation("org.springframework.boot:spring-boot-starter-security")
    implementation("org.springframework.cloud:spring-cloud-stream")
    implementation("org.springframework.cloud:spring-cloud-starter-kubernetes")
    implementation("org.springframework.cloud:spring-cloud-starter-kubernetes-config")
    implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
    implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core")
    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor")
    implementation("io.projectreactor.kotlin:reactor-kotlin-extensions")
    implementation("net.logstash.logback:logstash-logback-encoder:${Versions.logback}")
    implementation ("org.projectlombok:lombok:${Versions.lombok}")
    annotationProcessor("org.springframework.boot:spring-boot-configuration-processor")
    testImplementation("org.springframework.boot:spring-boot-starter-test") {
        exclude(group = "org.junit.vintage", module = "junit-vintage-engine")
    }
    testImplementation("io.projectreactor:reactor-test")
    testImplementation("com.ninja-squad:springmockk:${Versions.springMock}")
}

tasks.getByName<org.springframework.boot.gradle.tasks.bundling.BootBuildImage>("bootBuildImage") {
    imageName = "docker.example.com/library/${project.name}"
    **publish = true**
    docker {
        publishRegistry {
            username = "user"
            password = "secret"
            url = "https://docker.example.com/v1/"
            email = "user@example.com"
        }
    }
}
jnizet commented 3 years ago

You simply have to use

isPublish = true

or

setPublish(true)
wilkinsona commented 3 years ago

Thanks, @jnizet.

wilkinsona commented 3 years ago

Our Kotlin example in the docs is wrong. We're missing a few tests in PackagingDocumentationTests as well.

jnizet commented 3 years ago

@wilkinsona Note that the wrong publish property is used in the plugin documentation. I'm working on a PR to fix it.

snicoll commented 3 years ago

Closing in favor of PR #25454