Commit 516cd43b authored by ZhengCornell's avatar ZhengCornell Committed by Evan W. Patton

Move shared constants from Compiler and ComponentListGenerator into ComponentDescriptorConstants

parent 6f939f64
...@@ -161,6 +161,7 @@ ...@@ -161,6 +161,7 @@
<fileset dir="${local.lib.dir}" includes="*.jar"/> <fileset dir="${local.lib.dir}" includes="*.jar"/>
<fileset dir="${build.dir}" includes="common/CommonUtils.jar" /> <fileset dir="${build.dir}" includes="common/CommonUtils.jar" />
<fileset dir="${build.dir}" includes="common/CommonVersion.jar" /> <fileset dir="${build.dir}" includes="common/CommonVersion.jar" />
<fileset dir="${build.dir}" includes="components/CommonConstants.jar" />
<fileset dir="${lib.dir}" includes="bouncycastle/bcprov-jdk15on-149.jar"/> <fileset dir="${lib.dir}" includes="bouncycastle/bcprov-jdk15on-149.jar"/>
<fileset dir="${lib.dir}" includes="bouncycastle/bcpkix-jdk15on-149.jar"/> <fileset dir="${lib.dir}" includes="bouncycastle/bcpkix-jdk15on-149.jar"/>
<fileset dir="${lib.dir}" includes="android/tools/common-24.3.0.jar"/> <fileset dir="${lib.dir}" includes="android/tools/common-24.3.0.jar"/>
......
// -*- mode: java; c-basic-offset: 2; -*-
// Copyright 2011-2019 MIT, All rights reserved
// Released under the Apache License, Version 2.0
// http://www.apache.org/licenses/LICENSE-2.0
package com.google.appinventor.components.common;
/**
* Contains constants related to the description of Simple components.
*
*/
public final class ComponentDescriptorConstants {
private ComponentDescriptorConstants() {
// nothing
}
// shared constants between ComponentListGenerator.java and Compiler.java
public static final String ARMEABI_V7A_SUFFIX = "-v7a";
public static final String ARM64_V8A_SUFFIX = "-v8a";
public static final String X86_64_SUFFIX = "-x8a";
public static final String ASSET_DIRECTORY = "component";
public static final String ASSETS_TARGET = "assets";
public static final String ACTIVITIES_TARGET = "activities";
public static final String LIBRARIES_TARGET = "libraries";
public static final String NATIVE_TARGET = "native";
public static final String PERMISSIONS_TARGET = "permissions";
public static final String BROADCAST_RECEIVERS_TARGET = "broadcastReceivers";
public static final String ANDROIDMINSDK_TARGET = "androidMinSdk";
public static final String CONDITIONALS_TARGET = "conditionals";
// TODO(Will): Remove the following target once the deprecated
// @SimpleBroadcastReceiver annotation is removed. It should
// should remain for the time being because otherwise we'll break
// extensions currently using @SimpleBroadcastReceiver.
public static final String BROADCAST_RECEIVER_TARGET = "broadcastReceiver";
}
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
package com.google.appinventor.components.scripts; package com.google.appinventor.components.scripts;
import com.google.appinventor.common.utils.StringUtils; import com.google.appinventor.common.utils.StringUtils;
import com.google.appinventor.components.common.ComponentDescriptorConstants;
import java.io.IOException; import java.io.IOException;
import java.io.Writer; import java.io.Writer;
...@@ -23,22 +24,6 @@ import javax.tools.FileObject; ...@@ -23,22 +24,6 @@ import javax.tools.FileObject;
* @author lizlooney@google.com (Liz Looney) * @author lizlooney@google.com (Liz Looney)
*/ */
public final class ComponentListGenerator extends ComponentProcessor { public final class ComponentListGenerator extends ComponentProcessor {
// Names of component information types to be output. Must match buildserver.compiler constants.
private static final String PERMISSIONS_TARGET = "permissions";
private static final String LIBRARIES_TARGET = "libraries";
private static final String ASSETS_TARGET = "assets";
private static final String NATIVE_TARGET = "native";
private static final String BROADCAST_RECEIVERS_TARGET = "broadcastReceivers";
private static final String ACTIVITIES_TARGET = "activities";
private static final String ANDROIDMINSDK_TARGET = "androidMinSdk";
private static final String CONDITONAL_TARGET = "conditional";
// TODO(Will): Remove the following target once the deprecated
// @SimpleBroadcastReceiver annotation is removed. It should
// should remain for the time being because otherwise we'll break
// extensions currently using @SimpleBroadcastReceiver.
private static final String BROADCAST_RECEIVER_TARGET = "broadcastReceiver";
// Where to write results. Build Info is the collection of permissions, asset and library info. // Where to write results. Build Info is the collection of permissions, asset and library info.
private static final String COMPONENT_LIST_OUTPUT_FILE_NAME = "simple_components.txt"; private static final String COMPONENT_LIST_OUTPUT_FILE_NAME = "simple_components.txt";
private static final String COMPONENT_BUILD_INFO_OUTPUT_FILE_NAME = private static final String COMPONENT_BUILD_INFO_OUTPUT_FILE_NAME =
...@@ -91,19 +76,19 @@ public final class ComponentListGenerator extends ComponentProcessor { ...@@ -91,19 +76,19 @@ public final class ComponentListGenerator extends ComponentProcessor {
private static void outputComponentBuildInfo(ComponentInfo component, StringBuilder sb) { private static void outputComponentBuildInfo(ComponentInfo component, StringBuilder sb) {
sb.append("{\"type\": \""); sb.append("{\"type\": \"");
sb.append(component.type).append("\""); sb.append(component.type).append("\"");
appendComponentInfo(sb, PERMISSIONS_TARGET, component.permissions); appendComponentInfo(sb, ComponentDescriptorConstants.PERMISSIONS_TARGET, component.permissions);
appendComponentInfo(sb, LIBRARIES_TARGET, component.libraries); appendComponentInfo(sb, ComponentDescriptorConstants.LIBRARIES_TARGET, component.libraries);
appendComponentInfo(sb, NATIVE_TARGET, component.nativeLibraries); appendComponentInfo(sb, ComponentDescriptorConstants.NATIVE_TARGET, component.nativeLibraries);
appendComponentInfo(sb, ASSETS_TARGET, component.assets); appendComponentInfo(sb, ComponentDescriptorConstants.ASSETS_TARGET, component.assets);
appendComponentInfo(sb, ACTIVITIES_TARGET, component.activities); appendComponentInfo(sb, ComponentDescriptorConstants.ACTIVITIES_TARGET, component.activities);
appendComponentInfo(sb, ANDROIDMINSDK_TARGET, Collections.singleton(Integer.toString(component.getAndroidMinSdk()))); appendComponentInfo(sb, ComponentDescriptorConstants.ANDROIDMINSDK_TARGET, Collections.singleton(Integer.toString(component.getAndroidMinSdk())));
appendComponentInfo(sb, BROADCAST_RECEIVERS_TARGET, component.broadcastReceivers); appendComponentInfo(sb, ComponentDescriptorConstants.BROADCAST_RECEIVERS_TARGET, component.broadcastReceivers);
appendConditionalComponentInfo(component, sb); appendConditionalComponentInfo(component, sb);
// TODO(Will): Remove the following call once the deprecated // TODO(Will): Remove the following call once the deprecated
// @SimpleBroadcastReceiver annotation is removed. It should // @SimpleBroadcastReceiver annotation is removed. It should
// should remain for the time being because otherwise we'll break // should remain for the time being because otherwise we'll break
// extensions currently using @SimpleBroadcastReceiver. // extensions currently using @SimpleBroadcastReceiver.
appendComponentInfo(sb, BROADCAST_RECEIVER_TARGET, component.classNameAndActionsBR); appendComponentInfo(sb, ComponentDescriptorConstants.BROADCAST_RECEIVER_TARGET, component.classNameAndActionsBR);
sb.append("}"); sb.append("}");
} }
...@@ -119,10 +104,10 @@ public final class ComponentListGenerator extends ComponentProcessor { ...@@ -119,10 +104,10 @@ public final class ComponentListGenerator extends ComponentProcessor {
component.conditionalBroadcastReceivers.size() == 0) { component.conditionalBroadcastReceivers.size() == 0) {
return; return;
} }
sb.append(", \"conditionals\": { "); sb.append(", \"" + ComponentDescriptorConstants.CONDITIONALS_TARGET + "\": { ");
sb.append("\"permissions\": "); sb.append("\"" + ComponentDescriptorConstants.PERMISSIONS_TARGET + "\": ");
appendMap(sb, component.conditionalPermissions); appendMap(sb, component.conditionalPermissions);
sb.append(", \"broadcastReceivers\": "); sb.append(", \"" + ComponentDescriptorConstants.BROADCAST_RECEIVERS_TARGET + "\": ");
appendMap(sb, component.conditionalBroadcastReceivers); appendMap(sb, component.conditionalBroadcastReceivers);
sb.append("}"); sb.append("}");
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment