protected String extractPackageNameFromAndroidManifest( File manifestFile ) { return new DefaultManifestParser( manifestFile ).getPackage(); }
import com.android.builder.DefaultManifestParser def manifestParser = new DefaultManifestParser() println manifestParser.getVersionName(android.sourceSets.main.manifest.srcFile)
@NonNull public static NativeLibrariesPackagingMode getNativeLibrariesLibrariesPackagingMode( @NonNull File manifest) { checkState(manifest.exists()); DefaultManifestParser parser = new DefaultManifestParser(manifest); Boolean extractNativeLibs = parser.getExtractNativeLibs(); // The default is "true", so we only package *.so files differently if the user explicitly // set this to "false". if (Boolean.FALSE.equals(extractNativeLibs)) { return NativeLibrariesPackagingMode.UNCOMPRESSED_AND_ALIGNED; } else { return NativeLibrariesPackagingMode.COMPRESSED; } }
new DefaultManifestParser(atomDependency.getManifest()).getSplit(); if (splitName == null) return config.getOriginalApplicationId();
@Nullable @Override public synchronized String getPackage(@NonNull File manifestFile) { if (mPackage == null) { mPackage = Optional.fromNullable(getStringValue(manifestFile, "/manifest/@package")); } return mPackage.orNull(); }
/** * Builds instance of the parser, and parses the supplied file. */ public DefaultManifestParser(@NonNull File manifestFile) { if (!manifestFile.exists()) { attributeValues = Maps.newHashMap(); } else { Set<String> xPaths = Sets.newHashSet( AndroidManifest.getPackageXPath(), AndroidManifest.getSplitXPath(), AndroidManifest.getVersionNameXPath(), AndroidManifest.getVersionCodeXPath(), AndroidManifest.getMinSdkVersionXPath(), AndroidManifest.getTargetSdkVersionXPath(), AndroidManifest.getInstrumentationRunnerXPath(), AndroidManifest.getTestTargetPackageXPath(), AndroidManifest.getTestFunctionalTestXPath(), AndroidManifest.getTestHandleProfilingXPath(), AndroidManifest.getTestLabelXPath(), AndroidManifest.getExtractNativeLibsXPath()); attributeValues = getStringValues(manifestFile, xPaths); } }
doLast { def manifestParser = new DefaultManifestParser() def manifestVersion = manifestParser.getVersionName(android.sourceSets.main.manifest.srcFile) }
@Nullable @Override public synchronized String getVersionName(@NonNull File manifestFile) { if (mVersionName == null) { mVersionName = Optional.fromNullable( getStringValue(manifestFile, "/manifest/@android:versionName")); } return mVersionName.orNull(); }
final String packageName = new DefaultManifestParser( libManifestFile ).getPackage(); if ( rJavaAlreadyExists( packageName ) )
buildTypes { applicationVariants.all { variant -> variant.outputs.each { output -> def String fileName; if(variant.name == android.buildTypes.release.name) { def manifestParser = new DefaultManifestParser() def String versionName = manifestParser.getVersionName((File) android.sourceSets.main.manifest.srcFile) fileName = "App-release-v${versionName}.apk" } else { //etc } def File file = output.outputFile output.outputFile = new File( file.parent, fileName ) } } release { //etc } }
@Override @NonNull public synchronized int getVersionCode(@NonNull File manifestFile) { if (mVersionCode == null) { mVersionCode = Optional.absent(); try { String value = getStringValue(manifestFile, "/manifest/@android:versionCode"); if (value != null) { mVersionCode = Optional.of(Integer.valueOf(value)); } } catch (NumberFormatException ignored) { } } return mVersionCode.or(-1); }
/** * Parses the manifest file and return the package name. * @param manifestFile the manifest file * @return the package name found or null */ @Nullable public static String getManifestPackage(@NonNull File manifestFile) { return new DefaultManifestParser().getPackage(manifestFile); }
@NonNull private ManifestAttributeSupplier getManifestAttributeSupplier(){ if (mManifestAttributeSupplier == null){ mManifestAttributeSupplier = new DefaultManifestParser(mDefaultSourceProvider.getManifestFile()); } return mManifestAttributeSupplier; } }
externalBuildContext, new AaptOptionsImpl(null, null, false, null), new DefaultManifestParser(androidManifestFile));