use of com.android.utils.StdLogger in project bazel by bazelbuild.
the class AarGeneratorAction method main.
public static void main(String[] args) {
Stopwatch timer = Stopwatch.createStarted();
OptionsParser optionsParser = OptionsParser.newOptionsParser(Options.class);
optionsParser.parseAndExitUponError(args);
Options options = optionsParser.getOptions(Options.class);
checkFlags(options);
AndroidResourceProcessor resourceProcessor = new AndroidResourceProcessor(new StdLogger(com.android.utils.StdLogger.Level.VERBOSE));
try (ScopedTemporaryDirectory scopedTmp = new ScopedTemporaryDirectory("aar_gen_tmp")) {
Path tmp = scopedTmp.getPath();
Path resourcesOut = tmp.resolve("merged_resources");
Files.createDirectories(resourcesOut);
Path assetsOut = tmp.resolve("merged_assets");
Files.createDirectories(assetsOut);
logger.fine(String.format("Setup finished at %dms", timer.elapsed(TimeUnit.MILLISECONDS)));
// There aren't any dependencies, but we merge to combine primary resources from different
// res/assets directories into a single res and single assets directory.
MergedAndroidData mergedData = AndroidResourceMerger.mergeData(options.mainData, ImmutableList.<DependencyAndroidData>of(), ImmutableList.<DependencyAndroidData>of(), resourcesOut, assetsOut, null, VariantType.LIBRARY, null);
logger.fine(String.format("Merging finished at %dms", timer.elapsed(TimeUnit.MILLISECONDS)));
writeAar(options.aarOutput, mergedData, options.manifest, options.rtxt, options.classes);
logger.fine(String.format("Packaging finished at %dms", timer.elapsed(TimeUnit.MILLISECONDS)));
} catch (IOException | MergingException e) {
logger.log(Level.SEVERE, "Error during merging resources", e);
System.exit(1);
}
System.exit(0);
}
use of com.android.utils.StdLogger in project android by JetBrains.
the class KeystoreUtils method getOrCreateDefaultDebugKeystore.
public static File getOrCreateDefaultDebugKeystore() throws Exception {
try {
File debugLocation = new File(KeystoreHelper.defaultDebugKeystoreLocation());
if (!debugLocation.exists()) {
File keystoreDirectory = new File(AndroidLocation.getFolder());
if (!keystoreDirectory.canWrite()) {
throw new AndroidLocationException("Could not create debug keystore because \"" + keystoreDirectory + "\" is not writable");
}
ILogger logger = new StdLogger(StdLogger.Level.ERROR);
// Default values taken from http://developer.android.com/tools/publishing/app-signing.html
// Keystore name: "debug.keystore"
// Keystore password: "android"
// Keystore alias: "androiddebugkey"
// Key password: "android"
KeystoreHelper.createDebugStore(null, debugLocation, "android", "android", "AndroidDebugKey", logger);
}
if (!debugLocation.exists()) {
throw new AndroidLocationException("Could not create debug keystore");
}
return debugLocation;
} catch (AndroidLocationException exception) {
throw new Exception("Failed to get debug keystore path", exception);
}
}
use of com.android.utils.StdLogger in project bazel by bazelbuild.
the class RClassGeneratorTest method setUp.
@Before
public void setUp() throws Exception {
temp = Files.createTempDirectory(toString());
stdLogger = new StdLogger(StdLogger.Level.VERBOSE);
}
use of com.android.utils.StdLogger in project android by JetBrains.
the class RecipeMergeUtils method mergeManifest.
/**
* Merges the given manifest fragment into the given manifest file
*/
@Nullable
private static String mergeManifest(@NotNull File moduleRoot, @NotNull final File targetManifest, @NotNull final String targetXml, @NotNull final String mergeText) {
try {
boolean isMasterManifest = FileUtil.filesEqual(moduleRoot, targetManifest.getParentFile());
//noinspection SpellCheckingInspection
final File tempFile2 = new File(targetManifest.getParentFile(), "nevercreated.xml");
StdLogger logger = new StdLogger(StdLogger.Level.INFO);
MergingReport mergeReport = ManifestMerger2.newMerger(targetManifest, logger, ManifestMerger2.MergeType.APPLICATION).withFeatures(ManifestMerger2.Invoker.Feature.EXTRACT_FQCNS, ManifestMerger2.Invoker.Feature.NO_PLACEHOLDER_REPLACEMENT).addLibraryManifest(tempFile2).asType(isMasterManifest ? XmlDocument.Type.MAIN : XmlDocument.Type.OVERLAY).withFileStreamProvider(new ManifestMerger2.FileStreamProvider() {
@Override
protected InputStream getInputStream(@NotNull File file) throws FileNotFoundException {
String text = FileUtil.filesEqual(file, targetManifest) ? targetXml : mergeText;
return new ByteArrayInputStream(text.getBytes(Charsets.UTF_8));
}
}).merge();
if (mergeReport.getResult().isSuccess()) {
return mergeReport.getMergedDocument(MergingReport.MergedManifestKind.MERGED);
}
return null;
} catch (ManifestMerger2.MergeFailureException e) {
LOG.warn(e);
return null;
}
}
Aggregations