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

The following examples show how to use org.gradle.api.artifacts.ModuleVersionIdentifier#getName() . 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: MavenResolver.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private TimestampedModuleSource findUniqueSnapshotVersion(ModuleRevisionId moduleRevisionId) {
    ModuleVersionIdentifier moduleVersionIdentifier = DefaultModuleVersionIdentifier.newId(moduleRevisionId);
    ModuleVersionArtifactIdentifier artifactId = new DefaultModuleVersionArtifactIdentifier(moduleVersionIdentifier, moduleVersionIdentifier.getName(), "pom", "pom");
    DefaultModuleVersionArtifactMetaData pomArtifact = new DefaultModuleVersionArtifactMetaData(artifactId);
    String metadataLocation = toResourcePattern(getWholePattern()).toModuleVersionPath(pomArtifact) + "/maven-metadata.xml";
    MavenMetadata mavenMetadata = parseMavenMetadata(metadataLocation);

    if (mavenMetadata.timestamp != null) {
        // we have found a timestamp, so this is a snapshot unique version
        String rev = moduleRevisionId.getRevision();
        rev = rev.substring(0, rev.length() - "SNAPSHOT".length());
        rev = rev + mavenMetadata.timestamp + "-" + mavenMetadata.buildNumber;
        return new TimestampedModuleSource(rev);
    }
    return null;
}
 
Example 2
Source File: DefaultConfigurationsToArtifactsConverter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public IvyArtifactName createIvyArtifact(PublishArtifact publishArtifact, ModuleVersionIdentifier moduleVersionIdentifier) {
    Map<String, String> extraAttributes = new HashMap<String, String>();
    if (GUtil.isTrue(publishArtifact.getClassifier())) {
        extraAttributes.put(Dependency.CLASSIFIER, publishArtifact.getClassifier());
    }
    String name = publishArtifact.getName();
    if (!GUtil.isTrue(name)) {
        name = moduleVersionIdentifier.getName();
    }
    return new DefaultIvyArtifactName(name, publishArtifact.getType(), publishArtifact.getExtension(), extraAttributes);
}
 
Example 3
Source File: MavenResolver.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
protected ModuleVersionArtifactMetaData getMetaDataArtifactFor(ModuleVersionIdentifier moduleVersionIdentifier) {
    if (isUsepoms()) {
        DefaultModuleVersionArtifactIdentifier artifactId = new DefaultModuleVersionArtifactIdentifier(moduleVersionIdentifier, moduleVersionIdentifier.getName(), "pom", "pom");
        return new DefaultModuleVersionArtifactMetaData(artifactId);
    }

    return null;
}
 
Example 4
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 5
Source File: DefaultConfigurationsToArtifactsConverter.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public IvyArtifactName createIvyArtifact(PublishArtifact publishArtifact, ModuleVersionIdentifier moduleVersionIdentifier) {
    Map<String, String> extraAttributes = new HashMap<String, String>();
    if (GUtil.isTrue(publishArtifact.getClassifier())) {
        extraAttributes.put(Dependency.CLASSIFIER, publishArtifact.getClassifier());
    }
    String name = publishArtifact.getName();
    if (!GUtil.isTrue(name)) {
        name = moduleVersionIdentifier.getName();
    }
    return new DefaultIvyArtifactName(name, publishArtifact.getType(), publishArtifact.getExtension(), extraAttributes);
}
 
Example 6
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 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: IdeDependenciesExtractor.java    From Pushjet-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 9
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 10
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 11
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 12
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 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: 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 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: 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 18
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 19
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 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());
}