Skip to content

Commit

Permalink
Merge pull request #136 from gradle/tt/remove-protobuf-sourcesets-reg…
Browse files Browse the repository at this point in the history
…istration

Remove sourceset registration from Protobuf feature
  • Loading branch information
tresat authored Nov 7, 2024
2 parents 7496864 + a305234 commit cbebda5
Showing 1 changed file with 0 additions and 17 deletions.
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

0 comments on commit cbebda5

Please sign in to comment.