use of org.gradle.api.artifacts.Dependency in project gradle by gradle.
the class ModuleFactoryDelegate method dependency.
@SuppressWarnings("rawtypes")
public void dependency(Object dependencyNotation, Closure configureClosure) {
Dependency dependency = dependencyFactory.createDependency(dependencyNotation);
clientModule.addDependency((ModuleDependency) dependency);
ConfigureUtil.configure(configureClosure, dependency);
}
use of org.gradle.api.artifacts.Dependency in project gradle by gradle.
the class UnresolvableConfigurationResult method getChildren.
@Override
public Set<? extends RenderableDependency> getChildren() {
final DependencySet dependencies = configuration.getDependencies();
if (dependencies.isEmpty()) {
return Collections.emptySet();
}
Set<RenderableDependency> children = Sets.newLinkedHashSet();
for (final Dependency dependency : dependencies) {
children.add(new AbstractRenderableDependency() {
@Override
public Object getId() {
return dependency;
}
@Override
public String getName() {
String label;
if (dependency instanceof ProjectDependency) {
label = "project " + dependency.getName();
} else {
label = Joiner.on(":").join(Stream.of(dependency.getGroup(), dependency.getName(), dependency.getVersion()).filter(Objects::nonNull).collect(Collectors.toList()));
}
return label;
}
});
}
return children;
}
use of org.gradle.api.artifacts.Dependency in project gradle by gradle.
the class DefaultJvmComponentDependencies method doAddEager.
private void doAddEager(Configuration bucket, Object dependency, @Nullable Action<? super Dependency> configuration) {
Dependency created = create(dependency, configuration);
bucket.getDependencies().add(created);
}
use of org.gradle.api.artifacts.Dependency in project gradle by gradle.
the class DependenciesAwareVersionCatalogBuilder method collectDependencies.
private void collectDependencies(DependencySet allDependencies, Set<ModuleIdentifier> seen) {
for (Dependency dependency : allDependencies) {
String group = dependency.getGroup();
String name = dependency.getName();
if (group != null) {
ModuleIdentifier id = DefaultModuleIdentifier.newId(group, name);
if (seen.add(id)) {
String alias = explicitAliases.get(id);
if (alias != null) {
library(alias, group, name).version(v -> copyDependencyVersion(dependency, group, name, v));
} else {
tryGenericAlias(group, name, v -> copyDependencyVersion(dependency, group, name, v));
}
} else {
LOGGER.warn("Duplicate entry for dependency " + group + ":" + name);
}
}
}
}
use of org.gradle.api.artifacts.Dependency in project gradle by gradle.
the class XCTestConventionPlugin method configureTestSuiteBuildingTasks.
private void configureTestSuiteBuildingTasks(final Project project, final DefaultSwiftXCTestBinary binary) {
// Overwrite the source to exclude `LinuxMain.swift`
SwiftCompile compile = binary.getCompileTask().get();
compile.getSource().setFrom(binary.getSwiftSource().getAsFileTree().matching(patterns -> patterns.include("**/*").exclude("**/LinuxMain.swift")));
if (binary instanceof SwiftXCTestBundle) {
TaskContainer tasks = project.getTasks();
final Names names = binary.getNames();
// TODO - creating a bundle should be done by some general purpose plugin
// TODO - make this lazy
final DefaultNativePlatform currentPlatform = new DefaultNativePlatform("current");
final ModelRegistry modelRegistry = ((ProjectInternal) project).getModelRegistry();
final NativeToolChain toolChain = modelRegistry.realize("toolChains", NativeToolChainRegistryInternal.class).getForPlatform(currentPlatform);
// Platform specific arguments
// TODO: Need to lazily configure compile task
// TODO: Ultimately, this should be some kind of 3rd party dependency that's visible to dependency management.
compile.getCompilerArgs().addAll(project.provider(() -> {
File platformSdkPath = sdkPlatformPathLocator.find();
File frameworkDir = new File(platformSdkPath, "Developer/Library/Frameworks");
// Since Xcode 11/12, the XCTest framework is being replaced by a different library that's available in the sdk root
File extraInclude = new File(platformSdkPath, "Developer/usr/lib");
return Arrays.asList("-parse-as-library", "-F" + frameworkDir.getAbsolutePath(), "-I", extraInclude.getAbsolutePath(), "-v");
}));
// Add a link task
final TaskProvider<LinkMachOBundle> link = tasks.register(names.getTaskName("link"), LinkMachOBundle.class, task -> {
task.getLinkerArgs().set(project.provider(() -> {
File platformSdkPath = sdkPlatformPathLocator.find();
File frameworkDir = new File(platformSdkPath, "Developer/Library/Frameworks");
// Since Xcode 11/12, the XCTest framework is being replaced by a different library that's available in the sdk root
File extraInclude = new File(platformSdkPath, "Developer/usr/lib");
return Lists.newArrayList("-F" + frameworkDir.getAbsolutePath(), "-L", extraInclude.getAbsolutePath(), "-framework", "XCTest", "-Xlinker", "-rpath", "-Xlinker", "@executable_path/../Frameworks", "-Xlinker", "-rpath", "-Xlinker", "@loader_path/../Frameworks");
}));
task.source(binary.getObjects());
task.lib(binary.getLinkLibraries());
final PlatformToolProvider toolProvider = ((NativeToolChainInternal) toolChain).select(currentPlatform);
Provider<RegularFile> exeLocation = project.getLayout().getBuildDirectory().file(binary.getBaseName().map(baseName -> toolProvider.getExecutableName("exe/" + names.getDirName() + baseName)));
task.getLinkedFile().set(exeLocation);
task.getTargetPlatform().set(currentPlatform);
task.getToolChain().set(toolChain);
task.getDebuggable().set(binary.isDebuggable());
});
final TaskProvider<InstallXCTestBundle> install = tasks.register(names.getTaskName("install"), InstallXCTestBundle.class, task -> {
task.getBundleBinaryFile().set(link.get().getLinkedFile());
task.getInstallDirectory().set(project.getLayout().getBuildDirectory().dir("install/" + names.getDirName()));
});
binary.getInstallDirectory().set(install.flatMap(task -> task.getInstallDirectory()));
binary.getExecutableFile().set(link.flatMap(task -> task.getLinkedFile()));
DefaultSwiftXCTestBundle bundle = (DefaultSwiftXCTestBundle) binary;
bundle.getLinkTask().set(link);
bundle.getRunScriptFile().set(install.flatMap(task -> task.getRunScriptFile()));
} else {
DefaultSwiftXCTestExecutable executable = (DefaultSwiftXCTestExecutable) binary;
executable.getRunScriptFile().set(executable.getInstallTask().flatMap(task -> task.getRunScriptFile()));
// Rename `LinuxMain.swift` to `main.swift` so the entry point is correctly detected by swiftc
if (binary.getTargetMachine().getOperatingSystemFamily().isLinux()) {
TaskProvider<Sync> renameLinuxMainTask = project.getTasks().register("renameLinuxMain", Sync.class, task -> {
task.from(binary.getSwiftSource());
task.into(project.provider(() -> task.getTemporaryDir()));
task.include("LinuxMain.swift");
task.rename(it -> "main.swift");
});
compile.getSource().from(project.files(renameLinuxMainTask).getAsFileTree().matching(patterns -> patterns.include("**/*.swift")));
}
}
}
Aggregations