use of org.gradle.api.artifacts.Configuration in project gradle by gradle.
the class FindBugsPlugin method configureFindBugsConfigurations.
private void configureFindBugsConfigurations() {
Configuration configuration = project.getConfigurations().create("findbugsPlugins");
configuration.setVisible(false);
configuration.setTransitive(true);
configuration.setDescription("The FindBugs plugins to be used for this project.");
}
use of org.gradle.api.artifacts.Configuration in project gradle by gradle.
the class IdeaDependenciesProvider method getFileDependencies.
private Set<Dependency> getFileDependencies(IdeaModule ideaModule, GeneratedIdeaScope scope) {
Collection<Configuration> plusConfigurations = getPlusConfigurations(ideaModule, scope);
Collection<Configuration> minusConfigurations = getMinusConfigurations(ideaModule, scope);
Set<Dependency> dependencies = Sets.newLinkedHashSet();
Collection<IdeLocalFileDependency> ideLocalFileDependencies = dependenciesExtractor.extractLocalFileDependencies(plusConfigurations, minusConfigurations);
for (IdeLocalFileDependency fileDependency : ideLocalFileDependencies) {
dependencies.add(toLibraryDependency(fileDependency, ideaModule, scope));
}
return dependencies;
}
use of org.gradle.api.artifacts.Configuration in project atlas by alibaba.
the class PrepareAPTask method generate.
/**
* 生成so的目录
*/
@TaskAction
void generate() {
Project project = getProject();
File apBaseFile = null;
if (null != apContext.getApFile() && apContext.getApFile().exists()) {
apBaseFile = apContext.getApFile();
} else if (StringUtils.isNotBlank(apContext.getApDependency())) {
Dependency dependency = project.getDependencies().create(apContext.getApDependency());
Configuration configuration = project.getConfigurations().detachedConfiguration(dependency);
configuration.setTransitive(false);
for (File file : configuration.getFiles()) {
if (file.getName().endsWith(".ap")) {
apBaseFile = file;
break;
}
}
}
if (null != apBaseFile && apBaseFile.exists()) {
File explodedDir = project.file(project.getBuildDir().getAbsolutePath() + "/" + FD_INTERMEDIATES + "/exploded-ap" + "/");
ZipUtils.unzip(apBaseFile, explodedDir.getAbsolutePath());
apContext.setApExploredFolder(explodedDir);
apContext.setBaseApk(new File(explodedDir, "android.apk"));
}
}
use of org.gradle.api.artifacts.Configuration in project atlas by alibaba.
the class TDependencyManager method collectArtifacts.
/**
* Collects the resolved artifacts and returns a configuration which contains them. If the
* configuration has unresolved dependencies we check that we have the latest version of the
* Google repository and the Android Support repository and we install them if not. After this,
* the resolution is retried with a fresh copy of the configuration, that will contain the newly
* updated repositories. If this passes, we return the correct configuration and we fill the
* artifacts map.
*
* @param configuration the configuration from which we get the artifacts
* @param artifacts the map of artifacts that are being collected
* @return a valid configuration that has only resolved dependencies.
*/
private Configuration collectArtifacts(Configuration configuration, Map<ModuleVersionIdentifier, List<ResolvedArtifact>> artifacts) {
Set<ResolvedArtifact> allArtifacts;
// Make a copy because Gradle keeps a per configuration state of resolution that we
// need to reset.
Configuration configurationCopy = configuration.copyRecursive();
Set<UnresolvedDependency> unresolvedDependencies = configuration.getResolvedConfiguration().getLenientConfiguration().getUnresolvedModuleDependencies();
if (unresolvedDependencies.isEmpty()) {
allArtifacts = configuration.getResolvedConfiguration().getResolvedArtifacts();
} else {
if (!repositoriesUpdated && sdkLibData.useSdkDownload()) {
List<String> repositoryPaths = new ArrayList<>();
for (UnresolvedDependency dependency : unresolvedDependencies) {
if (isGoogleOwnedDependency(dependency.getSelector())) {
repositoryPaths.add(getRepositoryPath(dependency.getSelector()));
}
}
sdkLibData.setNeedsCacheReset(sdkHandler.checkResetCache());
List<File> updatedRepositories = sdkHandler.getSdkLoader().updateRepositories(repositoryPaths, sdkLibData, logger);
// resolution result.
for (File updatedRepository : updatedRepositories) {
project.getRepositories().maven(newRepo -> {
newRepo.setName("Updated " + updatedRepository.getPath());
newRepo.setUrl(updatedRepository.toURI());
newRepo.artifactUrls(project.getRootProject().file("sdk-manager"));
});
}
repositoriesUpdated = true;
}
if (extraModelInfo.getMode() != STANDARD) {
allArtifacts = configurationCopy.getResolvedConfiguration().getLenientConfiguration().getArtifacts(Specs.satisfyAll());
} else {
allArtifacts = configurationCopy.getResolvedConfiguration().getResolvedArtifacts();
}
// Modify the configuration to the one that passed.
configuration = configurationCopy;
}
for (ResolvedArtifact artifact : allArtifacts) {
ModuleVersionIdentifier id = artifact.getModuleVersion().getId();
List<ResolvedArtifact> moduleArtifacts = artifacts.get(id);
if (moduleArtifacts == null) {
moduleArtifacts = Lists.newArrayList();
artifacts.put(id, moduleArtifacts);
}
if (!moduleArtifacts.contains(artifact)) {
moduleArtifacts.add(artifact);
}
}
return configuration;
}
use of org.gradle.api.artifacts.Configuration in project atlas by alibaba.
the class TDependencyManager method addDependsOnTaskInOtherProjects.
/**
* Adds a dependency on tasks with the specified name in other projects. The other projects
* are determined from project lib dependencies using the specified configuration name.
* These may be projects this project depends on or projects that depend on this project
* based on the useDependOn argument.
*
* @param task Task to add dependencies to
* @param useDependedOn if true, add tasks from projects this project depends on, otherwise
* use projects that depend on this one.
* @param otherProjectTaskName name of task in other projects
* @param configurationName name of configuration to use to find the other projects
*/
private static void addDependsOnTaskInOtherProjects(final Task task, boolean useDependedOn, String otherProjectTaskName, String configurationName) {
Project project = task.getProject();
final Configuration configuration = project.getConfigurations().getByName(configurationName);
task.dependsOn(configuration.getTaskDependencyFromProjectDependency(useDependedOn, otherProjectTaskName));
}
Aggregations