사용자 도구

사이트 도구


springframework:springboot:jar_publish

문서의 이전 판입니다!


Spring Boot Jar Publish

maven plugin 사용

uploadBootArchives {
    repositories {
        mavenDeployer {
            repository url: 'https://repo.example.com'
        }
    }
}

maven-publish plugin 사용

apply plugin: 'maven'
apply plugin: "maven-publish"
 
bootJar.enabled = true
jar.enabled = true
 
bootJar {
    mainClassName = "yourMainClass"
}
 
publishing {
    publications {
        bootJava(MavenPublication) {
            groupId 'your group id' // 생략하면 프로젝트 기본값
            artifactId 'artifact id' // 생략하면 프로젝트 기본값
            artifact bootJar
        }
    }
    repositories {
        maven {
            credentials {
                username '리포지토리 접속 username'
                password '리포지토리 접속 password'
            }
            url 'http://nexus.host.name/content/repositories/releases/'
        }
    }
}
 
// 불필요하게 publsh.dependsOn bootJar 를 붙일 경우 생성된 jar 에 의존성 *.jar 파일들이 추가가 안되는 형상이 있었음.

maven-publish plugin 사용 prod/dev 구분해서 release/snapshot 올리기

  • publishing.gradle
    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
    }
    
  • build.gradle에서
    apply from: 'publishing.gradle'
    
    initializePublishing('groupId', 'artifactId')
springframework/springboot/jar_publish.1560317014.txt.gz · 마지막으로 수정됨: 2019/06/12 14:23 저자 kwon37xi