프라이빗 Amazon S3 Maven 리포지토리에 Android 라이브러리 아티팩트 게시
개요
이 게시물에서는 라이브러리 아티팩트를 amazon s3 버킷에 게시하는 데 중점을 둘 것이므로 전제 조건으로 이미 Android 라이브러리가 준비되어 있다고 가정합니다.
프라이빗 Amazon S3 Maven 리포지토리 설정
프라이빗 Amazon s3 버킷 설정부터 시작하겠습니다. amazon s3 console으로 이동하여 서비스 탭에서 s3를 선택합니다.

그런 다음 버킷 만들기를 선택하고 지침을 따릅니다. 버킷 이름은 고유해야 com.organization.library와 같은 라이브러리 패키지 이름과 같은 것을 사용할 수 있습니다.
이제 버킷이 준비되었으며 이를 사용하여 종속 항목을 제공할 수 있습니다.
아티팩트를 업로드하는 Gradle 스크립트
gradle/gradle-library-push.gradle
명령을 사용할 때 gradle-maven 플러그인을 사용하여 아티팩트를 s3 버킷에 푸시하는 데 사용할 ./gradlew publish
라는 파일을 만듭니다.apply plugin: 'com.android.library'
apply plugin: 'maven-publish'
// update these next lines to fit your specification
group = 'com.android.library'
version = '1.0'
// Add sources as an artifact
task sourceJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier "source"
}
// Loop over all variants
android.libraryVariants.all { variant ->
variant.outputs.all { output ->
// This creates a publication for each variant
publishing.publications.create(variant.name, MavenPublication) {
// The sources artifact from earlier
artifact sourceJar
// Variant dependent artifact, e.g. release, debug
artifact source: output.outputFile, classifier: output.name
// Go through all the dependencies for each variant and add them to the POM
// file as dependencies
pom.withXml {
def dependencies = asNode().appendNode('dependencies')
// Filter out anything that's not an external dependency. You shouldn't
// be publishing artifacts that depend on local (e.g. project) dependencies,
// but who knows...
configurations.getByName(variant.name + "CompileClasspath").allDependencies
.findAll { it instanceof ExternalDependency }
.each {
def dependency = dependencies.appendNode('dependency')
dependency.appendNode('groupId', it.group)
dependency.appendNode('artifactId', it.name)
dependency.appendNode('version', it.version)
}
}
}
}
}
// Ensure that the publish task depends on assembly
tasks.all { task ->
if (task instanceof AbstractPublishToMaven) {
task.dependsOn assemble
}
}
// Configure the destination repository with
// S3 URL and access credentials
publishing {
repositories {
maven {
//aws bucket link
url "YOUR_S3_BUCKET_URL"
//aws credentials
credentials(AwsCredentials) {
accessKey "YOUR_ACCESS_KEY"
secretKey "YOUR_SECRET_KEY"
}
}
}
}
// Top-level build file where you can add configuration
options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.4.10'
repositories {
google()
jcenter()
maven {
url = uri("https://plugins.gradle.org/m2/")
}
}
}
그런 다음 라이브러리의 build.gradle 파일에 포함합니다.
apply from: rootProject.file('gradle/gradle-library-push.gradle')
이제 Gradle 스크립트와 Amazon 버킷이 준비되었으므로 작업을 준비하겠습니다. 터미널에서 다음 명령을 실행합니다./gradlew library:publish
.프로젝트에서 새로운 종속성을 사용합니다.
루트 build.gradle 파일에 다음을 포함합니다.
allprojects {
repositories {
google()
jcenter()
maven {
url "YOUR_S3_BUCKET_URL"
credentials(AwsCredentials) {
accessKey "YOUR-ACCESS-KEY"
secretKey "YOUR-SECRET-KEY"
}
}
}
}
참조
Reference
이 문제에 관하여(프라이빗 Amazon S3 Maven 리포지토리에 Android 라이브러리 아티팩트 게시), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/narayanansampath/publish-android-library-artifacts-to-private-amazon-s3-maven-repository-546f텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)