ScopedArtifact.CLASSES

Added in 7.4.0

object ScopedArtifact.CLASSES : ScopedArtifact, Artifact.Appendable, Artifact.Transformable, Artifact.Replaceable


.class files, result of sources compilation and/or external dependencies depending on the scope; includes users' transformation, but does not include Jacoco instrumentation

content of POST_COMPILATION_CLASSES plus anything added to CLASSES after compilation.

You should use this if you just need to consume all the classes that will be packaged in the project.

If you need to generate bytecodes post compilation and also need to have access to the compiled classes, you cannot directly consume CLASSES and append to it as it would create a circular dependency.

Instead, consume POST_COMPILATION_CLASSES and use CLASSES to append your bytecodes to.

extension.onVariants(extension.selector().withBuildType("debug")) {  variant ->
val generatorTask = project.tasks.register(
"postCompilation${variant.name.capitalizeFirstChar()}Task",
AddPostCompilationCodeGeneratorTask::class.java) { task ->
// configure your task
}

// consume the result of compilation
variant.artifacts.forScope(Scope.PROJECT)
.use(generatorTask)
.toGet(
ScopedArtifact.POST_COMPILATION_CLASSES,
AddPostCompilationCodeGeneratorTask::jars,
AddPostCompilationCodeGeneratorTask::dirs
)

// and produce the new bytecodes.
variant.artifacts.forScope(Scope.PROJECT)
.use(generatorTask)
.toAppend(ScopedArtifact.CLASSES, AddPostCompilationCodeGeneratorTask::outputDir)
}

Summary

Inherited functions

From com.android.build.api.artifact.Artifact
open String
open String
String

Provide a unique name for the artifact type.