Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spring Boot Gradle plugin: bootJar.enabled=false not working #10238

Closed
xmlking opened this issue Sep 9, 2017 · 4 comments
Closed

Spring Boot Gradle plugin: bootJar.enabled=false not working #10238

xmlking opened this issue Sep 9, 2017 · 4 comments
Labels
status: invalid An issue that we don't feel is valid

Comments

@xmlking
Copy link

xmlking commented Sep 9, 2017

What is equivalent for bootRepackage.enabled=false for Spring Boot's latest Gradle plugin (2.0.0) ? bootJar.enabled=false is not working

More details:
gradle/kotlin-dsl-samples#488

Full project to reproduce:
https://github.com/xmlking/reactive-apps/blob/master/shared/build.gradle.kts

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Sep 9, 2017
@wilkinsona
Copy link
Member

I don't think we need two issues to track the same problem. Given that this works for you with earlier versions of Gradle and that the BootJar task inherits the enabled property from Gradle's AbstractTask, I am going to close this one in favour of the Gradle issue you also opened.

You may want to consider improving your build's configuration so that Spring Boot's plugin isn't applied to the shared project. It doesn't appear to be a Spring Boot application so applying the plugin is counter-productive. If you still wish to use Spring Boot's dependency management, you could import the spring-boot-dependencies bom using the dependency management plugin (which I see you are already using directly).

@wilkinsona wilkinsona added status: invalid An issue that we don't feel is valid and removed status: waiting-for-triage An issue we've not yet triaged labels Sep 9, 2017
@xmlking
Copy link
Author

xmlking commented Sep 10, 2017

Agree. Looks like it is gradle kotlin DSL issue.
The following worked.

import org.gradle.api.tasks.bundling.Jar
import org.springframework.boot.gradle.tasks.bundling.BootJar

val jar: Jar by tasks
val bootJar: BootJar by tasks

bootJar.enabled = false
jar.enabled = true

@jelovac
Copy link

jelovac commented Oct 20, 2019

I've been using it like this in latest build.gradle.kts in order to be able to compile to jar Spring Boot 2.x based library:

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

tasks.getByName<BootJar>("bootJar") {
    enabled = false
}

tasks.getByName<Jar>("jar") {
    enabled = true
}

@ixre
Copy link

ixre commented Oct 26, 2020

I tried some times and success finally! see below code:

plugins{
    base
    id("org.springframework.boot") version("2.3.4.RELEASE")
    id("io.spring.dependency-management") version ("1.0.7.RELEASE")
    kotlin("jvm") version("1.4.10")
    kotlin("plugin.spring") version("1.4.10")
}

tasks.bootJar {enabled = false}
tasks.jar {enabled = true}

group = "demo"
version="1.0"
allprojects {
    repositories {
        mavenCentral()
    }
}
subprojects {
    apply(plugin = "kotlin")
    apply(plugin = "org.springframework.boot")
    apply(plugin = "io.spring.dependency-management")

    dependencies {
        "implementation"("mysql:mysql-connector-java:5.1.38")
    }
}

project(":sub"){
    tasks.bootJar{ enabled = true }
}

KTH-96 added a commit to KTH-96/message-agent that referenced this issue Jan 8, 2024
KTH-96 added a commit to f-lab-edu/message-agent that referenced this issue Jan 18, 2024
* fix: docker login cli 적용이 안되는 문제

- github action에서 제공해주는 메소드로 변경

* fix: 멀티모듈 프로젝트에 맞게 jar파일에 대한 경로 지정

* refactor: mainclass 지정

* refactor: 도커파일 COPY 경로 변경

* refactor: github-cd파일 도커 빌드부분 수정

* refactor: 모듈마다 bootJar파일 및 Plain jar 파일 제거 구문 추가

* refactor: github action gradle build해서 파일 저장하는 위치 경로 지정

* refactor: Jar파일 생성 안되는 문제 해결

- spring-projects/spring-boot#10238

* refactor: 하위 모듈에서 dockerfile의 context범위 문제로 도커파일 위치 변경

* refactor: Jar 파일 위치 지정 형식 변경

* refactor: github action Dockerfile 경로 변경

* refactor: docker build context를 root로 변경

* refactor: 실제 repository에 파일이 있는지 확인하는 코드 추가

* refactor: github upload artifact부분 수정

* refactor: main클래스가 있어야 jar파일이 생성된다

* refactor: docker hub 이미지 이름 변경

* refactor: 사용하지 않는 명령어 제거

* refactor: 구문 오류를 해결하기 위해 따음표 추가

* refactor: db 연결을 위한 network설정 변경

* refactor: DB실행 후 애플리케이션 실행

* refactor: db설정 정보 확인용 스크립트 추가

* refactor: profile local, dev설정 변경

* refactor: cl log 확인

* refactor: LocalDateTime 인스턴스 시간 변경 및 docker 컨테이너 종료시 자동삭제

- LocalDateTime 인스턴스를 ZonedDateTime으로 변경
- docker -d --rm 명령어 형식으로 변경

* feat: 도커 컴포즈 적용

* refactor: docker-compose.yml파일 위치 찾을 수 있도록 변경

* refactor: docker-compose.yml파일 위치를 api모듈 아래로 변경

* refactor: docker-compose.yml파일이 실행되지않아 파일 위치를 클라우드 서버와 동일하게 변경

* refactor: err발생한 이유를 도커 컴포즈를 다운받은 파일에 접근하여 up을 해줘야 한다고 판단

* refactor: 서버 docker-compose다운 파일 위치로 가는 부분 삭제

* refactor: 깃헙 리포지토리를 사용할 수 있도록 체크아웃

* refactor: 깃헙 리포지토리 api폴더 아래 docker-compose.yml파일 찾기

* refactor: docker-compose최상위 폴더로 위치 변경

* refactor: 변수 설정 부분 수정

* refactor: gradle 캐시 추가

* refactor: docker-compose파일 복사 및 파일 분리

- docker-compose파일 root에 복사
- 기존 github-cd파일이 ci와 cd를 다같이하는 구조여서 파일 분리

* refactor: github cd파일 ci파일 진행 후 실행시키기

* refactor: github action 이름 중복 변경

* refactor: github ci실행이 성공이면 단계 실행

* defalut 브랜치가 아니면 workflow-run은 작동하지 않는다.

* deploy가 스킵되는 코드 부분 삭제

* secrets 변수 이름 수정

* 도커 컴포즈 파일 위치 변경

* 환경변수를 with보다 먼저 호출하기

* 환경변수를 스크립트 안에서 호출하도록 변경

* 환경변수 지정 형식 변경

* 환경변수 명령어로 넣기

* appleboy/ssh-action 버전 명시

* refactor: 버전 오타 수정

* refactor: github action 브랜치 별로 파일 나누기

* refactor: github action cicd 한 파일에 넣는게 자연스럽다고 판단

* refactor: docker-compose 환경변수 .env파일 만들어서 사용하기
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

5 participants