Skip to content

Commit

Permalink
Merge pull request #501 from takahirom/takahirom/remove-verify-maven-…
Browse files Browse the repository at this point in the history
…repository/2024-10-06

Remove verifyMavenRepository because ComposablePreviewScanner is now on Maven Central
  • Loading branch information
takahirom authored Oct 6, 2024
2 parents 067f663 + a6490d6 commit f2f8269
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 38 deletions.
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ webjar-material-design-icons = "4.0.0"
webjar-materialize = "1.0.0"
webjars-locator-lite = "0.0.4"

composable-preview-scanner = "0.1.3"
composable-preview-scanner = "0.3.2"

[libraries]
roborazzi = { module = "io.github.takahirom.roborazzi:roborazzi", version.ref = "roborazzi-for-replacing-by-include-build" }
Expand All @@ -56,7 +56,7 @@ kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test" }
kotlin-test-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit" }

# for sample
composable-preview-scanner = { module = "com.github.sergio-sastre.ComposablePreviewScanner:android", version.ref = "composable-preview-scanner" }
composable-preview-scanner = { module = "io.github.sergio-sastre.ComposablePreviewScanner:android", version.ref = "composable-preview-scanner" }

androidx-activity = { module = "androidx.activity:activity", version.ref = "androidx-activity" }
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activity" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ class PreviewModule(
repositories {
mavenCentral()
google()
maven { url = uri("https://jitpack.io") }
}
""".trimIndent()
} else {
Expand All @@ -220,7 +219,6 @@ class PreviewModule(
repositories {
mavenCentral()
google()
maven { url = uri("https://jitpack.io") }
}
$androidBlock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ roborazzi {
repositories {
mavenCentral()
google()
maven { url = uri("https://jitpack.io") }
}

android {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import com.android.build.api.variant.Variant
import com.android.build.gradle.TestedExtension
import org.gradle.api.DefaultTask
import org.gradle.api.Project
import org.gradle.api.artifacts.repositories.MavenArtifactRepository
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.logging.Logger
import org.gradle.api.model.ObjectFactory
Expand All @@ -16,7 +15,6 @@ import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.TaskAction
import org.gradle.api.tasks.TaskCollection
import org.gradle.api.tasks.testing.Test
import org.gradle.invocation.DefaultGradle
import java.io.File
import java.net.URLEncoder
import java.util.Locale
Expand Down Expand Up @@ -235,39 +233,11 @@ fun verifyGenerateComposePreviewRobolectricTests(
if ((extension.enable.orNull) != true) {
return@afterEvaluate
}
verifyMavenRepository(project)
verifyLibraryDependencies(project)
verifyAndroidConfig(androidExtension, logger)
}
}

private fun verifyMavenRepository(project: Project) {
// Check if the jitpack repository is added.
val hasJitpackRepo = project.repositories.any {
it is MavenArtifactRepository &&
it.url.toString().contains("https://jitpack.io")
}
// settingsEvaluated{} is not called
// when it is already evaluated so we need to call `settingsEvaluated`
// before the project is evaluated.
// So we need to use the following workaround.
// https://github.com/gradle/gradle/issues/27741
val setting = (project.gradle as? DefaultGradle)?.getSettings() ?: return
val hasJitpackRepoInSettings = setting.pluginManagement.repositories.any {
it is MavenArtifactRepository && it.url.toString().contains("https://jitpack.io")
} || setting.dependencyResolutionManagement.repositories.any {
it is MavenArtifactRepository && it.url.toString().contains("https://jitpack.io")
}
if (!hasJitpackRepo && !hasJitpackRepoInSettings) {
error(
"Roborazzi: Please add the following 'maven' repository to the 'repositories' block in the 'build.gradle' file.\n" +
"build.gradle: \nrepositories {\nmaven { url 'https://jitpack.io' } \n}\n" +
"build.gradle.kts: \nrepositories {\nmaven { url = uri(\"https://jitpack.io\") } \n}\n" +
"This is necessary to download the ComposablePreviewScanner."
)
}
}

private fun verifyTestConfig(
testTaskProvider: TaskCollection<Test>,
logger: Logger
Expand Down Expand Up @@ -345,7 +315,7 @@ private fun verifyLibraryDependencies(
"io.github.takahirom.roborazzi:roborazzi-compose-preview-scanner-support",
"junit:junit",
"org.robolectric:robolectric",
"com.github.sergio-sastre.ComposablePreviewScanner:android",
"io.github.sergio-sastre.ComposablePreviewScanner:android",
)
requiredLibraries.forEach { allDependencies.checkExists(it) }
}
1 change: 0 additions & 1 deletion roborazzi-compose-preview-scanner-support/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ if (System.getenv("INTEGRATION_TEST") != "true") {
repositories {
google()
mavenCentral()
maven { url = uri("https://jitpack.io") }
}

android.buildFeatures.compose = true
Expand Down
1 change: 0 additions & 1 deletion sample-generate-preview-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ roborazzi {
repositories {
mavenCentral()
google()
maven { url = uri("https://jitpack.io") }
}

android {
Expand Down

0 comments on commit f2f8269

Please sign in to comment.