Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Configure patches project on extensions projects absence #5

Merged
merged 2 commits into from
Mar 22, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 20 additions & 16 deletions src/main/kotlin/app/revanced/patches/gradle/SettingsPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,14 @@ abstract class SettingsPlugin @Inject constructor(
private fun Settings.configureProjects(extension: SettingsExtension) {
// region Include the projects

val extensionsProjectPath = extension.extensions.projectsPath ?: return
val extensionsProjectPath = extension.extensions.projectsPath

objectFactory.fileTree().from(rootDir.resolve(extensionsProjectPath)).matching {
it.include("**/build.gradle.kts")
}.forEach {
include(it.relativeTo(rootDir).toPath().joinToString(":"))
if (extensionsProjectPath != null) {
objectFactory.fileTree().from(rootDir.resolve(extensionsProjectPath)).matching {
it.include("**/build.gradle.kts")
}.forEach {
include(it.relativeTo(rootDir).toPath().joinToString(":"))
}
}

include(extension.patchesProjectPath)
Expand All @@ -70,18 +72,20 @@ abstract class SettingsPlugin @Inject constructor(
// region Apply the plugins

gradle.rootProject { rootProject ->
val extensionsProject = try {
rootProject.project(extensionsProjectPath)
} catch (e: UnknownProjectException) {
return@rootProject
}
if (extensionsProjectPath != null) {
val extensionsProject = try {
rootProject.project(extensionsProjectPath)
} catch (e: UnknownProjectException) {
null
}

extensionsProject.subprojects { extensionProject ->
if (
extensionProject.buildFile.exists() &&
!extensionProject.parent!!.plugins.hasPlugin(ExtensionPlugin::class.java)
) {
extensionProject.pluginManager.apply(ExtensionPlugin::class.java)
extensionsProject?.subprojects { extensionProject ->
if (
extensionProject.buildFile.exists() &&
!extensionProject.parent!!.plugins.hasPlugin(ExtensionPlugin::class.java)
) {
extensionProject.pluginManager.apply(ExtensionPlugin::class.java)
}
}
}

Expand Down