private Set<String> getCompileArtifactsForAgp2x() { Set<String> compileLibs = new HashSet<>(); Configuration configuration = project.getConfigurations().getByName("compile"); if (configuration.isCanBeResolved()) { ResolvableDependencies incoming = configuration.getIncoming(); ResolutionResult resolutionResult = incoming.getResolutionResult(); Set<ResolvedComponentResult> components = resolutionResult.getAllComponents(); for (ResolvedComponentResult result : components) { ModuleVersionIdentifier identifier = result.getModuleVersion(); if (identifier != null && !"unspecified".equals(identifier.getVersion())) { compileLibs.add( String.join(":", identifier.getGroup(), identifier.getName(), identifier.getVersion())); } } } return compileLibs; }
@Override public void execute( ComponentMetadataContext ctx ) { ComponentMetadataDetails details = ctx.getDetails(); ModuleVersionIdentifier module = details.getId(); details.allVariants( vm -> { String group = "org.jetbrains.kotlin"; log.trace( "checking for {}: {}", group, module ); if ( Objects.equals( module.getGroup(), group ) ) { details.belongsTo( group + ":kotlin-bom:" + module.getVersion() ); log.info( "alligning {}: {}", group, module ); } } ); } }
@Nullable private String getJacocoVersion() { Project candidateProject = project; boolean shouldFailWithException = false; while (candidateProject != null) { Set<ResolvedArtifact> resolvedArtifacts = candidateProject.getBuildscript().getConfigurations().getByName("classpath") .getResolvedConfiguration().getResolvedArtifacts(); for (ResolvedArtifact artifact : resolvedArtifacts) { ModuleVersionIdentifier moduleVersion = artifact.getModuleVersion().getId(); if ("org.jacoco.core".equals(moduleVersion.getName())) { return moduleVersion.getVersion(); } } if (!resolvedArtifacts.isEmpty()) { // not in the DSL test case, where nothing will have been resolved. shouldFailWithException = true; } candidateProject = candidateProject.getParent(); } if (shouldFailWithException) { throw new IllegalStateException( "Could not find project build script dependency on org.jacoco.core"); } project.getLogger().error( "No resolved dependencies found when searching for the jacoco version."); return DEFAULT_JACOCO_VERSION; }
public String getGroup() { return mArtifact.getModuleVersion().getId().getGroup(); }
public String getVersion() { return mArtifact.getModuleVersion().getId().getVersion(); }
public String getName() { return mArtifact.getModuleVersion().getId().getName(); }
@Override public void execute( ComponentMetadataContext ctx ) { ComponentMetadataDetails details = ctx.getDetails(); ModuleVersionIdentifier module = details.getId(); details.allVariants( vm -> { String group = "org.jetbrains.kotlin"; log.trace( "checking for {}: {}", group, module ); if ( Objects.equals( module.getGroup(), group ) ) { details.belongsTo( group + ":kotlin-bom:" + module.getVersion() ); log.info( "alligning {}: {}", group, module ); } } ); } }
ResolvedArtifactLibrary(ResolvedArtifact artifact, LibraryScope scope) { super(artifact.getModuleVersion().getId().getGroup(), artifact.getFile(), scope); this.artifact = artifact; }
private void collectArchives(final List<JApiCmpWorkerAction.Archive> archives, ResolvedDependency resolvedDependency) { String version = resolvedDependency.getModule().getId().getVersion(); archives.add(new JApiCmpWorkerAction.Archive(resolvedDependency.getAllModuleArtifacts().iterator().next().getFile(), version)); for (ResolvedDependency dependency : resolvedDependency.getChildren()) { collectArchives(archives, dependency); } }
private String key(ResolvedArtifact dependency, Properties props) { String key = dependency.getModuleVersion().getId().getName(); if (!StringUtils.isEmpty(dependency.getClassifier())) { key = key + "." + dependency.getClassifier(); } int counter = 1; while (props.get("dependencies." + key) != null) { key = key + "." + counter++; } return key; }
public DefaultGradleModuleVersion(ModuleVersionIdentifier identifier) { this.group = identifier.getGroup(); this.name = identifier.getName(); this.version = identifier.getVersion(); }
@Override public void execute( ComponentMetadataContext ctx ) { ComponentMetadataDetails details = ctx.getDetails(); ModuleVersionIdentifier module = details.getId(); details.allVariants( vm -> { String group = "org.immutables"; log.trace( "checking for immutables: {}", module ); if ( Objects.equals( module.getGroup(), group ) ) { details.belongsTo( group + ":platform:" + module.getVersion(), true ); log.info( "alligning immutables: {}", module ); } } ); } }
/** * Creates a {@code DependencyIdentifier} from a given {@link ModuleVersionIdentifier}. * * @param moduleVersionIdentifier The {@code ModuleVersionIdentifier} to create this object from. */ public DependencyIdentifier(ModuleVersionIdentifier moduleVersionIdentifier) { group = moduleVersionIdentifier.getGroup(); name = moduleVersionIdentifier.getName(); version = moduleVersionIdentifier.getVersion(); }
@Override public boolean isUnpackRequired() { if (ProjectLibraries.this.extension.getRequiresUnpack() != null) { ModuleVersionIdentifier id = this.artifact.getModuleVersion().getId(); return ProjectLibraries.this.extension.getRequiresUnpack() .contains(id.getGroup() + ":" + id.getName()); } return false; }
@Override public void execute( ComponentMetadataContext ctx ) { ComponentMetadataDetails details = ctx.getDetails(); ModuleVersionIdentifier module = details.getId(); details.allVariants( vm -> { String group = "org.immutables"; log.trace( "checking for immutables: {}", module ); if ( Objects.equals( module.getGroup(), group ) ) { details.belongsTo( group + ":platform:" + module.getVersion(), true ); log.info( "alligning immutables: {}", module ); } } ); } }
static String identifierToCoord(ModuleVersionIdentifier identifier) { return String.format("%s:%s:%s", identifier.getGroup(), identifier.getName(), identifier.getVersion()); }
@Override public void execute(DependencyResult dependencyResult) { if (dependencyResult instanceof ResolvedDependencyResult) { ResolvedDependencyResult resolved = (ResolvedDependencyResult) dependencyResult; excludedDependencies.add(new DependencyCandidate(resolved.getSelected() .getModuleVersion().getGroup(), resolved.getSelected() .getModuleVersion().getName())); } else if (dependencyResult instanceof UnresolvedDependencyResult) { DependencyCandidate dependencyCandidate = toDependencyCandidate((UnresolvedDependencyResult) dependencyResult); if (dependencyCandidate != null) { excludedDependencies.add(dependencyCandidate); } } } });