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

How to override the apiBuild task in Groovy #109

Closed
radixdev opened this issue Nov 10, 2022 · 6 comments
Closed

How to override the apiBuild task in Groovy #109

radixdev opened this issue Nov 10, 2022 · 6 comments
Labels
question Further information is requested

Comments

@radixdev
Copy link

image

title. I get the following error for:

apiBuild {
  // "jar" here is the name of the default Jar task producing the resulting jar file
  // in a multiplatform project it can be named "jvmJar"
  // if you applied the shadow plugin, it creates the "shadowJar" task that produces the transformed jar
  inputJar.value(new File("android-sdk-base/build/outputs/sources/android-sdk-base-sources.jar"))
}
Caused by: org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method apiBuild() for arguments [quality_3w8dpqhsp24rs3ntbbp280wfa$_run_closure5@7d0ce1f1] on project ':android-sdk-base' of type org.gradle.api.Project.

in 0.12.1 of the library

@ilya-g
Copy link
Member

ilya-g commented Nov 11, 2022

Yes, this is an example of configuration in a Kotlin build script.
In a Groovy build script, try using tasks.named('apiBuild') { ... } instead of tasks.apiBuild { ... }

@qwwdfsad qwwdfsad added the question Further information is requested label Nov 14, 2022
@radixdev
Copy link
Author

Hi @ilya-g ,

I think I see the root cause of the problem. Upon running ./gradlew tasks I see that apiBuild is not present. This is for 0.11.2 version of the library. Is this task not published or available to be overridden or is there some other way of following the documentation?

complete:13: command not found: compdef
complete:13: command not found: compdef
~ → cd code/android-sdk 
~/code/android-sdk git:(SDK-3166/api-check-mapping-file-checks) ▶▶▶ ./gradlew tasks
Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details
Configuration on demand is an incubating feature.

> Configure project :
Setting version to last recorded version in public/root-directory-files/CHANGELOG.md: 24.0.0

> Configure project :android-sdk-base
Applying project as LIBRARY
WARNING:We recommend using a newer Android Gradle plugin to use compileSdk = 33

This Android Gradle plugin (7.1.0) was tested up to compileSdk = 32

This warning can be suppressed by adding
    android.suppressUnsupportedCompileSdk=33
to this project's gradle.properties

The build will continue, but you are strongly encouraged to update your project to
use a newer Android Gradle Plugin that has been tested with compileSdk = 33

> Configure project :android-sdk-ui
Applying project as LIBRARY

> Task :tasks

------------------------------------------------------------
Tasks runnable from root project 'android-sdk'
------------------------------------------------------------

Android tasks
-------------
androidDependencies - Displays the Android dependencies of the project.
signingReport - Displays the signing info for the base and test modules
sourceSets - Prints out all the source sets defined in this project.

Build tasks
-----------
assemble - Assemble main outputs for all the variants.
assembleAndroidTest - Assembles all the Test applications.
build - Assembles and tests this project.
buildDependents - Assembles and tests this project and all projects that depend on it.
buildKotlinToolingMetadata - Build metadata json file containing information about the used Kotlin tooling
buildNeeded - Assembles and tests this project and all projects it depends on.
bundle - Assemble bundles for all the variants.
clean - Deletes the build directory.
compileDebugAndroidTestSources
compileDebugSources
compileDebugUnitTestSources
compileFireosSources
compileFireosUnitTestSources
compileReleaseSources
compileReleaseUnitTestSources
extractDebugAnnotations - Extracts Android annotations for the debug variant into the archive file
extractReleaseAnnotations - Extracts Android annotations for the release variant into the archive file

Build Setup tasks
-----------------
init - Initializes a new Gradle build.
wrapper - Generates Gradle wrapper files.

Documentation tasks
-------------------
dokkaGfm - Generates documentation in GitHub flavored markdown format
dokkaGfmPartial - Generates documentation in GitHub flavored markdown format
dokkaHtml - Generates documentation in 'html' format
dokkaHtmlPartial - Generates documentation in 'html' format
dokkaJavadoc - Generates documentation in 'javadoc' format
dokkaJavadocPartial - Generates documentation in 'javadoc' format
dokkaJekyll - Generates documentation in Jekyll flavored markdown format
dokkaJekyllPartial - Generates documentation in Jekyll flavored markdown format

Firebase Crashlytics tasks
--------------------------
injectCrashlyticsMappingFileIdDebug - Injects a mapping file id into the app, used by Crashlytics for deobfuscation.
injectCrashlyticsMappingFileIdFireos - Injects a mapping file id into the app, used by Crashlytics for deobfuscation.
injectCrashlyticsMappingFileIdRelease - Injects a mapping file id into the app, used by Crashlytics for deobfuscation.
uploadCrashlyticsMappingFileRelease - Uploads mapping files to Crashlytics for crash deobfuscation.

Help tasks
----------
buildEnvironment - Displays all buildscript dependencies declared in root project 'android-sdk'.
dependencies - Displays all dependencies declared in root project 'android-sdk'.
dependencyInsight - Displays the insight into a specific dependency in root project 'android-sdk'.
help - Displays a help message.
javaToolchains - Displays the detected java toolchains.
kotlinDslAccessorsReport - Prints the Kotlin code for accessing the currently available project extensions and conventions.
outgoingVariants - Displays the outgoing variants of root project 'android-sdk'.
projects - Displays the sub-projects of root project 'android-sdk'.
properties - Displays the properties of root project 'android-sdk'.
tasks - Displays the tasks runnable from root project 'android-sdk' (some of the displayed tasks may belong to subprojects).

Install tasks
-------------
installDebug - Installs the Debug build.
installDebugAndroidTest - Installs the android (on device) tests for the Debug build.
installFireos - Installs the Fireos build.
installRelease - Installs the Release build.
uninstallAll - Uninstall all applications.
uninstallDebug - Uninstalls the Debug build.
uninstallDebugAndroidTest - Uninstalls the android (on device) tests for the Debug build.
uninstallFireos - Uninstalls the Fireos build.
uninstallRelease - Uninstalls the Release build.

Publishing tasks
----------------
generateMetadataFileForAppboyLibraryPublication - Generates the Gradle metadata file for publication 'appboyLibrary'.
generateMetadataFileForBrazeLibraryPublication - Generates the Gradle metadata file for publication 'brazeLibrary'.
generatePomFileForAppboyLibraryPublication - Generates the Maven POM file for publication 'appboyLibrary'.
generatePomFileForBrazeLibraryPublication - Generates the Maven POM file for publication 'brazeLibrary'.
publish - Publishes all publications produced by this project.
publishAllPublicationsToMavenRepository - Publishes all Maven publications produced by this project to the maven repository.
publishAppboyLibraryPublicationToMavenLocal - Publishes Maven publication 'appboyLibrary' to the local Maven repository.
publishAppboyLibraryPublicationToMavenRepository - Publishes Maven publication 'appboyLibrary' to Maven repository 'maven'.
publishBrazeLibraryPublicationToMavenLocal - Publishes Maven publication 'brazeLibrary' to the local Maven repository.
publishBrazeLibraryPublicationToMavenRepository - Publishes Maven publication 'brazeLibrary' to Maven repository 'maven'.
publishToMavenLocal - Publishes all Maven publications produced by this project to the local Maven cache.

Verification tasks
------------------
apiCheck - Checks signatures of public API against the golden value in API folder for android-sdk-base
check - Runs all checks.
checkJetifier - Checks whether Jetifier is needed for the current project
connectedAndroidTest - Installs and runs instrumentation tests for all flavors on connected devices.
connectedCheck - Runs all device checks on currently connected devices.
connectedDebugAndroidTest - Installs and runs the tests for debug on connected devices.
detekt
detektBaseline - Creates a detekt baseline on the given --baseline path.
detektBaselineDebug - EXPERIMENTAL: Creates detekt baseline for debug classes with type resolution
detektBaselineDebugAndroidTest - EXPERIMENTAL: Creates detekt baseline for debugAndroidTest classes with type resolution
detektBaselineDebugUnitTest - EXPERIMENTAL: Creates detekt baseline for debugUnitTest classes with type resolution
detektBaselineFireos - EXPERIMENTAL: Creates detekt baseline for fireos classes with type resolution
detektBaselineFireosUnitTest - EXPERIMENTAL: Creates detekt baseline for fireosUnitTest classes with type resolution
detektBaselineMain - EXPERIMENTAL: Creates detekt baseline files for production classes across all variants with type resolution
detektBaselineRelease - EXPERIMENTAL: Creates detekt baseline for release classes with type resolution
detektBaselineReleaseUnitTest - EXPERIMENTAL: Creates detekt baseline for releaseUnitTest classes with type resolution
detektBaselineTest - EXPERIMENTAL: Creates detekt baseline files for test classes across all variants with type resolution
detektDebug - EXPERIMENTAL: Run detekt analysis for debug classes with type resolution
detektDebugAndroidTest - EXPERIMENTAL: Run detekt analysis for debugAndroidTest classes with type resolution
detektDebugUnitTest - EXPERIMENTAL: Run detekt analysis for debugUnitTest classes with type resolution
detektFireos - EXPERIMENTAL: Run detekt analysis for fireos classes with type resolution
detektFireosUnitTest - EXPERIMENTAL: Run detekt analysis for fireosUnitTest classes with type resolution
detektGenerateConfig - Generate a detekt configuration file inside your project.
detektMain - EXPERIMENTAL: Run detekt analysis for production classes across all variants with type resolution
detektRelease - EXPERIMENTAL: Run detekt analysis for release classes with type resolution
detektReleaseUnitTest - EXPERIMENTAL: Run detekt analysis for releaseUnitTest classes with type resolution
detektTest - EXPERIMENTAL: Run detekt analysis for test classes across all variants with type resolution
deviceAndroidTest - Installs and runs instrumentation tests using all Device Providers.
deviceCheck - Runs all device checks using Device Providers and Test Servers.
lint - Runs lint on the default variant.
lintAnalyzeDebug - Run lint analysis on the debug variant
lintAnalyzeFireos - Run lint analysis on the fireos variant
lintAnalyzeRelease - Run lint analysis on the release variant
lintDebug - Print text output from the corresponding lint report task
lintFireos - Print text output from the corresponding lint report task
lintFix - Runs lint on the default variant and applies any safe suggestions to the source code.
lintFixDebug - Fix lint on the debug variant
lintFixFireos - Fix lint on the fireos variant
lintFixRelease - Fix lint on the release variant
lintRelease - Print text output from the corresponding lint report task
lintReportDebug - Run lint on the debug variant
lintReportFireos - Run lint on the fireos variant
lintReportRelease - Run lint on the release variant
test - Run unit tests for all variants.
testDebugUnitTest - Run unit tests for the debug build.
testFireosUnitTest - Run unit tests for the fireos build.
testReleaseUnitTest - Run unit tests for the release build.

Other tasks
-----------
apiDump - Syncs API from build dir to provider(?) dir for android-sdk-base

To see all tasks and more detail, run gradlew tasks --all

To see more detail about a task, run gradlew help --task <task>

BUILD SUCCESSFUL in 23s
1 actionable task: 1 executed
~/code/android-sdk git:(SDK-3166/api-check-mapping-file-checks) ▶▶▶ 

And for clarity, your gradle style of overriding gives the same error. Presumably this is because the task doesn't exist.

@radixdev
Copy link
Author

Is this not due to

if (project.name in extension.ignoredProjects) return@configurePlugin
val kotlin = project.extensions.getByName("kotlin") as KotlinMultiplatformExtension
// Create common tasks for multiplatform
val commonApiDump = project.tasks.register("apiDump") {
it.group = "other"
it.description = "Task that collects all target specific dump tasks"
}
val commonApiCheck: TaskProvider<Task> = project.tasks.register("apiCheck") {
it.group = "verification"
it.description = "Shortcut task that depends on all specific check tasks"
}.apply { project.tasks.named("check") { it.dependsOn(this) } }
and no task with the name "apiBuild" being registered?

@ilya-g
Copy link
Member

ilya-g commented Nov 18, 2022

Note that you need the version to be at least 0.12.0 in order to specify jar as the source of apiBuild task.
And in a multiplatform project, it's likely called jvmApiBuild.

@radixdev
Copy link
Author

I was on 0.12.1 (see my original post), I had a typo in my follow-up comment.

@Chozzle
Copy link

Chozzle commented Jan 10, 2023

I'm also seeing this issue. As an aside I'm aiming to run the validator on a minified aar file, not sure if this is expected to work and worth my time?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants