Search in sources :

Example 11 with JavaLibrary

use of com.android.builder.model.JavaLibrary in project meghanada-server by mopemope.

the class AndroidSupport method parseExtraJavaArtifacts.

private void parseExtraJavaArtifacts(Set<ProjectDependency> dependencies, Variant variant) {
    String buildType = variant.getBuildType();
    boolean debugBuild = buildType.equals(DEBUG_BUILD);
    Collection<JavaArtifact> extraJavaArtifacts = variant.getExtraJavaArtifacts();
    for (JavaArtifact javaArtifact : extraJavaArtifacts) {
        if (debugBuild) {
            Collection<File> generatedSourceFolders = javaArtifact.getGeneratedSourceFolders();
            for (File src : generatedSourceFolders) {
                this.project.getSources().add(src);
            }
        }
        Dependencies compileDependencies = javaArtifact.getDependencies();
        Collection<AndroidLibrary> libraries = compileDependencies.getLibraries();
        for (AndroidLibrary androidLibrary : libraries) {
            Collection<File> localJars = androidLibrary.getLocalJars();
            for (File jar : localJars) {
                addDependencies(dependencies, jar);
            }
        }
        Collection<JavaLibrary> javaLibraries = compileDependencies.getJavaLibraries();
        for (JavaLibrary javaLibrary : javaLibraries) {
            File file = javaLibrary.getJarFile();
            addDependencies(dependencies, file);
        }
    }
}
Also used : JavaArtifact(com.android.builder.model.JavaArtifact) JavaLibrary(com.android.builder.model.JavaLibrary) AndroidLibrary(com.android.builder.model.AndroidLibrary) Dependencies(com.android.builder.model.Dependencies) File(java.io.File)

Example 12 with JavaLibrary

use of com.android.builder.model.JavaLibrary in project meghanada-server by mopemope.

the class AndroidSupport method parseExtraAndroidArtifacts.

private void parseExtraAndroidArtifacts(Set<ProjectDependency> dependencies, Variant variant) {
    String buildType = variant.getBuildType();
    boolean debugBuild = buildType.equals(DEBUG_BUILD);
    Collection<AndroidArtifact> extraAndroidArtifacts = variant.getExtraAndroidArtifacts();
    for (AndroidArtifact androidArtifact : extraAndroidArtifacts) {
        String name = androidArtifact.getName();
        boolean isTest = name.contains(TEST_SUFFIX);
        if (debugBuild) {
            Collection<File> generatedSourceFolders = androidArtifact.getGeneratedSourceFolders();
            for (File src : generatedSourceFolders) {
                if (isTest) {
                    this.project.getTestSources().add(src);
                } else {
                    this.project.getSources().add(src);
                }
            }
            Collection<File> generatedResourceFolders = androidArtifact.getGeneratedResourceFolders();
            for (File src : generatedResourceFolders) {
                if (isTest) {
                    this.project.getTestResources().add(src);
                } else {
                    this.project.getResources().add(src);
                }
            }
        }
        Dependencies compileDependencies = androidArtifact.getDependencies();
        // getLibraries
        Collection<AndroidLibrary> libraries = compileDependencies.getLibraries();
        for (AndroidLibrary androidLibrary : libraries) {
            Collection<File> localJars = androidLibrary.getLocalJars();
            if (localJars.isEmpty()) {
                File jar = androidLibrary.getJarFile();
                addDependencies(dependencies, jar);
            } else {
                for (File jar : localJars) {
                    addDependencies(dependencies, jar);
                }
            }
        }
        // getJavaLibraries
        Collection<JavaLibrary> javaLibraries = compileDependencies.getJavaLibraries();
        for (JavaLibrary javaLibrary : javaLibraries) {
            File file = javaLibrary.getJarFile();
            addDependencies(dependencies, file);
        }
    }
}
Also used : JavaLibrary(com.android.builder.model.JavaLibrary) AndroidLibrary(com.android.builder.model.AndroidLibrary) Dependencies(com.android.builder.model.Dependencies) AndroidArtifact(com.android.builder.model.AndroidArtifact) File(java.io.File)

Example 13 with JavaLibrary

use of com.android.builder.model.JavaLibrary in project atlas by alibaba.

the class AtlasDepTreeParser method check.

private void check(AtlasDependencyTree atlasDependencyTree) {
    Map<String, List<String>> dependeys = new HashMap<>();
    for (AwbBundle awbBundle : atlasDependencyTree.getAwbBundles()) {
        String gav = awbBundle.getAndroidLibrary().getResolvedCoordinates().toString();
        for (AndroidLibrary androidLibrary : awbBundle.getAndroidLibraries()) {
            addValuetoList(dependeys, gav, androidLibrary.getResolvedCoordinates().toString());
        }
        for (JavaLibrary javaLibrary : awbBundle.getJavaLibraries()) {
            addValuetoList(dependeys, gav, javaLibrary.getResolvedCoordinates().toString());
        }
        for (SoLibrary soLibrary : awbBundle.getSoLibraries()) {
            addValuetoList(dependeys, gav, soLibrary.getResolvedCoordinates().toString());
        }
    }
    List<String> warnings = new ArrayList<>();
    for (String key : dependeys.keySet()) {
        List<String> values = dependeys.get(key);
        if (values.size() > 1) {
            String msg = key + ":" + StringUtils.join(values, ",");
            warnings.add(msg);
            logger.warning(msg);
        }
    }
    if (warnings.size() > 0) {
        logger.warning(JSON.toJSONString(atlasDependencyTree.getDependencyJson(), true));
        throw new GradleException("decencyconflict : " + StringUtils.join(warnings, "\r\n"));
    }
}
Also used : JavaLibrary(com.android.builder.model.JavaLibrary) AndroidLibrary(com.android.builder.model.AndroidLibrary) GradleException(org.gradle.api.GradleException) AwbBundle(com.taobao.android.builder.dependency.model.AwbBundle) SoLibrary(com.taobao.android.builder.dependency.model.SoLibrary)

Example 14 with JavaLibrary

use of com.android.builder.model.JavaLibrary in project atlas by alibaba.

the class AwbBundle method getLibraryJars.

/**
 * Get all the associated jars
 *
 * @return
 */
public List<File> getLibraryJars() {
    List<File> jars = Lists.newArrayList();
    jars.add(androidLibrary.getJarFile());
    Collection<File> localJars = androidLibrary.getLocalJars();
    if (null != localJars) {
        jars.addAll(localJars);
    }
    if (null != androidLibraries) {
        for (AndroidLibrary aarBundle : androidLibraries) {
            if (aarBundle.getJarFile().exists()) {
                jars.add(aarBundle.getJarFile());
            }
            jars.addAll(aarBundle.getLocalJars());
        }
    }
    if (null != javaLibraries) {
        for (JavaLibrary javaLibrary : javaLibraries) {
            if (javaLibrary.getJarFile().exists()) {
                jars.add(javaLibrary.getJarFile());
            }
        }
    }
    return jars;
}
Also used : JavaLibrary(com.android.builder.model.JavaLibrary) AndroidLibrary(com.android.builder.model.AndroidLibrary) File(java.io.File)

Aggregations

JavaLibrary (com.android.builder.model.JavaLibrary)14 AndroidLibrary (com.android.builder.model.AndroidLibrary)11 SoLibrary (com.taobao.android.builder.dependency.model.SoLibrary)5 File (java.io.File)5 AwbBundle (com.taobao.android.builder.dependency.model.AwbBundle)4 Dependencies (com.android.builder.model.Dependencies)3 ArrayList (java.util.ArrayList)3 AndroidArtifact (com.android.builder.model.AndroidArtifact)2 MtlBaseTaskAction (com.taobao.android.builder.tasks.manager.MtlBaseTaskAction)2 HashSet (java.util.HashSet)2 TaskAction (org.gradle.api.tasks.TaskAction)2 NonNull (com.android.annotations.NonNull)1 Nullable (com.android.annotations.Nullable)1 TransformException (com.android.build.api.transform.TransformException)1 BaseVariantOutput (com.android.build.gradle.api.BaseVariantOutput)1 TaskContainerAdaptor (com.android.build.gradle.internal.TaskContainerAdaptor)1 AppVariantContext (com.android.build.gradle.internal.api.AppVariantContext)1 AppVariantOutputContext (com.android.build.gradle.internal.api.AppVariantOutputContext)1 AwbTransform (com.android.build.gradle.internal.api.AwbTransform)1 AtlasAndroidLibraryImpl (com.android.build.gradle.internal.ide.AtlasAndroidLibraryImpl)1