https://github.com/kmong/gradle-plugin-codeartifact
gradle dependency management, simple aws codeartifact config plugin
https://github.com/kmong/gradle-plugin-codeartifact
aws aws-authentication codeartifact gradle-plugin
Last synced: about 2 months ago
JSON representation
gradle dependency management, simple aws codeartifact config plugin
- Host: GitHub
- URL: https://github.com/kmong/gradle-plugin-codeartifact
- Owner: Kmong
- Created: 2025-03-10T05:29:20.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2025-03-19T06:42:49.000Z (2 months ago)
- Last Synced: 2025-03-19T07:24:12.904Z (2 months ago)
- Topics: aws, aws-authentication, codeartifact, gradle-plugin
- Language: Kotlin
- Homepage:
- Size: 80.1 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Why codeartifact plugin?
gradle dependency management, simple aws codeartifact config plugin
aws codeartifact private repository setting, very tired and complex.
## Requirements
| plugin Version | Requirement | Version |
|----------------|-------------|---------|
| 0.0.4 | kotlin | 1.9.24 |
| | gradle | 8.10 |
| | awssdk | 2.30.33 |
| | jdk | 17 |## Process Change, Before and After
### get private repository:before`build.gradle:`
```groovy
repositories {
maven {
url "https://my-domain-123456789012.d.codeartifact.ap-northeast-2.amazonaws.com/maven/my-repo"
credentials {
username = "aws"
password = getAwsCodeArtifactToken(... parameters)
// <- aws codeartifact token, token generate process required
}
}
}fun getAwsCodeArtifactToken(profileName: String, region: String, domain: String, repositoryName: String): String {
val process = ProcessBuilder("aws", "codeartifact", "get-authorization-token", "--profile", profileName, "--region", region, "--domain", domain, "--domain-owner", "123456789012", "--repository", repositoryName).start()
val reader = BufferedReader(InputStreamReader(process.inputStream))
val token = reader.readLine()
process.waitFor()
return token
}
```### get private repository:after
`build.gradle:`
```groovy
import com.kmong.codeartifact.codeartifactplugins {
id 'com.kmong.codeartifact' version
}repositories {
codeartifact(url = "https://-.d.codeartifact..amazonaws.com//?profile=")
}
```### publish private repository:before
`build.gradle.kts:`
```groovy
publishing {
publications {
create("mavenJava", MavenPublication::class) {
artifactId = codeArtifactId
version = moduleVersion.toString()
groupId = group.toString()
from(components["java"])
}
}
repositories {
maven {
url "https://my-domain-123456789012.d.codeartifact.ap-northeast-2.amazonaws.com/maven/my-repo"
credentials {
username = "aws"
password = getAwsCodeArtifactToken(... parameters)
// <- aws codeartifact token, token generate process required
}
}
}
}fun getAwsCodeArtifactToken(profileName: String, region: String, domain: String, repositoryName: String): String {
val process = ProcessBuilder("aws", "codeartifact", "get-authorization-token", "--profile", profileName, "--region", region, "--domain", domain, "--domain-owner", "123456789012", "--repository", repositoryName).start()
val reader = BufferedReader(InputStreamReader(process.inputStream))
val token = reader.readLine()
process.waitFor()
return token
}
```### publish private repository:after
`build.gradle.kts:`
```kotlin
publishing {
publications {
create("mavenJava") {
artifactId = codeArtifactId
version = moduleVersion.toString()
groupId = group.toString()
from(components["java"])
}
}
repositories {
codeartifact(url = "https://-.d.codeartifact..amazonaws.com//?profile=")
}
}
```## How to use
| Property | Description | Default |
|--------------|------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| profile name | aws profile name | aws profile name |
| region | aws region | repository region |
| domain | domain name | Domain |
| domainOwner | account id | AccountId |
| repository | repository name | repository name, If a repository url is present, this value is ignored. If you don't have a repository url and you have a repository name, assemble it as `https://${domain}-${accountId}.d.codeartifact.${region}.amazonaws.com/maven/${repositoryName}/.` |
| type | repository type | maven |### build.gradle.kts
`build.gradle.kts:`
```kotlin
import com.kmong.codeartifact.codeartifactplugins {
id("com.kmong.aws:codeartifact") version
}repositories {
codeartifact(url = "https://-.d.codeartifact..amazonaws.com//?profile=")
}
```### Multiple repositories
`build.gradle.kts:`
```kotlin
import com.kmong.codeartifact.codeartifactrepositories {
codeartifact(url = "https://-.d.codeartifact..amazonaws.com//?profile=")
codeartifact(url = "https://-.d.codeartifact..amazonaws.com//?profile=")
}
```