목차

Gradle Maven Deployment

기본 설정

apply plugin: 'maven'
 
// ....
 
project.version = '1.0' : version
project.group = 'kr.pe.kwonnam.blah' // groupId
// project.name이 artifactId 가 되어줌.
 
uploadArchives {
    repositories {
        mavenDeployer {
            repository(url: 'http://your.maven.repository.com/nexus/content/repositories/releases/') {
                authentication(userName: '계정명', password: '비밀번호')
            }
            snapshotRepository(url: 'http://your.maven.repository.com/nexus/content/repositories/snapshot/') {
                authentication(userName: '계정명', password: '비밀번호')
            }
        }
    }
}
 
// 소스와 JavaDoc 배포를 위한 작업
task sourcesJar(type: Jar, dependsOn: classes) {
    classifier = 'sources'
    from sourceSets.main.allSource
}
 
task javadocJar(type: Jar, dependsOn: javadoc) {
    classifier = 'javadoc'
    from javadoc.destinationDir
}
 
artifacts {
    archives sourcesJar
    archives javadocJar
}

배포

# 로컬 저장소(~/.m2/repository)로 설치
gradle install
 
# 원격 저장소에 업로드
gradle uploadArchives