Skip to content

Commit

Permalink
build: Setup publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
warnyul committed Mar 18, 2024
1 parent 3b0bf64 commit 3b045a5
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Setup Gradle
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0
- name: Build with Gradle Wrapper
run: ./gradlew build koverXmlReport
run: ./gradlew build koverXmlReport publishToMavenLocal
- name: Upload coverage report
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
if: ${{ hashFiles('build/reports/kover/report.xml') != '' }}
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {

allprojects {
group = 'tech.apter.junit5.jupiter'
version = '1.0-SNAPSHOT'
version = property('apter.junit5.robolectric.extension.version')
}

dependencies {
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
android.useAndroidX=true
kotlin.code.style=official
apter.junit5.robolectric.extension.version=0.1.0-SNAPSHOT
64 changes: 64 additions & 0 deletions gradle/publishing.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
apply plugin: 'maven-publish'
apply plugin: 'signing'

publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact(kotlinSourcesJar)
artifact(dokkaJavadocJar)

pom {
name = 'JUnit5 Robolectric Extension'
description = """This repository aims to bridge the gap between JUnit 5 and Robolectric,
|enabling developers to leverage the benefits of both frameworks
|for unit testing Android applications. While Robolectric currently lacks
|a dedicated JUnit 5 extension, this project proposes a community-driven solution to
|achieve seamless integration.""".stripMargin()
url = 'https://github.com/apter-tech/junit5-robolectric-extension'
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'https://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
organization {
name = 'Apter Technologies Ltd.'
url = 'https://apter.tech'
}
developers {
developer {
id = 'warnyul'
name = 'Balázs Varga'
email = '[email protected]'
}
}
scm {
connection = 'scm:git:git://github.com:apter-tech/junit5-robolectric-extension.git'
developerConnection = 'scm:git:ssh://github.com:apter-tech/junit5-robolectric-extension.git'
url = 'https://github.com/apter-tech/junit5-robolectric-extension'
}
}
}
}
repositories {
maven {
name = 'MavenCentral'
final releasesRepoUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2'
final snapshotsRepoUrl = 'https://oss.sonatype.org/content/repositories/snapshots'
url = version.toString().endsWith("SNAPSHOT") ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username = System.getenv('JUNIT5_ROBOLECTRIC_EXTENSION_MAVEN_USERNAME')
password = System.getenv('JUNIT5_ROBOLECTRIC_EXTENSION_MAVEN_PASSWORD')
}
}
}
}

//signing {
// useInMemoryPgpKeys(
// System.getenv('JUNIT5_ROBOLECTRIC_EXTENSION_PGP_SIGNING_KEY'),
// System.getenv('JUNIT5_ROBOLECTRIC_EXTENSION_PGP_SIGNING_PASSWORD'),
// )
// sign(publishing.publications["mavenJava"])
//}
3 changes: 1 addition & 2 deletions integration-tests/agp-groovy-dsl/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ android {
}

detekt {
version = libs.versions.detekt.get()
toolVersion = libs.versions.detekt.get()
autoCorrect = true
config.setFrom(rootProject.layout.projectDirectory.file('config/detekt/detekt.yml').asFile)
}

kotlin {
Expand Down
3 changes: 1 addition & 2 deletions integration-tests/agp-kotlin-dsl/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ android {
}

detekt {
version = libs.versions.detekt.get()
toolVersion = libs.versions.detekt.get()
autoCorrect = true
config.setFrom(rootProject.layout.projectDirectory.file("config/detekt/detekt.yml").asFile)
}

kotlin {
Expand Down
10 changes: 9 additions & 1 deletion robolectric-extension/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ test {
}

detekt {
version libs.versions.detekt.get()
toolVersion = libs.versions.detekt.get()
autoCorrect true
}

Expand All @@ -48,6 +48,12 @@ dependencies {
testRuntimeOnly(libs.junit5JupiterEngine)
}

tasks.register('dokkaJavadocJar', Jar) {
dependsOn dokkaJavadoc
archiveClassifier.set 'javadoc'
from javadoc.destinationDir
}

private void bashExecute(String command) {
final process = command.execute()
final error = process.errorReader().readLines().join("\n")
Expand Down Expand Up @@ -85,3 +91,5 @@ tasks.register('generateAndroidR') {
bashExecute(aaptCommand)
}
}

apply from: "${rootProject.layout.projectDirectory.file('gradle/publishing.gradle')}"
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ class RobolectricExtension :
private val beforeAllFired = AtomicBoolean(false)
private val robolectricTestRunnerHelper by lazy { JUnit5RobolectricTestRunnerHelper() }

init {
logger.trace { "init" }
}

override fun beforeAll(context: ExtensionContext) {
logger.trace { "beforeAll ${context.requiredTestClass.name}" }
robolectricTestRunnerHelper.createTestEnvironmentForClass(context.requiredTestClass)
Expand Down

0 comments on commit 3b045a5

Please sign in to comment.