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

Remove sourceset registration from Protobuf feature #136

Merged
merged 1 commit into from
Nov 7, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.android.build.api.dsl.CommonExtension;
import com.android.build.api.dsl.LibraryExtension;
import com.android.build.api.variant.LibraryAndroidComponentsExtension;
import com.google.protobuf.gradle.ProtobufExtension;
import org.gradle.api.Project;
import org.gradle.api.artifacts.ConfigurationContainer;
Expand All @@ -14,7 +13,6 @@
import org.gradle.api.internal.plugins.software.SoftwareType;
import org.jetbrains.kotlin.com.google.common.base.Preconditions;

import java.io.File;
import java.util.Objects;
import java.util.Set;

Expand Down Expand Up @@ -96,21 +94,6 @@ protected void configureProtobuf(Project project, AndroidLibrary dslModel, Commo
task.getBuiltins().create("kotlin", builtin -> builtin.getOptions().add("lite"));
});
});

/*
* TODO:DG We don't want to rely on beforeVariants here, but how to do without hardcoding:
* the NiA variants: "demoDebug, demoRelease, prodDebug, prodRelease"?
* This would seem to require some sort of ProductFlavor support (and maybe enumerated buildTypes?)
* which we don't want to add just yet.
*/
LibraryAndroidComponentsExtension androidComponents = project.getExtensions().getByType(LibraryAndroidComponentsExtension.class);
File buildDir = project.getLayout().getBuildDirectory().get().getAsFile();
androidComponents.beforeVariants(androidComponents.selector().all(), variant -> {
android.getSourceSets().register(variant.getName()).configure(sourceSet -> {
sourceSet.getJava().srcDir(new File(buildDir, dslModel.getProtobuf().getGeneratedRootDir().get() + "/" + variant.getName() + "/java"));
sourceSet.getKotlin().srcDir(new File(buildDir, dslModel.getProtobuf().getGeneratedRootDir().get() + "/" + variant.getName() + "/kotlin"));
});
});
} else {
throw new IllegalStateException("We only support lite option currently, not: " + option);
}
Expand Down
Loading