use of org.gradle.api.artifacts.Dependency in project gradle by gradle.
the class DefaultConfigurationContainer method detachedConfiguration.
public ConfigurationInternal detachedConfiguration(Dependency... dependencies) {
String name = DETACHED_CONFIGURATION_DEFAULT_NAME + detachedConfigurationDefaultNameCounter++;
DetachedConfigurationsProvider detachedConfigurationsProvider = new DetachedConfigurationsProvider();
DefaultConfiguration detachedConfiguration = instantiator.newInstance(DefaultConfiguration.class, context, name, detachedConfigurationsProvider, resolver, listenerManager, dependencyMetaDataProvider, resolutionStrategyFactory, projectAccessListener, projectFinder, fileCollectionFactory, buildOperationExecutor, instantiator, artifactNotationParser, capabilityNotationParser, attributesFactory, rootComponentMetadataBuilder.withConfigurationsProvider(detachedConfigurationsProvider));
DomainObjectSet<Dependency> detachedDependencies = detachedConfiguration.getDependencies();
for (Dependency dependency : dependencies) {
detachedDependencies.add(dependency.copy());
}
detachedConfigurationsProvider.setTheOnlyConfiguration(detachedConfiguration);
return detachedConfiguration;
}
use of org.gradle.api.artifacts.Dependency in project shipkit by mockito.
the class CreateDependencyInfoFile method createDependencyInfoFile.
public void createDependencyInfoFile(CreateDependencyInfoFileTask task) {
String result = "# Description" + NEWLINE + DESCRIPTION + NEWLINE + "# Dependencies";
// sorting dependencies to assure that they are always in the same order
// without depending on Gradle implementation
SortedSet<String> dependencies = new TreeSet<>();
for (Dependency dependency : task.getConfiguration().getAllDependencies()) {
if (dependency instanceof ModuleDependency) {
String dep = getDependencyWithArtifacts(task, (ModuleDependency) dependency);
dependencies.add(dep);
}
}
result += DEPENDENCY_INDENT + StringUtil.join(dependencies, DEPENDENCY_INDENT);
IOUtil.writeFile(task.getOutputFile(), result.toString());
}
use of org.gradle.api.artifacts.Dependency in project atlas by alibaba.
the class UpdatePomTask method getExtraMap.
private Map<String, DependencyExtraInfo> getExtraMap() {
Map<String, DependencyExtraInfo> dependencyExtraInfoMap = new HashMap<>();
DependencySet dependencies = project.getConfigurations().getByName("compile").getDependencies();
dependencies.forEach(new Consumer<Dependency>() {
@Override
public void accept(Dependency dependency) {
String group = dependency.getGroup();
String name = dependency.getName();
String scope = "compile";
String type = "";
if (dependency instanceof DefaultProjectDependency) {
DefaultProjectDependency projectDependency = (DefaultProjectDependency) dependency;
if (projectDependency.getDependencyProject().getPlugins().hasPlugin(LibraryPlugin.class)) {
type = "aar";
}
}
dependencyExtraInfoMap.put(group + ":" + name, new DependencyExtraInfo(type, scope));
}
});
return dependencyExtraInfoMap;
}
use of org.gradle.api.artifacts.Dependency in project atlas by alibaba.
the class PrepareAPTask method generate.
/**
* Directory of so
*/
@TaskAction
void generate() throws IOException, DocumentException {
Project project = getProject();
File apBaseFile = null;
File apFile = getApFile();
if (null != apFile && apFile.exists()) {
apBaseFile = apFile;
} else {
String apDependency = getApDependency();
if (StringUtils.isNotBlank(apContext.getApDependency())) {
Dependency dependency = project.getDependencies().create(apDependency);
Configuration configuration = project.getConfigurations().detachedConfiguration(dependency);
configuration.setTransitive(false);
configuration.getResolutionStrategy().cacheChangingModulesFor(0, TimeUnit.MILLISECONDS);
configuration.getResolutionStrategy().cacheDynamicVersionsFor(0, TimeUnit.MILLISECONDS);
for (File file : configuration.getFiles()) {
if (file.getName().endsWith(".ap")) {
apBaseFile = file;
break;
}
}
}
}
if (null != apBaseFile && apBaseFile.exists()) {
try {
explodedDir = getExplodedDir();
BetterZip.unzipDirectory(apBaseFile, explodedDir);
apContext.setApExploredFolder(explodedDir);
Set<String> awbBundles = getAwbBundles();
if (awbBundles != null) {
// Unzip the baseline Bundle
for (String awbBundle : awbBundles) {
File awbFile = BetterZip.extractFile(new File(explodedDir, AP_INLINE_APK_FILENAME), "lib/armeabi/" + awbBundle, new File(explodedDir, AP_INLINE_AWB_EXTRACT_DIRECTORY));
File awbExplodedDir = new File(new File(explodedDir, AP_INLINE_AWB_EXPLODED_DIRECTORY), FilenameUtils.getBaseName(awbBundle));
BetterZip.unzipDirectory(awbFile, awbExplodedDir);
FileUtils.renameTo(new File(awbExplodedDir, FN_APK_CLASSES_DEX), new File(awbExplodedDir, "classes2.dex"));
}
// Preprocessing increment androidmanifest.xml
ManifestFileUtils.updatePreProcessBaseManifestFile(FileUtils.join(explodedDir, "manifest-modify", ANDROID_MANIFEST_XML), new File(explodedDir, ANDROID_MANIFEST_XML));
}
if (explodedDir.listFiles().length == 0) {
throw new RuntimeException("unzip ap exception, no files found");
}
} catch (Throwable e) {
FileUtils.deleteIfExists(apBaseFile);
throw new GradleException(e.getMessage(), e);
}
}
}
use of org.gradle.api.artifacts.Dependency in project spring-boot by spring-projects.
the class JavaConventions method configureDependencyManagement.
private void configureDependencyManagement(Project project) {
ConfigurationContainer configurations = project.getConfigurations();
Configuration dependencyManagement = configurations.create("dependencyManagement", (configuration) -> {
configuration.setVisible(false);
configuration.setCanBeConsumed(false);
configuration.setCanBeResolved(false);
});
configurations.matching((configuration) -> configuration.getName().endsWith("Classpath") || JavaPlugin.ANNOTATION_PROCESSOR_CONFIGURATION_NAME.equals(configuration.getName())).all((configuration) -> configuration.extendsFrom(dependencyManagement));
Dependency springBootParent = project.getDependencies().enforcedPlatform(project.getDependencies().project(Collections.singletonMap("path", ":spring-boot-project:spring-boot-parent")));
dependencyManagement.getDependencies().add(springBootParent);
project.getPlugins().withType(OptionalDependenciesPlugin.class, (optionalDependencies) -> configurations.getByName(OptionalDependenciesPlugin.OPTIONAL_CONFIGURATION_NAME).extendsFrom(dependencyManagement));
}
Aggregations