Skip to content

Commit

Permalink
Make final_classes_dex_zip nullable.
Browse files Browse the repository at this point in the history
AOSP has a special resource-only apk that does not contain the dex code for its resources and this change enables reusing the apk packaging logic of the native rules while they are being starlarkified

PiperOrigin-RevId: 562845132
Change-Id: I6d6716b8c627884f47c22e26dea5eb07513cedb9
  • Loading branch information
rjobredeaux3 authored and copybara-github committed Sep 5, 2023
1 parent e8f5082 commit 0807093
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public Artifact getDeployJar() {
}

@Override
@Nullable
public Artifact getFinalClassesDexZip() {
return finalClassesDexZip;
}
Expand Down Expand Up @@ -88,14 +89,14 @@ public String getName() {
@Override
public AndroidDexInfo createInfo(
Artifact deployJar,
Artifact finalClassesDexZip,
Object finalClassesDexZip,
Object finalProguardOutputMap,
Object javaResourceJar)
throws EvalException {

return new AndroidDexInfo(
deployJar,
finalClassesDexZip,
fromNoneable(finalClassesDexZip, Artifact.class),
fromNoneable(finalProguardOutputMap, Artifact.class),
fromNoneable(javaResourceJar, Artifact.class));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ public ApkActionsBuilder setNativeLibs(NativeLibs nativeLibs) {
@CanIgnoreReturnValue
public ApkActionsBuilder setClassesDex(Artifact classesDex) {
Preconditions.checkArgument(
classesDex.getFilename().endsWith(".zip")
classesDex == null
|| classesDex.getFilename().endsWith(".zip")
|| classesDex.getFilename().equals("classes.dex"));
this.classesDex = classesDex;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ public interface AndroidDexInfoApi<FileT extends FileApi> extends StructApi {
structField = true)
FileT getDeployJar();

@Nullable
@StarlarkMethod(
name = "final_classes_dex_zip",
doc = "The zip file containing the final dex classes.",
documented = false,
structField = true)
structField = true,
allowReturnNones = true)
FileT getFinalClassesDexZip();

@Nullable
Expand Down Expand Up @@ -94,6 +96,7 @@ interface Provider<FileT extends FileApi> extends ProviderApi {
name = "final_classes_dex_zip",
allowedTypes = {
@ParamType(type = FileApi.class),
@ParamType(type = NoneType.class),
},
named = true,
doc = "The zip file containing the final dex classes."),
Expand All @@ -120,7 +123,7 @@ interface Provider<FileT extends FileApi> extends ProviderApi {
@StarlarkConstructor
AndroidDexInfoApi<FileT> createInfo(
FileT deployJar,
FileT finalClassesDexZip,
Object finalClassesDexZip,
Object finalProguardOutputMap,
Object javaResourceJar)
throws EvalException;
Expand Down

0 comments on commit 0807093

Please sign in to comment.