사용자 도구

사이트 도구


springframework:springboot:jar_publish

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

다음 판
이전 판
springframework:springboot:jar_publish [2018/07/24 18:16]
kwon37xi 만듦
springframework:springboot:jar_publish [2019/06/12 14:24] (현재)
kwon37xi [maven-publish plugin 사용 prod/dev 구분해서 release/snapshot 올리기]
줄 1: 줄 1:
 ====== Spring Boot Jar Publish ====== ====== Spring Boot Jar Publish ======
 +  * [[https://docs.spring.io/spring-boot/docs/2.0.4.RELEASE/gradle-plugin/reference/html/|Spring Boot Gradle Plugin Reference Guide]] 2.x 기준
 +
 +
   * [[springframework:springboot|SpringBoot]] jar 파일을 [[:nexus|SonaType Nexus]] 등 Maven Repository에 Publish 하기   * [[springframework:springboot|SpringBoot]] jar 파일을 [[:nexus|SonaType Nexus]] 등 Maven Repository에 Publish 하기
 +
 +===== maven plugin 사용 =====
 +  * [[gradle:maven|Gradle Maven Deployment]]이 적용되면 자동으로 **uploadBootArchives** 태스크 생성됨.
 +<code groovy>
 +uploadBootArchives {
 +    repositories {
 +        mavenDeployer {
 +            repository url: 'https://repo.example.com'
 +        }
 +    }
 +}
 +
 +</code>
 +
 +===== maven-publish plugin 사용 =====
 +  * [[gradle:maven_publishing|Gradle Maven Publish Plugin]]
  
 <code groovy> <code groovy>
줄 15: 줄 34:
 publishing { publishing {
     publications {     publications {
-        batchZipUpload(MavenPublication) {+        bootJava(MavenPublication) {
             groupId 'your group id' // 생략하면 프로젝트 기본값             groupId 'your group id' // 생략하면 프로젝트 기본값
             artifactId 'artifact id' // 생략하면 프로젝트 기본값             artifactId 'artifact id' // 생략하면 프로젝트 기본값
줄 33: 줄 52:
  
 // 불필요하게 publsh.dependsOn bootJar 를 붙일 경우 생성된 jar 에 의존성 *.jar 파일들이 추가가 안되는 형상이 있었음. // 불필요하게 publsh.dependsOn bootJar 를 붙일 경우 생성된 jar 에 의존성 *.jar 파일들이 추가가 안되는 형상이 있었음.
 +</code>
 +
 +===== maven-publish plugin 사용 prod/dev 구분해서 release/snapshot 올리기 =====
 +  * ''publishing.gradle''<code>
 +import java.time.LocalDateTime
 +import java.time.format.DateTimeFormatter
 +
 +apply plugin: 'maven'
 +apply plugin: "maven-publish"
 +
 +def isProduction = Boolean.getBoolean('production')
 +def buildDateTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy.MM.dd.HH.mm.ss"))
 +version = isProduction ? buildDateTime + "PROD" : buildDateTime + "DEV-SNAPSHOT"
 +
 +def initializePublishing(String targetGroupId, String targetArtifactId) {
 +    publishing {
 +        publications {
 +            zipUpload(MavenPublication) {
 +                groupId targetGroupId
 +                artifactId targetArtifactId
 +                artifact project.bootJar
 +            }
 +        }
 +        repositories {
 +            maven {
 +                credentials {
 +                    username 'username'
 +                    password 'passwd'
 +                }
 +
 +                def releaseRepoUrl = 'http://repositories/releases/'
 +                def snapshotRepoUrl = 'http://repositories/snapshots/'
 +                url version.endsWith('SNAPSHOT') ?  snapshotRepoUrl : releaseRepoUrl
 +            }
 +        }
 +    }
 +}
 +
 +ext {
 +    initializePublishing = this.&initializePublishing
 +}
 +
 +</code>
 +  * ''build.gradle''에서<code>
 +apply from: 'publishing.gradle'
 +
 +bootJar.enabled = true
 +jar.enabled = true
 + 
 +bootJar {
 +    mainClassName = "yourMainClass"
 +}
 + 
 +initializePublishing('groupId', 'artifactId')
 </code> </code>
springframework/springboot/jar_publish.1532423786.txt.gz · 마지막으로 수정됨: 2018/07/24 18:16 저자 kwon37xi