com.android.builder.model.SigningConfig Java Examples
The following examples show how to use
com.android.builder.model.SigningConfig.
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: VariantManager.java From javaide with GNU General Public License v3.0 | 6 votes |
private SigningConfig createSigningOverride() { AndroidGradleOptions.SigningOptions signingOptions = AndroidGradleOptions.getSigningOptions(project); if (signingOptions != null) { com.android.build.gradle.internal.dsl.SigningConfig signingConfigDsl = new com.android.build.gradle.internal.dsl.SigningConfig("externalOverride"); signingConfigDsl.setStoreFile(new File(signingOptions.storeFile)); signingConfigDsl.setStorePassword(signingOptions.keyPassword); signingConfigDsl.setKeyAlias(signingOptions.keyAlias); signingConfigDsl.setKeyPassword(signingOptions.keyPassword); if (signingOptions.storeType != null) { signingConfigDsl.setStoreType(signingOptions.storeType); } return signingConfigDsl; } return null; }
Example #2
Source File: VariantConfiguration.java From javaide with GNU General Public License v3.0 | 6 votes |
/** * Creates the configuration with the base source sets, and an optional tested variant. * * @param defaultConfig the default configuration. Required. * @param defaultSourceProvider the default source provider. Required * @param buildType the build type for this variant. Required. * @param buildTypeSourceProvider the source provider for the build type. * @param type the type of the project. * @param signingConfigOverride an optional Signing override to be used for signing. */ public VariantConfiguration( @NonNull D defaultConfig, @NonNull SourceProvider defaultSourceProvider, @NonNull T buildType, @Nullable SourceProvider buildTypeSourceProvider, @NonNull VariantType type, @Nullable SigningConfig signingConfigOverride) { checkNotNull(defaultConfig); checkNotNull(defaultSourceProvider); checkNotNull(buildType); checkNotNull(type); checkArgument( true, "You have to specify the tested variant for this variant type."); mDefaultConfig = checkNotNull(defaultConfig); mDefaultSourceProvider = checkNotNull(defaultSourceProvider); mBuildType = checkNotNull(buildType); mBuildTypeSourceProvider = buildTypeSourceProvider; mType = checkNotNull(type); mSigningConfigOverride = signingConfigOverride; mMergedFlavor = DefaultProductFlavor.clone(mDefaultConfig); }
Example #3
Source File: ProductFlavorAdaptor.java From javaide with GNU General Public License v3.0 | 5 votes |
@Nullable @Override public SigningConfig getSigningConfig() { return productFlavor.getSigningConfig() == null ? null : new SigningConfigAdaptor(productFlavor.getSigningConfig()); }
Example #4
Source File: ModelBuilder.java From javaide with GNU General Public License v3.0 | 5 votes |
@NonNull private static Collection<SigningConfig> cloneSigningConfigs( @NonNull Collection<? extends SigningConfig> signingConfigs) { Collection<SigningConfig> results = Lists.newArrayListWithCapacity(signingConfigs.size()); for (SigningConfig signingConfig : signingConfigs) { results.add(SigningConfigImpl.createSigningConfig(signingConfig)); } return results; }
Example #5
Source File: DefaultAndroidProject.java From javaide with GNU General Public License v3.0 | 5 votes |
DefaultAndroidProject( @NonNull String modelVersion, @NonNull String name, @NonNull Collection<String> flavorDimensions, @NonNull String compileTarget, @NonNull Collection<String> bootClasspath, @NonNull Collection<File> frameworkSource, @NonNull Collection<SigningConfig> signingConfigs, @NonNull AaptOptions aaptOptions, @NonNull Collection<ArtifactMetaData> extraArtifacts, @NonNull Collection<String> unresolvedDependencies, @NonNull Collection<SyncIssue> syncIssues, @NonNull CompileOptions compileOptions, @NonNull LintOptions lintOptions, @NonNull File buildFolder, @Nullable String resourcePrefix, boolean isLibrary, int apiVersion) { this.modelVersion = modelVersion; this.name = name; this.flavorDimensions = flavorDimensions; this.compileTarget = compileTarget; this.bootClasspath = bootClasspath; this.frameworkSource = frameworkSource; this.signingConfigs = signingConfigs; this.aaptOptions = aaptOptions; this.extraArtifacts = extraArtifacts; this.unresolvedDependencies = unresolvedDependencies; this.syncIssues = syncIssues; javaCompileOptions = new DefaultJavaCompileOptions(compileOptions); this.lintOptions = lintOptions; this.buildFolder = buildFolder; this.resourcePrefix = resourcePrefix; this.isLibrary = isLibrary; this.apiVersion = apiVersion; }
Example #6
Source File: SigningConfigImpl.java From javaide with GNU General Public License v3.0 | 5 votes |
@NonNull static SigningConfig createSigningConfig(@NonNull SigningConfig signingConfig) { return new SigningConfigImpl( signingConfig.getName(), signingConfig.getStoreFile(), signingConfig.getStorePassword(), signingConfig.getKeyAlias(), signingConfig.getKeyPassword(), signingConfig.getStoreType(), signingConfig.isSigningReady()); }
Example #7
Source File: ReadOnlyObjectProvider.java From javaide with GNU General Public License v3.0 | 5 votes |
/** * Returns an read-only version of a signing config. * * @param signingConfig the signing config. * @return an read-only version. */ @Nullable public SigningConfig getSigningConfig(@Nullable SigningConfig signingConfig) { if (signingConfig == null) { return null; } SigningConfig readOnlySigningConfig = this.readOnlySigningConfig.get(signingConfig); if (readOnlySigningConfig == null) { this.readOnlySigningConfig.put(signingConfig, readOnlySigningConfig = new ReadOnlySigningConfig(signingConfig)); } return readOnlySigningConfig; }
Example #8
Source File: GradleVariantConfiguration.java From javaide with GNU General Public License v3.0 | 5 votes |
/** * Creates a {@link GradleVariantConfiguration} for a normal (non-test) variant. */ public GradleVariantConfiguration( @NonNull CoreProductFlavor defaultConfig, @NonNull SourceProvider defaultSourceProvider, @NonNull CoreBuildType buildType, @Nullable SourceProvider buildTypeSourceProvider, @NonNull VariantType type, @Nullable SigningConfig signingConfigOverride) { super(defaultConfig, defaultSourceProvider, buildType, buildTypeSourceProvider, type, signingConfigOverride); }
Example #9
Source File: AndroidBuilder.java From javaide with GNU General Public License v3.0 | 5 votes |
/** * Signs a single jar file using the passed {@link SigningConfig}. * * @param in the jar file to sign. * @param signingConfig the signing configuration * @param out the file path for the signed jar. * @throws IOException * @throws KeytoolException * @throws SigningException * @throws NoSuchAlgorithmException * @throws SignedJarBuilder.IZipEntryFilter.ZipAbortException * @throws com.android.builder.signing.SigningException */ public void signApk(File in, SigningConfig signingConfig, File out) throws IOException, KeytoolException, SigningException, NoSuchAlgorithmException, SignedJarBuilder.IZipEntryFilter.ZipAbortException, com.android.builder.signing.SigningException { CertificateInfo certificateInfo = null; if (signingConfig != null && signingConfig.isSigningReady()) { //noinspection ConstantConditions - isSigningReady() called above. certificateInfo = KeystoreHelper.getCertificateInfo(signingConfig.getStoreType(), signingConfig.getStoreFile(), signingConfig.getStorePassword(), signingConfig.getKeyPassword(), signingConfig.getKeyAlias()); if (certificateInfo == null) { throw new SigningException("Failed to read key from keystore"); } } SignedJarBuilder signedJarBuilder = new SignedJarBuilder( new FileOutputStream(out), certificateInfo != null ? certificateInfo.getKey() : null, certificateInfo != null ? certificateInfo.getCertificate() : null, Packager.getLocalVersion(), mCreatedBy); signedJarBuilder.writeZip(new FileInputStream(in)); signedJarBuilder.close(); }
Example #10
Source File: VariantConfiguration.java From javaide with GNU General Public License v3.0 | 5 votes |
@Nullable public SigningConfig getSigningConfig() { if (mSigningConfigOverride != null) { return mSigningConfigOverride; } SigningConfig signingConfig = mBuildType.getSigningConfig(); if (signingConfig != null) { return signingConfig; } return mMergedFlavor.getSigningConfig(); }
Example #11
Source File: AndroidBuilder.java From javaide with GNU General Public License v3.0 | 4 votes |
/** * Packages the apk. * * @param androidResPkgLocation the location of the packaged resource file * @param dexFolder the folder with the dex file. * @param dexedLibraries optional collection of additional dex files to put in the apk. * @param packagedJars the jars that are packaged (libraries + jar dependencies) * @param javaResourcesLocation the processed Java resource folder * @param jniLibsFolders the folders containing jni shared libraries * @param mergingFolder folder to contain files that are being merged * @param abiFilters optional ABI filter * @param jniDebugBuild whether the app should include jni debug data * @param signingConfig the signing configuration * @param packagingOptions the packaging options * @param outApkLocation location of the APK. * @throws DuplicateFileException * @throws FileNotFoundException if the store location was not found * @throws KeytoolException * @throws PackagerException * @throws SigningException when the key cannot be read from the keystore * @see VariantConfiguration#getPackagedJars() */ public void packageApk( @NonNull String androidResPkgLocation, @Nullable File dexFolder, @NonNull Collection<File> dexedLibraries, @NonNull Collection<File> packagedJars, @Nullable String javaResourcesLocation, @Nullable Collection<File> jniLibsFolders, @NonNull File mergingFolder, @Nullable Set<String> abiFilters, boolean jniDebugBuild, @Nullable SigningConfig signingConfig, @Nullable PackagingOptions packagingOptions, @Nullable SignedJarBuilder.IZipEntryFilter packagingOptionsFilter, @NonNull String outApkLocation) throws DuplicateFileException, FileNotFoundException, KeytoolException, PackagerException, SigningException { checkNotNull(androidResPkgLocation, "androidResPkgLocation cannot be null."); checkNotNull(outApkLocation, "outApkLocation cannot be null."); CertificateInfo certificateInfo = null; if (signingConfig != null && signingConfig.isSigningReady()) { //noinspection ConstantConditions - isSigningReady() called above. certificateInfo = KeystoreHelper.getCertificateInfo(signingConfig.getStoreType(), signingConfig.getStoreFile(), signingConfig.getStorePassword(), signingConfig.getKeyPassword(), signingConfig.getKeyAlias()); if (certificateInfo == null) { throw new SigningException("Failed to read key from keystore"); } } try { Packager packager = new Packager( outApkLocation, androidResPkgLocation, mergingFolder, certificateInfo, mCreatedBy, packagingOptions, packagingOptionsFilter, mLogger); // add dex folder to the apk root. if (dexFolder != null) { if (!dexFolder.isDirectory()) { throw new IllegalArgumentException("dexFolder must be a directory"); } packager.addDexFiles(dexFolder, dexedLibraries); } packager.setJniDebugMode(jniDebugBuild); if (javaResourcesLocation != null && !packagedJars.isEmpty()) { throw new PackagerException("javaResourcesLocation and packagedJars both provided"); } if (javaResourcesLocation != null || !packagedJars.isEmpty()) { packager.addResources(javaResourcesLocation != null ? new File(javaResourcesLocation) : Iterables.getOnlyElement(packagedJars)); } // also add resources from library projects and jars if (jniLibsFolders != null) { for (File jniFolder : jniLibsFolders) { if (jniFolder.isDirectory()) { packager.addNativeLibraries(jniFolder, abiFilters); } } } packager.sealApk(); } catch (SealedPackageException e) { // shouldn't happen since we control the package from start to end. throw new RuntimeException(e); } }
Example #12
Source File: BuildTypeAdaptor.java From javaide with GNU General Public License v3.0 | 4 votes |
@Nullable @Override public SigningConfig getSigningConfig() { return buildType.getSigningConfig() == null ? null : new SigningConfigAdaptor(buildType.getSigningConfig()); }
Example #13
Source File: DefaultAndroidProject.java From javaide with GNU General Public License v3.0 | 4 votes |
@Override @NonNull public Collection<SigningConfig> getSigningConfigs() { return signingConfigs; }
Example #14
Source File: VariantConfiguration.java From javaide with GNU General Public License v3.0 | 4 votes |
public boolean isSigningReady() { SigningConfig signingConfig = getSigningConfig(); return signingConfig != null && signingConfig.isSigningReady(); }
Example #15
Source File: VariantManager.java From javaide with GNU General Public License v3.0 | 4 votes |
public void addSigningConfig(@NonNull SigningConfig signingConfig) { signingConfigs.put(signingConfig.getName(), signingConfig); }
Example #16
Source File: VariantManager.java From javaide with GNU General Public License v3.0 | 4 votes |
@Override @NonNull public Map<String, SigningConfig> getSigningConfigs() { return signingConfigs; }
Example #17
Source File: BuildTypeImpl.java From javaide with GNU General Public License v3.0 | 4 votes |
@Nullable @Override public SigningConfig getSigningConfig() { return null; }
Example #18
Source File: DefaultBuildType.java From javaide with GNU General Public License v3.0 | 4 votes |
/** * Sets the signing configuration. e.g.: {@code signingConfig signingConfigs.myConfig} */ @NonNull public BuildType setSigningConfig(@Nullable SigningConfig signingConfig) { mSigningConfig = signingConfig; return this; }
Example #19
Source File: DefaultBuildType.java From javaide with GNU General Public License v3.0 | 4 votes |
/** * Sets the signing configuration. e.g.: {@code signingConfig signingConfigs.myConfig} */ @Override @Nullable public SigningConfig getSigningConfig() { return mSigningConfig; }
Example #20
Source File: DefaultProductFlavor.java From javaide with GNU General Public License v3.0 | 4 votes |
/** * Signing config used by this product flavor. */ @Override @Nullable public SigningConfig getSigningConfig() { return mSigningConfig; }
Example #21
Source File: ModelBuilder.java From javaide with GNU General Public License v3.0 | 4 votes |
private AndroidArtifact createAndroidArtifact( @NonNull String name, @NonNull BaseVariantData<? extends BaseVariantOutputData> variantData) { VariantScope scope = variantData.getScope(); GradleVariantConfiguration variantConfiguration = variantData.getVariantConfiguration(); SigningConfig signingConfig = variantConfiguration.getSigningConfig(); String signingConfigName = null; if (signingConfig != null) { signingConfigName = signingConfig.getName(); } SourceProviders sourceProviders = determineSourceProviders(variantData); // get the outputs List<? extends BaseVariantOutputData> variantOutputs = variantData.getOutputs(); List<AndroidArtifactOutput> outputs = Lists.newArrayListWithCapacity(variantOutputs.size()); Collection<NativeLibrary> nativeLibraries = ImmutableList.of(); for (BaseVariantOutputData variantOutputData : variantOutputs) { int intVersionCode; if (variantOutputData instanceof ApkVariantOutputData) { intVersionCode = variantOutputData.getVersionCode(); } else { Integer versionCode = variantConfiguration.getMergedFlavor().getVersionCode(); intVersionCode = versionCode != null ? versionCode : 1; } ImmutableCollection.Builder<OutputFile> outputFiles = ImmutableList.builder(); // add the main APK outputFiles.add(new OutputFileImpl( variantOutputData.getMainOutputFile().getFilters(), variantOutputData.getMainOutputFile().getType().name(), variantOutputData.getOutputFile())); for (ApkOutputFile splitApk : variantOutputData.getOutputs()) { if (splitApk.getType() == OutputFile.OutputType.SPLIT) { outputFiles.add(new OutputFileImpl( splitApk.getFilters(), OutputFile.SPLIT, splitApk.getOutputFile())); } } // add the main APK. outputs.add(new AndroidArtifactOutputImpl( outputFiles.build(), "assemble" + variantOutputData.getFullName(), variantOutputData.getScope().getManifestOutputFile(), intVersionCode)); } return new AndroidArtifactImpl( name, outputs, variantData.assembleVariantTask == null ? scope.getTaskName("assemble") : variantData.assembleVariantTask.getName(), variantConfiguration.isSigningReady() || variantData.outputsAreSigned, signingConfigName, variantConfiguration.getApplicationId(), // TODO: Need to determine the tasks' name when the tasks may not be created // in component plugin. scope.getSourceGenTask() == null ? scope.getTaskName("generate", "Sources") : scope.getSourceGenTask().getName(), scope.getCompileTask() == null ? scope.getTaskName("compile", "Sources") : scope.getCompileTask().getName(), getGeneratedSourceFolders(variantData), getGeneratedResourceFolders(variantData), (variantData.javacTask != null) ? variantData.javacTask.getDestinationDir() : scope.getJavaOutputDir(), scope.getJavaResourcesDestinationDir(), DependenciesImpl.cloneDependencies(variantData, androidBuilder), sourceProviders.variantSourceProvider, sourceProviders.multiFlavorSourceProvider, nativeLibraries, variantConfiguration.getMergedBuildConfigFields(), variantConfiguration.getMergedResValues()); }
Example #22
Source File: DefaultProductFlavor.java From javaide with GNU General Public License v3.0 | 4 votes |
/** Sets the signing configuration. e.g.: {@code signingConfig signingConfigs.myConfig} */ @NonNull public ProductFlavor setSigningConfig(SigningConfig signingConfig) { mSigningConfig = signingConfig; return this; }
Example #23
Source File: ModelBuilder.java From javaide with GNU General Public License v3.0 | 4 votes |
@Override public Object buildAll(String modelName, Project project) { Collection<? extends SigningConfig> signingConfigs = config.getSigningConfigs(); // Get the boot classpath. This will ensure the target is configured. List<String> bootClasspath = androidBuilder.getBootClasspathAsStrings(); List<File> frameworkSource = Collections.emptyList(); // List of extra artifacts, with all test variants added. List<ArtifactMetaData> artifactMetaDataList = Lists.newArrayList( extraModelInfo.getExtraArtifacts()); LintOptions lintOptions = com.android.build.gradle.internal.dsl.LintOptions.create( config.getLintOptions()); AaptOptions aaptOptions = AaptOptionsImpl.create(config.getAaptOptions()); List<SyncIssue> syncIssues = Lists.newArrayList(extraModelInfo.getSyncIssues().values()); List<String> flavorDimensionList = (config.getFlavorDimensionList() != null ? config.getFlavorDimensionList() : Lists.<String>newArrayList()); DefaultAndroidProject androidProject = new DefaultAndroidProject( Version.ANDROID_GRADLE_PLUGIN_VERSION, project.getName(), flavorDimensionList, androidBuilder.getTarget() != null ? androidBuilder.getTarget().hashString() : "", bootClasspath, frameworkSource, cloneSigningConfigs(config.getSigningConfigs()), aaptOptions, artifactMetaDataList, findUnresolvedDependencies(syncIssues), syncIssues, config.getCompileOptions(), lintOptions, project.getBuildDir(), config.getResourcePrefix(), isLibrary, Version.BUILDER_MODEL_API_VERSION); androidProject.setDefaultConfig(ProductFlavorContainerImpl.createProductFlavorContainer( variantManager.getDefaultConfig(), extraModelInfo.getExtraFlavorSourceProviders( variantManager.getDefaultConfig().getProductFlavor().getName()))); for (BuildTypeData btData : variantManager.getBuildTypes().values()) { androidProject.addBuildType(BuildTypeContainerImpl.create( btData, extraModelInfo.getExtraBuildTypeSourceProviders(btData.getBuildType().getName()))); } for (ProductFlavorData pfData : variantManager.getProductFlavors().values()) { androidProject.addProductFlavors(ProductFlavorContainerImpl.createProductFlavorContainer( pfData, extraModelInfo.getExtraFlavorSourceProviders(pfData.getProductFlavor().getName()))); } for (BaseVariantData<? extends BaseVariantOutputData> variantData : variantManager.getVariantDataList()) { androidProject.addVariant(createVariant(variantData)); } return androidProject; }
Example #24
Source File: ProductFlavorImpl.java From javaide with GNU General Public License v3.0 | 4 votes |
@Nullable @Override public SigningConfig getSigningConfig() { return null; }
Example #25
Source File: ApkVariantImpl.java From javaide with GNU General Public License v3.0 | 4 votes |
@Override public SigningConfig getSigningConfig() { return readOnlyObjectProvider.getSigningConfig( getApkVariantData().getVariantConfiguration().getSigningConfig()); }
Example #26
Source File: ReadOnlyBuildType.java From javaide with GNU General Public License v3.0 | 4 votes |
@Nullable @Override public SigningConfig getSigningConfig() { return readOnlyObjectProvider.getSigningConfig(buildType.getSigningConfig()); }
Example #27
Source File: ReadOnlySigningConfig.java From javaide with GNU General Public License v3.0 | 4 votes |
ReadOnlySigningConfig(@NonNull SigningConfig signingConfig) { this.signingConfig = signingConfig; }
Example #28
Source File: ReadOnlyProductFlavor.java From javaide with GNU General Public License v3.0 | 4 votes |
@Nullable @Override public SigningConfig getSigningConfig() { return readOnlyObjectProvider.getSigningConfig(productFlavor.getSigningConfig()); }
Example #29
Source File: VariantModel.java From javaide with GNU General Public License v3.0 | 4 votes |
@NonNull Map<String, ? extends SigningConfig> getSigningConfigs();
Example #30
Source File: ValidateSigningTask.java From javaide with GNU General Public License v3.0 | 4 votes |
public void setSigningConfig(SigningConfig signingConfig) { this.signingConfig = signingConfig; }