com.android.builder.model.JavaLibrary Java Examples

The following examples show how to use com.android.builder.model.JavaLibrary. 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: DependencyConvertUtils.java    From atlas with Apache License 2.0 6 votes vote down vote up
/**
 * Simple transformations, no dependencies
 *
 * @param resolvedDependencyInfo
 * @return
 */
public static AndroidLibrary toAndroidLibrary(ResolvedDependencyInfo resolvedDependencyInfo, Project project,
                                              boolean bundle) {

    ResolvedArtifact artifact = resolvedDependencyInfo.getResolvedArtifact();

    AndroidDependency androidDependency = AndroidDependency.createExplodedAarLibrary(artifact.getFile(),
                                                                                     convert(artifact,bundle?Type.AWB:Type.AAR),
                                                                                     resolvedDependencyInfo
                                                                                         .getDependencyName(),
                                                                                     null,
                                                                                     resolvedDependencyInfo
                                                                                         .getExplodedDir());

    List<File> localJars = new ArrayList<>();

    return new AtlasAndroidLibraryImpl(androidDependency,
                                  false,
                                  false,
                                  ImmutableList.<AndroidLibrary>of(),
                                  ImmutableList.<JavaLibrary>of(),
                                  localJars);
}
 
Example #2
Source File: AtlasDepTreeParser.java    From atlas with Apache License 2.0 5 votes vote down vote up
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"));
        }
    }
 
Example #3
Source File: AndroidSupport.java    From meghanada-server with GNU General Public License v3.0 5 votes vote down vote up
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);
    }
  }
}
 
Example #4
Source File: ArtifactData.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
private String makeSrcFileName() {
    File f;
    if (library instanceof AndroidLibrary) {
        f = ((AndroidLibrary) library).getBundle();
    } else {
        f = ((JavaLibrary) library).getJarFile();
    }
    String name = f.getName();
    String baseName = FilenameUtils.getBaseName(name);
    return baseName + SRC_NAME;
}
 
Example #5
Source File: ArtifactData.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
private String makePomFileName() {
    File f;
    if (library instanceof AndroidLibrary) {
        f = ((AndroidLibrary) library).getBundle();
    } else {
        f = ((JavaLibrary) library).getJarFile();
    }
    String name = f.getName();
    String baseName = FilenameUtils.getBaseName(name);
    return baseName + DependencyNode.POM_NAME;
}
 
Example #6
Source File: ArtifactData.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
private String makeJavadocFileName() {
    File f;
    if (library instanceof AndroidLibrary) {
        f = ((AndroidLibrary) library).getBundle();
    } else {
        f = ((JavaLibrary) library).getJarFile();
    }
    String name = f.getName();
    String baseName = FilenameUtils.getBaseName(name);
    return baseName + JAVADOC_NAME;
}
 
Example #7
Source File: AndroidClassPathProvider.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
@Override
public Iterable<? extends File> get() {
    Variant variant = buildConfig.getCurrentVariant();
    if (variant != null) {
        AndroidArtifact testArtifact = AndroidBuildVariants.instrumentTestArtifact(variant.getExtraAndroidArtifacts());
        Iterable<File> testCompileCPEntries
                = Collections.<File>singleton(variant.getMainArtifact().getClassesFolder());
        if (testArtifact != null) {
            List<File> javaLibs = new ArrayList<>();
            for (JavaLibrary lib : testArtifact.getDependencies().getJavaLibraries()) {
                collectJavaLibraries(javaLibs, lib);
            }
            testCompileCPEntries = Iterables.concat(
                    testCompileCPEntries,
                    Iterables.transform(
                            testArtifact.getDependencies().getLibraries(),
                            new Function<AndroidLibrary, File>() {
                        @Override
                        public File apply(AndroidLibrary f) {
                            return f.getJarFile();
                        }
                    }),
                    javaLibs);
        }
        return testCompileCPEntries;
    }
    return Collections.<File>emptyList();
}
 
Example #8
Source File: AndroidClassPathProvider.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
private void addJavaLibraryDependencies(List<URL> roots, Map<URL, ArtifactData> libs, JavaLibrary lib) {
    URL root = FileUtil.urlForArchiveOrDir(FileUtil.normalizeFile(lib.getJarFile()));
    if (!roots.contains(root)) {
        roots.add(root);
        libs.put(root, new ArtifactData(lib, project));
    }
    for (JavaLibrary childLib : lib.getDependencies()) {
        addJavaLibraryDependencies(roots, libs, childLib);
    }
}
 
Example #9
Source File: DependenciesImpl.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
@NonNull
static DependenciesImpl cloneDependenciesForJavaArtifacts(@NonNull Dependencies dependencies) {
    List<AndroidLibrary> libraries = Collections.emptyList();
    List<JavaLibrary> javaLibraries = Lists.newArrayList(dependencies.getJavaLibraries());
    List<String> projects = Collections.emptyList();

    return new DependenciesImpl(libraries, javaLibraries, projects);
}
 
Example #10
Source File: DependenciesImpl.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
private DependenciesImpl(@NonNull List<AndroidLibrary> libraries,
                         @NonNull List<JavaLibrary> javaLibraries,
                         @NonNull List<String> projects) {
    this.libraries = libraries;
    this.javaLibraries = javaLibraries;
    this.projects = projects;
}
 
Example #11
Source File: ConfigurationDependencies.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
@NonNull
@Override
public Collection<JavaLibrary> getJavaLibraries() {
    Set<File> files = configuration.getFiles();
    if (files.isEmpty()) {
        return Collections.emptySet();
    }
    Set<JavaLibrary> javaLibraries = Sets.newHashSet();
    for (File file : files) {
        javaLibraries.add(new JavaLibraryImpl(file, null, null));
    }
    return javaLibraries;
}
 
Example #12
Source File: LintGradleProject.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
@NonNull
@Override
public List<File> getJavaLibraries() {
    if (mJavaLibraries == null) {
        Collection<JavaLibrary> libs = mVariant.getMainArtifact().getDependencies().getJavaLibraries();
        mJavaLibraries = Lists.newArrayListWithExpectedSize(libs.size());
        for (JavaLibrary lib : libs) {
            File jar = lib.getJarFile();
            if (jar.exists()) {
                mJavaLibraries.add(jar);
            }
        }
    }
    return mJavaLibraries;
}
 
Example #13
Source File: AtlasAndroidLibraryImpl.java    From atlas with Apache License 2.0 5 votes vote down vote up
public AtlasAndroidLibraryImpl(
            @NonNull AndroidDependency clonedLibrary,
            boolean isProvided,
            boolean isSkipped,
            @NonNull List<AndroidLibrary> androidLibraries,
            @NonNull Collection<JavaLibrary> javaLibraries,
            @NonNull Collection<File> localJavaLibraries) {
        super(
                clonedLibrary.getProjectPath(),
                null,
                clonedLibrary.getCoordinates(),
                isSkipped,
                isProvided);


        this.androidLibrary = clonedLibrary;
        this.androidLibraries = ImmutableList.copyOf(androidLibraries);
        this.javaLibraries = ImmutableList.copyOf(javaLibraries);
        this.variant = androidLibrary.getVariant();
        //FIXME , add localJar later at prepareAllDependencies
//        this.localJars = clonedLibrary.getLocalJars();
//        variant = clonedLibrary.getVariant();
////        bundle = .getArtifactFile();
////        bundle = clonedLibrary.getClasspathFile();
//        folder = clonedLibrary.getExtractedFolder();
//        manifest = clonedLibrary.getManifest();
//        jarFile = clonedLibrary.getJarFile();
//        resFolder = clonedLibrary.getResFolder();
//        assetsFolder = clonedLibrary.getAssetsFolder();
//        jniFolder = clonedLibrary.getJniFolder();
//        aidlFolder = clonedLibrary.getAidlFolder();
//        renderscriptFolder = clonedLibrary.getRenderscriptFolder();
//        proguardRules = clonedLibrary.getProguardRules();
//        lintJar = clonedLibrary.getLintJar();
//        annotations = clonedLibrary.getExternalAnnotations();
//        publicResources = clonedLibrary.getPublicResources();
//        symbolFile = clonedLibrary.getSymbolFile();
//        hashcode = computeHashCode();
    }
 
Example #14
Source File: DependencyConvertUtils.java    From atlas with Apache License 2.0 5 votes vote down vote up
public static AndroidLibrary toAndroidLibrary(MavenCoordinates mavenCoordinates, File artifact, File dir) {

        AndroidDependency androidDependency = AndroidDependency.createExplodedAarLibrary(artifact,
                                                                                         mavenCoordinates,
                                                                                         mavenCoordinates.toString(),
                                                                                         null,
                                                                                         dir);

        return new AtlasAndroidLibraryImpl(androidDependency,
                                      false,
                                      false,
                                      ImmutableList.<AndroidLibrary>of(),
                                      ImmutableList.<JavaLibrary>of(),
                                      androidDependency.getLocalJars());
    }
 
Example #15
Source File: DependencyConvertUtils.java    From atlas with Apache License 2.0 5 votes vote down vote up
/**
 * Convert to jar dependency
 *
 * @param resolvedDependencyInfo
 * @return
 */
public static JavaLibrary toJavaLib(ResolvedDependencyInfo resolvedDependencyInfo) {

    ResolvedArtifact artifact = resolvedDependencyInfo.getResolvedArtifact();

    JavaLibrary jarInfo = new JavaLibraryImpl(artifact.getFile(),
                                              null,
                                              ImmutableList.<JavaLibrary>of(),
                                              null,
                                              convert(artifact,Type.JAR),
                                              false,
                                              false);
    return jarInfo;
}
 
Example #16
Source File: AwbBundle.java    From atlas with Apache License 2.0 5 votes vote down vote up
public List<String> getAllDependencies() {
    List<String> list = new ArrayList<>();
    for (AndroidLibrary androidL : getAllLibraryAars()) {
        list.add(androidL.getResolvedCoordinates().toString());
    }
    for (JavaLibrary javaLibrary : getJavaLibraries()) {
        list.add(javaLibrary.getResolvedCoordinates().toString());
    }
    for (SoLibrary soLibrary : getSoLibraries()) {
        list.add(soLibrary.getResolvedCoordinates().toString());
    }
    Collections.sort(list);
    return list;
}
 
Example #17
Source File: AwbBundle.java    From atlas with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #18
Source File: ProGuardPercentPrinter.java    From atlas with Apache License 2.0 5 votes vote down vote up
private static File getFile(Object library) {
    File file;
    if (library instanceof AndroidLibrary) {
        file = ((AndroidLibrary) library).getJarFile();
    } else if (library instanceof JavaLibrary) {
        file = ((JavaLibrary) library).getJarFile();
    } else {

        //file =;
        throw new IllegalArgumentException(
                "unexpected library type: " + library.getClass().getName());
    }
    return file;
}
 
Example #19
Source File: DependenciesImpl.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
public DependenciesImpl(@NonNull Set<JavaLibrary> javaLibraries) {
    this.javaLibraries = Lists.newArrayList(javaLibraries);
    this.libraries = Collections.emptyList();
    this.projects = Collections.emptyList();
}
 
Example #20
Source File: AtlasAndroidLibraryImpl.java    From atlas with Apache License 2.0 4 votes vote down vote up
@NonNull
@Override
public Collection<? extends JavaLibrary> getJavaDependencies() {
    return javaLibraries;
}
 
Example #21
Source File: DependenciesImpl.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
@NonNull
@Override
public Collection<JavaLibrary> getJavaLibraries() {
    return javaLibraries;
}
 
Example #22
Source File: JavaLibraryImpl.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
@NonNull
@Override
public List<? extends JavaLibrary> getDependencies() {
    return Collections.emptyList();
}
 
Example #23
Source File: AndroidClassPathProvider.java    From NBANDROID-V2 with Apache License 2.0 4 votes vote down vote up
private void collectJavaLibraries(Collection<File> libs, JavaLibrary library) {
    libs.add(library.getJarFile());
    for (JavaLibrary childLib : library.getDependencies()) {
        collectJavaLibraries(libs, childLib);
    }
}
 
Example #24
Source File: AwbBundle.java    From atlas with Apache License 2.0 4 votes vote down vote up
public List<JavaLibrary> getJavaLibraries() {
    return javaLibraries;
}