com.android.build.gradle.internal.dsl.PackagingOptions Java Examples

The following examples show how to use com.android.build.gradle.internal.dsl.PackagingOptions. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TransformReplacer.java    From atlas with Apache License 2.0 6 votes vote down vote up
public void replaceMergeJavaResourcesTransform(AppVariantContext appVariantContext, BaseVariantOutput vod) {
    List<TransformTask> baseTransforms = TransformManager.findTransformTaskByTransformType(
            variantContext, MergeJavaResourcesTransform.class);
    for (TransformTask transformTask : baseTransforms) {
        MergeJavaResourcesTransform transform = (MergeJavaResourcesTransform) transformTask.getTransform();
        PackagingOptions packagingOptions = (PackagingOptions) ReflectUtils.getField(transform, "packagingOptions");
        packagingOptions.exclude("**.aidl");
        packagingOptions.exclude("**.cfg");
        Set<? super QualifiedContent.Scope> mergeScopes = (Set<? super QualifiedContent.Scope>) ReflectUtils.getField(transform, "mergeScopes");
        Set<QualifiedContent.ContentType> mergedType = (Set<QualifiedContent.ContentType>) ReflectUtils.getField(transform, "mergedType");
        String name = (String) ReflectUtils.getField(transform, "name");
        AtlasMergeJavaResourcesTransform atlasMergeJavaResourcesTransform = new AtlasMergeJavaResourcesTransform(appVariantContext.getAppVariantOutputContext(ApkDataUtils.get(vod)), packagingOptions, mergeScopes, mergedType.iterator().next(), name, appVariantContext.getScope());
        ReflectUtils.updateField(transformTask, "transform",
                atlasMergeJavaResourcesTransform);
    }

}
 
Example #2
Source File: ApkBuilder.java    From javafxmobile-plugin with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private JavaAndNativeResourceFilter(@Nullable PackagingOptions packagingOptions) {
    mPackagingOptions = packagingOptions;

    mExcludes = mPackagingOptions != null ? mPackagingOptions.getExcludes() :
            Collections.<String>emptySet();
    mPickFirsts = mPackagingOptions != null ? mPackagingOptions.getPickFirsts() :
            Collections.<String>emptySet();
}
 
Example #3
Source File: AndroidConfigHelper.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
public static void configure(
        @NonNull AndroidConfig model,
        @NonNull Instantiator instantiator) {
    model.setDefaultPublishConfig(BuilderConstants.RELEASE);
    model.setPublishNonDefault(false);
    model.setGeneratePureSplits(false);
    model.setPreProcessingOptions(instantiator.newInstance(PreprocessingOptions.class));
    model.setAaptOptions(instantiator.newInstance(AaptOptions.class));
    model.setDexOptions(instantiator.newInstance(DexOptions.class));
    model.setLintOptions(instantiator.newInstance(LintOptions.class));
    model.setCompileOptions(instantiator.newInstance(CompileOptions.class));
    model.setPackagingOptions(instantiator.newInstance(PackagingOptions.class));
    model.setSplits(instantiator.newInstance(Splits.class, instantiator));
    model.setLibraryRequests(Lists.<LibraryRequest>newArrayList());
}
 
Example #4
Source File: AtlasMergeJavaResourcesTransform.java    From atlas with Apache License 2.0 5 votes vote down vote up
public AtlasMergeJavaResourcesTransform(AppVariantOutputContext appVariantOutputContext, PackagingOptions packagingOptions, Set<? super QualifiedContent.Scope> mergeScopes, QualifiedContent.ContentType mergedType, String name, VariantScope variantScope) {
    super(packagingOptions, mergeScopes, mergedType, name, variantScope);
    this.packagingOptions = packagingOptions;
    this.name = name;
    this.mergeScopes = ImmutableSet.copyOf(mergeScopes);
    this.mergedType = ImmutableSet.of(mergedType);
    this.intermediateDir = variantScope.getIncrementalDir(
            variantScope.getFullVariantName() + "-" + name);
    waitableExecutor = WaitableExecutor.useGlobalSharedThreadPool();
    this.appVariantOutputContext = appVariantOutputContext;
    if (mergedType == QualifiedContent.DefaultContentType.RESOURCES) {
        acceptedPathsPredicate =
                path -> !path.endsWith(SdkConstants.DOT_CLASS)
                        && !path.endsWith(SdkConstants.DOT_NATIVE_LIBS);
    } else if (mergedType == ExtendedContentType.NATIVE_LIBS) {
        acceptedPathsPredicate =
                path -> {
                    Matcher m = JAR_ABI_PATTERN.matcher(path);

                    // if the ABI is accepted, check the 3rd segment
                    if (m.matches()) {
                        paths.add(path);
                        // remove the beginning of the path (lib/<abi>/)
                        String filename = path.substring(5 + m.group(1).length());
                        // and check the filename
                        return ABI_FILENAME_PATTERN.matcher(filename).matches() ||
                                SdkConstants.FN_GDBSERVER.equals(filename) ||
                                SdkConstants.FN_GDB_SETUP.equals(filename);
                    }

                    return false;

                };
    } else {
        throw new UnsupportedOperationException(
                "mergedType param must be RESOURCES or NATIVE_LIBS");
    }
}
 
Example #5
Source File: PackageSplitAbi.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
public void setPackagingOptions(PackagingOptions packagingOptions) {
    this.packagingOptions = packagingOptions;
}
 
Example #6
Source File: AndroidConfigAdaptor.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
@Override
public PackagingOptions getPackagingOptions() {
    return model.getPackagingOptions();
}
 
Example #7
Source File: BaseExtension.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public PackagingOptions getPackagingOptions() {
    return packagingOptions;
}
 
Example #8
Source File: BaseExtension.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Configures packaging options.
 */
public void packagingOptions(Action<PackagingOptions> action) {
    checkWritability();
    action.execute(packagingOptions);
}
 
Example #9
Source File: BaseExtension.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
BaseExtension(
        @NonNull final ProjectInternal project,
        @NonNull Instantiator instantiator,
        @NonNull AndroidBuilder androidBuilder,
        @NonNull SdkHandler sdkHandler,
        @NonNull NamedDomainObjectContainer<BuildType> buildTypes,
        @NonNull NamedDomainObjectContainer<ProductFlavor> productFlavors,
        @NonNull NamedDomainObjectContainer<SigningConfig> signingConfigs,
        @NonNull ExtraModelInfo extraModelInfo,
        final boolean isLibrary) {
    this.androidBuilder = androidBuilder;
    this.sdkHandler = sdkHandler;
    this.buildTypes = buildTypes;
    //noinspection unchecked
    this.productFlavors = (NamedDomainObjectContainer) productFlavors;
    this.signingConfigs = signingConfigs;
    this.extraModelInfo = extraModelInfo;
    this.project = project;

    logger = Logging.getLogger(this.getClass());

    defaultConfig = instantiator.newInstance(ProductFlavor.class, BuilderConstants.MAIN,
            project, instantiator, project.getLogger());

    aaptOptions = instantiator.newInstance(AaptOptions.class);
    dexOptions = instantiator.newInstance(DexOptions.class);
    lintOptions = instantiator.newInstance(LintOptions.class);
    compileOptions = instantiator.newInstance(CompileOptions.class);
    packagingOptions = instantiator.newInstance(PackagingOptions.class);
    preprocessingOptions = instantiator.newInstance(PreprocessingOptions.class);
    splits = instantiator.newInstance(Splits.class, instantiator);

    sourceSetsContainer = project.container(AndroidSourceSet.class,
            new AndroidSourceSetFactory(instantiator, project, isLibrary));

    sourceSetsContainer.whenObjectAdded(new Action<AndroidSourceSet>() {
        @Override
        public void execute(AndroidSourceSet sourceSet) {
            ConfigurationContainer configurations = project.getConfigurations();

            createConfiguration(
                    configurations,
                    sourceSet.getCompileConfigurationName(),
                    "Classpath for compiling the " + sourceSet.getName() + " sources.");

            String packageConfigDescription;
            if (isLibrary) {
                packageConfigDescription
                        = "Classpath only used when publishing '" + sourceSet.getName() + "'.";
            } else {
                packageConfigDescription
                        = "Classpath packaged with the compiled '" + sourceSet.getName() + "' classes.";
            }
            createConfiguration(
                    configurations,
                    sourceSet.getPackageConfigurationName(),
                    packageConfigDescription);

            createConfiguration(
                    configurations,
                    sourceSet.getProvidedConfigurationName(),
                    "Classpath for only compiling the " + sourceSet.getName() + " sources.");

            createConfiguration(
                    configurations,
                    sourceSet.getWearAppConfigurationName(),
                    "Link to a wear app to embed for object '" + sourceSet.getName() + "'.");

            sourceSet.setRoot(String.format("src/%s", sourceSet.getName()));
        }
    });

    sourceSetsContainer.create(defaultConfig.getName());
}
 
Example #10
Source File: PackageApplication.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
public void setPackagingOptions(PackagingOptions packagingOptions) {
    this.packagingOptions = packagingOptions;
}
 
Example #11
Source File: PackageApplication.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
@Nested
public PackagingOptions getPackagingOptions() {
    return packagingOptions;
}
 
Example #12
Source File: AndroidExtension.java    From javafxmobile-plugin with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public AndroidExtension(Project project, ToolingModelBuilderRegistry registry) {
    this.project = project;

    this.extraModelInfo = new ExtraModelInfo(new ProjectOptions(project), project.getLogger());

    this.signingConfig = project.getExtensions().create("signingConfig", SigningConfig.class, "signing");
    this.packagingOptions = project.getExtensions().create("packagingOptions", PackagingOptions.class);
    this.dexOptions = project.getExtensions().create("dexOptions", DexOptions.class, extraModelInfo);

    try {
        this.buildCache = FileCache.getInstanceWithMultiProcessLocking(new File(AndroidLocation.getFolder(), "build-cache"));
    } catch (AndroidLocation.AndroidLocationException e) {
        throw new RuntimeException(e);
    }

    LoggerWrapper loggerWrapper = new LoggerWrapper(project.getLogger());

    this.sdkHandler = new SdkHandler(project, loggerWrapper);
    this.androidBuilder = new AndroidBuilder(
            project == project.getRootProject() ? project.getName() : project.getPath(),
            "JavaFX Mobile",
            new GradleProcessExecutor(project),
            new GradleJavaProcessExecutor(project),
            extraModelInfo,
            loggerWrapper,
            false);

    this.androidTaskRegistry = new AndroidTaskRegistry();
    this.taskFactory = new TaskContainerAdaptor(project.getTasks());

    installDirectory = new File(project.getBuildDir(), "javafxports/android");
    project.getLogger().info("Android install directory: " + installDirectory);

    temporaryDirectory = new File(project.getBuildDir(), "javafxports/tmp/android");
    project.getLogger().info("Android temporary output directory: " + temporaryDirectory);

    resourcesDirectory = new File(temporaryDirectory, "resources");
    resourcesDirectory.mkdirs();
    project.getLogger().info("Resources directory: " + resourcesDirectory);

    multidexOutputDirectory = new File(temporaryDirectory, "multi-dex");
    multidexOutputDirectory.mkdirs();
    project.getLogger().info("Multi-dex output directory: " + multidexOutputDirectory);

    dexOutputDirectory = new File(temporaryDirectory, "dex");
    dexOutputDirectory.mkdirs();
    project.getLogger().info("Dex output directory: " + dexOutputDirectory);
}
 
Example #13
Source File: PackageSplitAbi.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
@Nested
public PackagingOptions getPackagingOptions() {
    return packagingOptions;
}
 
Example #14
Source File: AndroidExtension.java    From javafxmobile-plugin with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public PackagingOptions getPackagingOptions() {
    return packagingOptions;
}
 
Example #15
Source File: ApkBuilder.java    From javafxmobile-plugin with BSD 3-Clause "New" or "Revised" License 3 votes vote down vote up
/**
 * Creates a new instance.
 *
 * This creates a new builder that will create the specified output file, using the two
 * mandatory given input files.
 *
 * Optional {@link PrivateKey} and {@link X509Certificate} can be provided to sign the APK.
 *
 * An optional {@link PrintStream} can also be provided for verbose output. If null, there will
 * be no output.
 *
 * @param apkFile the file to create
 * @param resFile the file representing the packaged resource file.
 * @param dexFile the file representing the dex file. This can be null for apk with no code.
 * @param key the private key used to sign the package. Can be null.
 * @param certificate the certificate used to sign the package. Can be null.
 * @param packagingOptions
 * @param verboseStream the stream to which verbose output should go. If null, verbose mode
 *                      is not enabled.
 * @throws ApkCreationException
 */
public ApkBuilder(File apkFile, File resFile, File dexFile, PrivateKey key,
        X509Certificate certificate, PackagingOptions packagingOptions, PrintStream verboseStream) throws ApkCreationException {
    mFilter = new JavaAndNativeResourceFilter(packagingOptions);

    init(apkFile, resFile, dexFile, key, certificate, verboseStream);
}
 
Example #16
Source File: ApkBuilder.java    From javafxmobile-plugin with BSD 3-Clause "New" or "Revised" License 3 votes vote down vote up
/**
 * Creates a new instance.
 *
 * This creates a new builder that will create the specified output file, using the two
 * mandatory given input files.
 *
 * An optional debug keystore can be provided. If set, it is expected that the store password
 * is 'android' and the key alias and password are 'androiddebugkey' and 'android'.
 *
 * An optional {@link PrintStream} can also be provided for verbose output. If null, there will
 * be no output.
 *
 * @param apkFile the file to create
 * @param resFile the file representing the packaged resource file.
 * @param dexFile the file representing the dex file. This can be null for apk with no code.
 * @param debugStoreOsPath the OS path to the debug keystore, if needed or null.
 * @param verboseStream the stream to which verbose output should go. If null, verbose mode
 *                      is not enabled.
 * @throws ApkCreationException
 */
public ApkBuilder(File apkFile, File resFile, File dexFile, String debugStoreOsPath,
        PackagingOptions packagingOptions, final PrintStream verboseStream) throws ApkCreationException {
    mFilter = new JavaAndNativeResourceFilter(packagingOptions);

    SigningInfo info = getDebugKey(debugStoreOsPath, verboseStream);
    if (info != null) {
        init(apkFile, resFile, dexFile, info.key, info.certificate, verboseStream);
    } else {
        init(apkFile, resFile, dexFile, null /*key*/, null/*certificate*/, verboseStream);
    }
}
 
Example #17
Source File: ApkBuilder.java    From javafxmobile-plugin with BSD 3-Clause "New" or "Revised" License 3 votes vote down vote up
/**
 * Creates a new instance.
 *
 * This creates a new builder that will create the specified output file, using the two
 * mandatory given input files.
 *
 * Optional {@link PrivateKey} and {@link X509Certificate} can be provided to sign the APK.
 *
 * An optional {@link PrintStream} can also be provided for verbose output. If null, there will
 * be no output.
 *
 * @param apkOsPath the OS path of the file to create.
 * @param resOsPath the OS path of the packaged resource file.
 * @param dexOsPath the OS path of the dex file. This can be null for apk with no code.
 * @param key the private key used to sign the package. Can be null.
 * @param certificate the certificate used to sign the package. Can be null.
 * @param verboseStream the stream to which verbose output should go. If null, verbose mode
 *                      is not enabled.
 * @throws ApkCreationException
 */
public ApkBuilder(String apkOsPath, String resOsPath, String dexOsPath, PrivateKey key,
                  X509Certificate certificate, PackagingOptions packagingOptions,
                  PrintStream verboseStream) throws ApkCreationException {
    this(new File(apkOsPath),
         new File(resOsPath),
         dexOsPath != null ? new File(dexOsPath) : null,
         key, certificate, packagingOptions,
         verboseStream);
}
 
Example #18
Source File: ApkBuilder.java    From javafxmobile-plugin with BSD 3-Clause "New" or "Revised" License 3 votes vote down vote up
/**
 * Creates a new instance.
 *
 * This creates a new builder that will create the specified output file, using the two
 * mandatory given input files.
 *
 * An optional debug keystore can be provided. If set, it is expected that the store password
 * is 'android' and the key alias and password are 'androiddebugkey' and 'android'.
 *
 * An optional {@link PrintStream} can also be provided for verbose output. If null, there will
 * be no output.
 *
 * @param apkOsPath the OS path of the file to create.
 * @param resOsPath the OS path of the packaged resource file.
 * @param dexOsPath the OS path of the dex file. This can be null for apk with no code.
 * @param verboseStream the stream to which verbose output should go. If null, verbose mode
 *                      is not enabled.
 * @throws ApkCreationException
 */
public ApkBuilder(String apkOsPath, String resOsPath, String dexOsPath, String storeOsPath,
        PackagingOptions packagingOptions, PrintStream verboseStream) throws ApkCreationException {
    this(new File(apkOsPath),
         new File(resOsPath),
         dexOsPath != null ? new File(dexOsPath) : null,
         storeOsPath,
         packagingOptions,
         verboseStream);
}
 
Example #19
Source File: AndroidConfig.java    From javaide with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Packaging options.
 */
PackagingOptions getPackagingOptions();
 
Example #20
Source File: AndroidConfig.java    From javaide with GNU General Public License v3.0 votes vote down vote up
/**
 * Packaging options.
 */

PackagingOptions getPackagingOptions();
 
Example #21
Source File: AndroidConfig.java    From javaide with GNU General Public License v3.0 votes vote down vote up
void setPackagingOptions(PackagingOptions packagingOptions);