-
-
Notifications
You must be signed in to change notification settings - Fork 35
feat(multi-module): Introduce SentryRootPlugin with App and Lib subplugins #858
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
Open
romtsn
wants to merge
3
commits into
main
Choose a base branch
from
rz/feat/multi-module-root-plugin
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
plugin-build/src/main/kotlin/io/sentry/android/gradle/autoinstall/AutoInstallState.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
plugin-build/src/main/kotlin/io/sentry/android/gradle/extensions/AutoInstallExtension.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
plugin-build/src/main/kotlin/io/sentry/gradle/SentryRootPlugin.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package io.sentry.gradle | ||
|
||
import io.sentry.gradle.subplugin.RootPlugin | ||
import javax.inject.Inject | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.api.tasks.StopExecutionException | ||
import org.gradle.internal.build.event.BuildEventListenerRegistryInternal | ||
import org.slf4j.LoggerFactory | ||
|
||
internal abstract class SentryRootPlugin | ||
@Inject | ||
constructor(private val buildEvents: BuildEventListenerRegistryInternal) : Plugin<Project> { | ||
|
||
override fun apply(project: Project) { | ||
if (project == project.rootProject) { | ||
RootPlugin(project).apply(buildEvents) | ||
} else { | ||
throw StopExecutionException("io.sentry.gradle must be applied only to the root project.") | ||
} | ||
} | ||
|
||
companion object { | ||
// a single unified logger used by instrumentation | ||
internal val logger by lazy { LoggerFactory.getLogger(SentryRootPlugin::class.java) } | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package io.sentry.gradle | ||
|
||
import io.sentry.BuildConfig | ||
import java.io.File | ||
|
||
internal const val SENTRY_ORG_PARAMETER = "sentryOrg" | ||
internal const val SENTRY_PROJECT_PARAMETER = "sentryProject" | ||
|
||
internal const val SENTRY_SDK_VERSION = BuildConfig.SdkVersion | ||
|
||
internal val sep = File.separator |
66 changes: 66 additions & 0 deletions
66
plugin-build/src/main/kotlin/io/sentry/gradle/subplugin/AndroidAppSubplugin.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package io.sentry.gradle.subplugin | ||
|
||
import com.android.build.api.variant.AndroidComponentsExtension | ||
import com.android.build.gradle.AppExtension | ||
import io.sentry.android.gradle.autoinstall.installDependencies | ||
import io.sentry.android.gradle.cliExecutableProvider | ||
import io.sentry.android.gradle.configure | ||
import io.sentry.android.gradle.extensions.SentryPluginExtension | ||
import io.sentry.android.gradle.util.AgpVersions | ||
import org.gradle.api.Project | ||
import org.gradle.api.tasks.StopExecutionException | ||
import org.gradle.internal.build.event.BuildEventListenerRegistryInternal | ||
|
||
class AndroidAppSubplugin( | ||
private val project: Project, | ||
private val extension: SentryPluginExtension, | ||
) { | ||
fun apply( | ||
buildEvents: BuildEventListenerRegistryInternal, | ||
sentryOrgParameter: String?, | ||
sentryProjectParameter: String?, | ||
) = | ||
project.run { | ||
checkAgpVersion() | ||
|
||
val oldAGPExtension = extensions.getByType(AppExtension::class.java) | ||
val androidComponentsExt = extensions.getByType(AndroidComponentsExtension::class.java) | ||
val cliExecutable = cliExecutableProvider() | ||
|
||
// new API configuration | ||
androidComponentsExt.configure( | ||
this, | ||
extension, | ||
buildEvents, | ||
cliExecutable, | ||
sentryOrgParameter, | ||
sentryProjectParameter, | ||
) | ||
|
||
// old API configuration | ||
oldAGPExtension.configure( | ||
this, | ||
extension, | ||
cliExecutable, | ||
sentryOrgParameter, | ||
sentryProjectParameter, | ||
buildEvents, | ||
) | ||
|
||
installDependencies(extension, true) | ||
} | ||
|
||
private fun Project.checkAgpVersion() { | ||
if (AgpVersions.CURRENT < AgpVersions.VERSION_7_0_0) { | ||
throw StopExecutionException( | ||
""" | ||
Using io.sentry.android.gradle:3+ with Android Gradle Plugin < 7 is not supported. | ||
Either upgrade the AGP version to 7+, or use an earlier version of the Sentry | ||
Android Gradle Plugin. For more information check our migration guide | ||
https://docs.sentry.io/platforms/android/migration/#migrating-from-iosentrysentry-android-gradle-plugin-2x-to-iosentrysentry-android-gradle-plugin-300 | ||
""" | ||
.trimIndent() | ||
) | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
plugin-build/src/main/kotlin/io/sentry/gradle/subplugin/AndroidLibSubplugin.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package io.sentry.gradle.subplugin | ||
|
||
import org.gradle.api.Project | ||
|
||
class AndroidLibSubplugin(private val project: Project) { | ||
fun apply() { | ||
// TODO: add logic to upload source contexts here | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a leftover from ktlint -> ktfmt migration