Java Code Examples for org.gradle.api.artifacts.ModuleVersionIdentifier#getGroup()

The following examples show how to use org.gradle.api.artifacts.ModuleVersionIdentifier#getGroup() . 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: Utils.java    From Injector with Apache License 2.0 5 votes vote down vote up
public static Dependency createDependencyFrom(ResolvedArtifact resolvedArtifact) {
	ModuleVersionIdentifier identifier = resolvedArtifact.getModuleVersion().getId();
	return identifier.getGroup().isEmpty() ? new DefaultSelfResolvingDependency(
			resolvedArtifact.getId().getComponentIdentifier(),
			new DefaultFileCollectionFactory(new IdentityFileResolver(), null).fixed(resolvedArtifact.getFile())
	) : new DefaultExternalModuleDependency(
			identifier.getGroup(),
			identifier.getName(),
			identifier.getVersion());
}
 
Example 2
Source File: CycloneDxTask.java    From cyclonedx-gradle-plugin with Apache License 2.0 4 votes vote down vote up
private String getDependencyName(ResolvedArtifact artifact) {
    final ModuleVersionIdentifier m = artifact.getModuleVersion().getId();
    return m.getGroup() + ":" + m.getName() + ":" + m.getVersion();
}
 
Example 3
Source File: DependencyResultSpec.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private boolean matchesSelected(ResolvedDependencyResult candidate) {
    ModuleVersionIdentifier selected = candidate.getSelected().getModuleVersion();
    String selectedCandidate = selected.getGroup() + ":" + selected.getModule() + ":" + selected.getVersion();
    return selectedCandidate.contains(stringNotation);
}
 
Example 4
Source File: DefaultGradleModuleVersion.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DefaultGradleModuleVersion(ModuleVersionIdentifier identifier) {
    this.group = identifier.getGroup();
    this.name = identifier.getName();
    this.version = identifier.getVersion();
}
 
Example 5
Source File: DefaultModuleComponentIdentifier.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public static ModuleComponentIdentifier newId(ModuleVersionIdentifier moduleVersionIdentifier) {
    return new DefaultModuleComponentIdentifier(moduleVersionIdentifier.getGroup(), moduleVersionIdentifier.getName(), moduleVersionIdentifier.getVersion());
}
 
Example 6
Source File: DependencyResultSpec.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private boolean matchesSelected(ResolvedDependencyResult candidate) {
    ModuleVersionIdentifier selected = candidate.getSelected().getModuleVersion();
    String selectedCandidate = selected.getGroup() + ":" + selected.getModule() + ":" + selected.getVersion();
    return selectedCandidate.contains(stringNotation);
}
 
Example 7
Source File: DefaultGradleModuleVersion.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DefaultGradleModuleVersion(ModuleVersionIdentifier identifier) {
    this.group = identifier.getGroup();
    this.name = identifier.getName();
    this.version = identifier.getVersion();
}
 
Example 8
Source File: DefaultModuleComponentIdentifier.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public static ModuleComponentIdentifier newId(ModuleVersionIdentifier moduleVersionIdentifier) {
    return new DefaultModuleComponentIdentifier(moduleVersionIdentifier.getGroup(), moduleVersionIdentifier.getName(), moduleVersionIdentifier.getVersion());
}
 
Example 9
Source File: DefaultDependencyMetaData.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DefaultDependencyMetaData(ModuleVersionIdentifier moduleVersionIdentifier) {
    dependencyDescriptor = new DefaultDependencyDescriptor(IvyUtil.createModuleRevisionId(moduleVersionIdentifier), false);
    requested = new DefaultModuleVersionSelector(moduleVersionIdentifier.getGroup(), moduleVersionIdentifier.getName(), moduleVersionIdentifier.getVersion());
}
 
Example 10
Source File: DependencyChecker.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
public boolean excluded(ModuleVersionIdentifier id) {
    String group = id.getGroup();
    String name = id.getName();
    String version = id.getVersion();

    if ("com.google.android".equals(group) && "android".equals(name)) {
        int moduleLevel = getApiLevelFromMavenArtifact(version);
        legacyApiLevels.put(id, moduleLevel);

        logger.info("Ignoring Android API artifact %s for %s", id,
                configurationDependencies.getName());
        return true;
    }

    if (!skipLibrariesInThePlatform) {
        return false;
    }

    if (("org.apache.httpcomponents".equals(group) && "httpclient".equals(name)) ||
            ("xpp3".equals(group) && name.equals("xpp3")) ||
            ("commons-logging".equals(group) && "commons-logging".equals(name)) ||
            ("xerces".equals(group) && "xmlParserAPIs".equals(name))) {

        logger.warning(
                "WARNING: Dependency %s is ignored for %s as it may be conflicting with the internal version provided by Android.\n" +
                        "         In case of problem, please repackage it with jarjar to change the class packages",
                id, configurationDependencies.getName());
        return true;
    }

    if ("org.json".equals(group) && "json".equals(name)) {
        logger.warning(
                "WARNING: Dependency %s is ignored for %s as it may be conflicting with the internal version provided by Android.\n" +
                        "         In case of problem, please repackage with jarjar to change the class packages",
                id, configurationDependencies.getName());
        return true;
    }

    if ("org.khronos".equals(group) && "opengl-api".equals(name)) {
        logger.warning(
                "WARNING: Dependency %s is ignored for %s as it may be conflicting with the internal version provided by Android.\n" +
                        "         In case of problem, please repackage with jarjar to change the class packages",
                id, configurationDependencies.getName());
        return true;
    }

    return false;
}
 
Example 11
Source File: DefaultDependencyMetaData.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DefaultDependencyMetaData(ModuleVersionIdentifier moduleVersionIdentifier) {
    dependencyDescriptor = new DefaultDependencyDescriptor(IvyUtil.createModuleRevisionId(moduleVersionIdentifier), false);
    requested = new DefaultModuleVersionSelector(moduleVersionIdentifier.getGroup(), moduleVersionIdentifier.getName(), moduleVersionIdentifier.getVersion());
}
 
Example 12
Source File: LinkageCheckTask.java    From cloud-opensource-java with Apache License 2.0 4 votes vote down vote up
/** Returns true iff {@code configuration}'s artifacts contain linkage errors. */
private boolean findLinkageErrors(Configuration configuration) throws IOException {
  ImmutableList.Builder<ClassPathEntry> classPathBuilder = ImmutableList.builder();

  // TODO(suztomo): Should this include optional dependencies?
  //  Once we decide what to do with the optional dependencies, let's revisit this logic.
  for (ResolvedArtifact resolvedArtifact :
      configuration.getResolvedConfiguration().getResolvedArtifacts()) {
    ModuleVersionIdentifier moduleVersionId = resolvedArtifact.getModuleVersion().getId();
    DefaultArtifact artifact =
        new DefaultArtifact(
            moduleVersionId.getGroup(),
            moduleVersionId.getName(),
            null,
            null,
            moduleVersionId.getVersion(),
            null,
            resolvedArtifact.getFile());
    classPathBuilder.add(new ClassPathEntry(artifact));
  }

  ImmutableList<ClassPathEntry> classPath = classPathBuilder.build();

  if (!classPath.isEmpty()) {
    String exclusionFileName = extension.getExclusionFile();
    Path exclusionFile = exclusionFileName == null ? null : Paths.get(exclusionFileName);
    if (exclusionFile != null && !exclusionFile.isAbsolute()) {
      // Relative path from the project root
      Path projectRoot = getProject().getRootDir().toPath();
      exclusionFile = projectRoot.resolve(exclusionFile).toAbsolutePath();
    }

    // TODO(suztomo): Specify correct entry points if reportOnlyReachable is true.
    LinkageChecker linkageChecker = LinkageChecker.create(classPath, classPath, exclusionFile);

    ImmutableSetMultimap<SymbolProblem, ClassFile> symbolProblems =
        linkageChecker.findSymbolProblems();

    int errorCount = symbolProblems.keySet().size();

    // TODO(suztomo): Show the dependency paths to the problematic artifacts.
    if (errorCount > 0) {
      getLogger().error(
          "Linkage Checker rule found {} error{}. Linkage error report:\n{}",
          errorCount,
          errorCount > 1 ? "s" : "",
          SymbolProblem.formatSymbolProblems(symbolProblems));

      ResolutionResult result = configuration.getIncoming().getResolutionResult();
      ResolvedComponentResult root = result.getRoot();
      String dependencyPaths = dependencyPathsOfProblematicJars(root, symbolProblems);
      getLogger().error(dependencyPaths);
      getLogger()
          .info(
              "For the details of the linkage errors, see "
                  + "https://github.com/GoogleCloudPlatform/cloud-opensource-java/wiki/Linkage-Checker-Messages");
    }
    return errorCount > 0;
  }
  // When the configuration does not have any artifacts, there's no linkage error.
  return false;
}
 
Example 13
Source File: DefaultModuleComponentIdentifier.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public static ModuleComponentIdentifier newId(ModuleVersionIdentifier moduleVersionIdentifier) {
    return new DefaultModuleComponentIdentifier(moduleVersionIdentifier.getGroup(), moduleVersionIdentifier.getName(), moduleVersionIdentifier.getVersion());
}
 
Example 14
Source File: DependencyResultSpec.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private boolean matchesSelected(ResolvedDependencyResult candidate) {
    ModuleVersionIdentifier selected = candidate.getSelected().getModuleVersion();
    String selectedCandidate = selected.getGroup() + ":" + selected.getModule() + ":" + selected.getVersion();
    return selectedCandidate.contains(stringNotation);
}
 
Example 15
Source File: DefaultGradleModuleVersion.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DefaultGradleModuleVersion(ModuleVersionIdentifier identifier) {
    this.group = identifier.getGroup();
    this.name = identifier.getName();
    this.version = identifier.getVersion();
}
 
Example 16
Source File: IdeDependenciesExtractor.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private ModuleComponentIdentifier toComponentIdentifier(ModuleVersionIdentifier id) {
    return new DefaultModuleComponentIdentifier(id.getGroup(), id.getName(), id.getVersion());
}
 
Example 17
Source File: DependencyResultSpec.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private boolean matchesSelected(ResolvedDependencyResult candidate) {
    ModuleVersionIdentifier selected = candidate.getSelected().getModuleVersion();
    String selectedCandidate = selected.getGroup() + ":" + selected.getModule() + ":" + selected.getVersion();
    return selectedCandidate.contains(stringNotation);
}
 
Example 18
Source File: DefaultGradleModuleVersion.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DefaultGradleModuleVersion(ModuleVersionIdentifier identifier) {
    this.group = identifier.getGroup();
    this.name = identifier.getName();
    this.version = identifier.getVersion();
}
 
Example 19
Source File: DefaultModuleComponentIdentifier.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public static ModuleComponentIdentifier newId(ModuleVersionIdentifier moduleVersionIdentifier) {
    return new DefaultModuleComponentIdentifier(moduleVersionIdentifier.getGroup(), moduleVersionIdentifier.getName(), moduleVersionIdentifier.getVersion());
}
 
Example 20
Source File: GradleDependencyResolutionHelper.java    From thorntail with Apache License 2.0 2 votes vote down vote up
/**
 * Translate the given {@link ResolvedArtifact resolved artifact} in to a {@link DependencyDescriptor} reference.
 *
 * @param scope    the scope to assign to the descriptor.
 * @param artifact the resolved artifact reference.
 * @return an instance of {@link DependencyDescriptor}.
 */
private static DependencyDescriptor asDescriptor(String scope, ResolvedArtifact artifact) {
    ModuleVersionIdentifier id = artifact.getModuleVersion().getId();
    return new DefaultDependencyDescriptor(scope, id.getGroup(), id.getName(), id.getVersion(),
                                           artifact.getType(), artifact.getClassifier(), artifact.getFile());
}