Skip to content

Commit

Permalink
Bump version and add exported = true to fix one more test
Browse files Browse the repository at this point in the history
  • Loading branch information
runningcode committed Jun 13, 2024
1 parent 7075c45 commit 4fca564
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,60 +16,64 @@ import com.gradle.enterprise.gradleplugin.test.JUnitXmlDialect as GEJUnitXmlDial
fun canImportReport(): Boolean = JUnitXmlHandler.canImport()

fun importReport(
project: Project, flankTaskProvider: TaskProvider<FlankExecutionTask>,
project: Project,
flankTaskProvider: TaskProvider<FlankExecutionTask>,
) {
val enableTestUploads =
project.providers
.gradleProperty("com.osacky.fladle.enableTestUploads")
.getOrElse("true")
.toBoolean()
if (enableTestUploads) {
val resultsProvider: Provider<RegularFile> = project.layout.buildDirectory
.dir("fladle")
.flatMap { fladleDir ->
val localResultsDirProvider: Provider<Directory> = fladleDir
.dir(flankTaskProvider.flatMap { task -> task.config.localResultsDir })
val resultsProvider: Provider<RegularFile> =
project.layout.buildDirectory
.dir("fladle")
.flatMap { fladleDir ->
val localResultsDirProvider: Provider<Directory> =
fladleDir
.dir(flankTaskProvider.flatMap { task -> task.config.localResultsDir })

localResultsDirProvider.map { localResultsDir -> localResultsDir.file("JUnitReport.xml") }
}
localResultsDirProvider.map { localResultsDir -> localResultsDir.file("JUnitReport.xml") }
}
JUnitXmlHandler.get()?.register(
project.tasks,
flankTaskProvider,
resultsProvider
resultsProvider,
)
}
}

/** Abstraction over Develocity and GE impls of JUnitXml reporting. */
sealed class JUnitXmlHandler {

abstract fun register(
tasks: TaskContainer,
flankTask: TaskProvider<FlankExecutionTask>,
reportsFile: Provider<RegularFile>,
)

companion object {
private fun canImport(name: String) = try {
Class.forName(name)
true
} catch (e: ClassNotFoundException) {
false
}
private fun canImport(name: String) =
try {
Class.forName(name)
true
} catch (e: ClassNotFoundException) {
false
}

private val canImportDevelocity get() = canImport("com.gradle.develocity.agent.gradle.test.ImportJUnitXmlReports")

private val canImportGE get() = canImport("com.gradle.enterprise.gradleplugin.test.ImportJUnitXmlReports")

fun canImport() = canImportDevelocity || canImportGE

fun get() = if (canImportDevelocity) {
DevelocityJunitXmlHandler
} else if (canImportGE) {
GEJunitXmlHandler
} else {
null
}
fun get() =
if (canImportDevelocity) {
DevelocityJunitXmlHandler
} else if (canImportGE) {
GEJunitXmlHandler
} else {
null
}
}

object DevelocityJunitXmlHandler : JUnitXmlHandler() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ android {
}

dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation("androidx.navigation:navigation-fragment-ktx:2.3.0")
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test:rules:1.3.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test:rules:1.5.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
<application
android:label="@string/app_name"
>
<activity android:name=".MainActivity">
<activity android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ android {
}

dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation("androidx.navigation:navigation-fragment-ktx:2.3.0")
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test:rules:1.3.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test:rules:1.5.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
<application
android:label="@string/app_name"
>
<activity android:name=".MainActivity">
<activity android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ android {
}

dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation("androidx.navigation:navigation-fragment-ktx:2.3.0")
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test:rules:1.3.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test:rules:1.5.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}

10 changes: 5 additions & 5 deletions fladle-plugin/src/test/resources/android-project/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ fladle {
}

dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation("androidx.navigation:navigation-fragment-ktx:2.3.0")
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test:rules:1.3.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test:rules:1.5.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}

10 changes: 5 additions & 5 deletions fladle-plugin/src/test/resources/android-project2/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ fulladleModuleConfig {
environmentVariables = ["clearPackageData": "false"]
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation("androidx.navigation:navigation-fragment-ktx:2.3.0")
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test:rules:1.3.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test:rules:1.5.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}

0 comments on commit 4fca564

Please sign in to comment.