Search in sources :

Example 6 with JpsAndroidModuleExtension

use of org.jetbrains.jps.android.model.JpsAndroidModuleExtension in project android by JetBrains.

the class AndroidFinalPackageElementBuilder method getApkPath.

@Nullable
private static String getApkPath(JpsAndroidFinalPackageElement element) {
    final JpsModuleReference ref = element.getModuleReference();
    final JpsModule module = ref != null ? ref.resolve() : null;
    if (module == null) {
        return null;
    }
    final JpsAndroidModuleExtension extension = AndroidJpsUtil.getExtension(module);
    if (extension == null) {
        return null;
    }
    return getApkPath(extension);
}
Also used : JpsModule(org.jetbrains.jps.model.module.JpsModule) JpsAndroidModuleExtension(org.jetbrains.jps.android.model.JpsAndroidModuleExtension) JpsModuleReference(org.jetbrains.jps.model.module.JpsModuleReference) Nullable(org.jetbrains.annotations.Nullable)

Example 7 with JpsAndroidModuleExtension

use of org.jetbrains.jps.android.model.JpsAndroidModuleExtension in project android by JetBrains.

the class AndroidLibraryPackagingBuilder method doBuild.

private static boolean doBuild(CompileContext context, JpsModule module, BuildOutputConsumer outputConsumer) throws IOException {
    final JpsAndroidModuleExtension extension = AndroidJpsUtil.getExtension(module);
    if (extension == null || !extension.isLibrary()) {
        return true;
    }
    File outputDir = AndroidJpsUtil.getDirectoryForIntermediateArtifacts(context, module);
    outputDir = AndroidJpsUtil.createDirIfNotExist(outputDir, context, BUILDER_NAME);
    if (outputDir == null) {
        return false;
    }
    final File classesDir = ProjectPaths.getModuleOutputDir(module, false);
    if (classesDir == null || !classesDir.isDirectory()) {
        return true;
    }
    final Set<String> subdirs = new HashSet<String>();
    AndroidJpsUtil.addSubdirectories(classesDir, subdirs);
    if (subdirs.size() > 0) {
        context.processMessage(new ProgressMessage(AndroidJpsBundle.message("android.jps.progress.library.packaging", module.getName())));
        final File outputJarFile = new File(outputDir, AndroidCommonUtils.CLASSES_JAR_FILE_NAME);
        final List<String> srcFiles;
        try {
            srcFiles = AndroidCommonUtils.packClassFilesIntoJar(ArrayUtil.EMPTY_STRING_ARRAY, ArrayUtil.toStringArray(subdirs), outputJarFile);
        } catch (IOException e) {
            AndroidJpsUtil.reportExceptionError(context, null, e, BUILDER_NAME);
            return false;
        }
        final AndroidBuildTestingManager testingManager = AndroidBuildTestingManager.getTestingManager();
        if (testingManager != null && outputJarFile.isFile()) {
            testingManager.getCommandExecutor().checkJarContent("library_package_jar", outputJarFile.getPath());
        }
        if (srcFiles.size() > 0) {
            outputConsumer.registerOutputFile(outputJarFile, srcFiles);
        }
    }
    return true;
}
Also used : ProgressMessage(org.jetbrains.jps.incremental.messages.ProgressMessage) AndroidBuildTestingManager(org.jetbrains.android.util.AndroidBuildTestingManager) JpsAndroidModuleExtension(org.jetbrains.jps.android.model.JpsAndroidModuleExtension) IOException(java.io.IOException) File(java.io.File) HashSet(com.intellij.util.containers.HashSet)

Example 8 with JpsAndroidModuleExtension

use of org.jetbrains.jps.android.model.JpsAndroidModuleExtension in project android by JetBrains.

the class AndroidBuildTarget method computeDependencies.

@Override
public Collection<BuildTarget<?>> computeDependencies(final BuildTargetRegistry registry, TargetOutputIndex outputIndex) {
    final List<BuildTarget<?>> result = new ArrayList<BuildTarget<?>>(3);
    fillDependencies(result);
    result.add(new ModuleBuildTarget(myModule, JavaModuleBuildTargetType.PRODUCTION));
    final JpsAndroidModuleExtension extension = AndroidJpsUtil.getExtension(myModule);
    if (extension != null && extension.isPackTestCode()) {
        result.add(new ModuleBuildTarget(myModule, JavaModuleBuildTargetType.TEST));
    }
    return result;
}
Also used : ModuleBuildTarget(org.jetbrains.jps.incremental.ModuleBuildTarget) ModuleBuildTarget(org.jetbrains.jps.incremental.ModuleBuildTarget) JpsAndroidModuleExtension(org.jetbrains.jps.android.model.JpsAndroidModuleExtension) ArrayList(java.util.ArrayList)

Example 9 with JpsAndroidModuleExtension

use of org.jetbrains.jps.android.model.JpsAndroidModuleExtension in project android by JetBrains.

the class AndroidPackagingBuildTarget method collectNativeLibsFolders.

@NotNull
public static String[] collectNativeLibsFolders(@NotNull JpsAndroidModuleExtension extension, boolean checkExistence) {
    final List<String> result = new ArrayList<String>();
    final File libsDir = extension.getNativeLibsDir();
    if (libsDir != null && (!checkExistence || libsDir.exists())) {
        result.add(libsDir.getPath());
    }
    for (JpsAndroidModuleExtension depExtension : AndroidJpsUtil.getAllAndroidDependencies(extension.getModule(), true)) {
        final File depLibsDir = depExtension.getNativeLibsDir();
        if (depLibsDir != null && (!checkExistence || depLibsDir.exists())) {
            result.add(depLibsDir.getPath());
        }
    }
    return ArrayUtil.toStringArray(result);
}
Also used : JpsAndroidModuleExtension(org.jetbrains.jps.android.model.JpsAndroidModuleExtension) ArrayList(java.util.ArrayList) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull)

Example 10 with JpsAndroidModuleExtension

use of org.jetbrains.jps.android.model.JpsAndroidModuleExtension in project android by JetBrains.

the class AndroidManifestMergingTarget method computeRootDescriptors.

@NotNull
@Override
public List<MyRootDescriptor> computeRootDescriptors(JpsModel model, ModuleExcludeIndex index, IgnoredFileIndex ignoredFileIndex, BuildDataPaths dataPaths) {
    final JpsAndroidModuleExtension extension = AndroidJpsUtil.getExtension(myModule);
    assert extension != null;
    final List<MyRootDescriptor> result = new ArrayList<MyRootDescriptor>();
    final File manifestFile = AndroidJpsUtil.getManifestFileForCompilationPath(extension);
    if (manifestFile != null) {
        result.add(new MyRootDescriptor(this, manifestFile, false));
    }
    for (JpsAndroidModuleExtension libExtension : AndroidJpsUtil.getAllAndroidDependencies(myModule, true)) {
        final File libManifest = AndroidJpsUtil.getManifestFileForCompilationPath(libExtension);
        if (libManifest != null && libManifest.exists()) {
            result.add(new MyRootDescriptor(this, libManifest, true));
        }
    }
    return result;
}
Also used : JpsAndroidModuleExtension(org.jetbrains.jps.android.model.JpsAndroidModuleExtension) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

JpsAndroidModuleExtension (org.jetbrains.jps.android.model.JpsAndroidModuleExtension)30 File (java.io.File)16 JpsModule (org.jetbrains.jps.model.module.JpsModule)14 CompilerMessage (org.jetbrains.jps.incremental.messages.CompilerMessage)11 NotNull (org.jetbrains.annotations.NotNull)9 HashMap (com.intellij.util.containers.HashMap)8 ArrayList (java.util.ArrayList)8 BuildRootDescriptor (org.jetbrains.jps.builders.BuildRootDescriptor)7 ProgressMessage (org.jetbrains.jps.incremental.messages.ProgressMessage)7 HashSet (com.intellij.util.containers.HashSet)6 TObjectLongHashMap (gnu.trove.TObjectLongHashMap)6 IAndroidTarget (com.android.sdklib.IAndroidTarget)3 THashSet (gnu.trove.THashSet)3 IOException (java.io.IOException)3 AndroidBuildTestingManager (org.jetbrains.android.util.AndroidBuildTestingManager)3 AndroidCompilerMessageKind (org.jetbrains.android.util.AndroidCompilerMessageKind)3 BuildRootDescriptorImpl (org.jetbrains.jps.builders.impl.BuildRootDescriptorImpl)3 AndroidArtifactSigningMode (org.jetbrains.android.compiler.artifact.AndroidArtifactSigningMode)2 Nullable (org.jetbrains.annotations.Nullable)2 AndroidPlatform (org.jetbrains.jps.android.AndroidPlatform)2