Skip to content

Commit 7c17bb1

Browse files
committed
Add githubPackages function to setup maven repository for GPR
1 parent 9391c7e commit 7c17bb1

File tree

4 files changed

+34
-32
lines changed

4 files changed

+34
-32
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import org.gradle.api.Project
2+
import org.gradle.api.artifacts.dsl.RepositoryHandler
3+
import org.gradle.api.artifacts.repositories.MavenArtifactRepository
4+
5+
/**
6+
* Set up GitHub Packages Registry for a specific repository.
7+
*
8+
* To use this GPR locally, you need to set the `gpr.user` and `gpr.key` properties
9+
* in your `~/.gradle/gradle.properties` file, for example:
10+
* ```
11+
* gpr.user=your-github-username
12+
* gpr.key=your-github-token
13+
* ```
14+
* Note: token must have "packages: read" permissions.
15+
*
16+
* On CI, provide `GITHUB_ACTOR` and `GITHUB_TOKEN` environment variables.
17+
*/
18+
fun RepositoryHandler.githubPackages(
19+
project: Project,
20+
repo: String,
21+
setup: MavenArtifactRepository.() -> Unit = {},
22+
) = with(project) {
23+
maven {
24+
name = "GitHubPackages"
25+
url = uri("https://maven.pkg.github.com/$repo")
26+
credentials {
27+
username = findProperty("gpr.user") as String? ?: System.getenv("USERNAME")
28+
password = findProperty("gpr.key") as String? ?: System.getenv("TOKEN")
29+
}
30+
setup()
31+
}
32+
}

buildSrc/src/main/kotlin/JacodbRepository.kt

Lines changed: 0 additions & 28 deletions
This file was deleted.

buildSrc/src/main/kotlin/usvm.kotlin-conventions.gradle.kts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@ group = "org.usvm"
1111

1212
repositories {
1313
mavenCentral()
14+
githubPackages(project, "UnitTestBot/jacodb")
1415
maven("https://jitpack.io")
1516
}
1617

17-
setupJacodbGitHubPackagesRepository()
18-
1918
dependencies {
2019
// Align versions of all Kotlin components
2120
implementation(platform(kotlin("bom", Versions.kotlin)))

usvm-jvm/usvm-jvm-api/build.gradle.kts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,10 @@ tasks {
2828

2929
repositories {
3030
mavenCentral()
31+
githubPackages(project, "UnitTestBot/jacodb")
3132
maven("https://jitpack.io")
3233
}
3334

34-
setupJacodbGitHubPackagesRepository()
35-
3635
dependencies {
3736
compileOnly(Libs.jacodb_api_jvm)
3837
}

0 commit comments

Comments
 (0)