org.gradle.api.artifacts.Dependency Java Examples
The following examples show how to use
org.gradle.api.artifacts.Dependency.
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: SonarRunnerPlugin.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
private void addConfiguration(final Project project, final SonarRunnerRootExtension rootExtension) { final Configuration configuration = project.getConfigurations().create(SonarRunnerExtension.SONAR_RUNNER_CONFIGURATION_NAME); configuration .setVisible(false) .setTransitive(false) .setDescription("The SonarRunner configuration to use to run analysis") .getIncoming() .beforeResolve(new Action<ResolvableDependencies>() { public void execute(ResolvableDependencies resolvableDependencies) { DependencySet dependencies = resolvableDependencies.getDependencies(); if (dependencies.isEmpty()) { String toolVersion = rootExtension.getToolVersion(); DependencyHandler dependencyHandler = project.getDependencies(); Dependency dependency = dependencyHandler.create("org.codehaus.sonar.runner:sonar-runner-dist:" + toolVersion); configuration.getDependencies().add(dependency); } } }); }
Example #2
Source File: ApDependency.java From atlas with Apache License 2.0 | 6 votes |
private File getBaseApFile(Project project, TBuildType tBuildType) { File apBaseFile; File buildTypeBaseApFile = tBuildType.getBaseApFile(); if (null != buildTypeBaseApFile && buildTypeBaseApFile.exists()) { apBaseFile = buildTypeBaseApFile; } else if (!isNullOrEmpty(tBuildType.getBaseApDependency())) { String apDependency = tBuildType.getBaseApDependency(); // Preconditions.checkNotNull(apDependency, // "You have to specify the baseApFile property or the baseApDependency // dependency"); Dependency dependency = project.getDependencies().create(apDependency); Configuration configuration = project.getConfigurations().detachedConfiguration(dependency); configuration.setTransitive(false); apBaseFile = Iterables.getOnlyElement(Collections2.filter(configuration.getFiles(), new Predicate<File>() { @Override public boolean apply(@Nullable File file) { return file.getName().endsWith(".ap"); } })); } else { throw new IllegalStateException("AP is missing"); } return apBaseFile; }
Example #3
Source File: Publisher.java From firebase-android-sdk with Apache License 2.0 | 6 votes |
private static Map<String, String> getDependencyTypes(Project project) { Configuration dummyDependencyConfiguration = project.getConfigurations().create("publisherDummyConfig"); Set<Dependency> nonProjectDependencies = project .getConfigurations() .getByName("releaseRuntimeClasspath") .getAllDependencies() .stream() .filter(dep -> !(dep instanceof ProjectDependency)) .collect(Collectors.toSet()); dummyDependencyConfiguration.getDependencies().addAll(nonProjectDependencies); try { return project .getConfigurations() .getByName("releaseRuntimeClasspath") .getAllDependencies() .stream() .map(dep -> getType(dummyDependencyConfiguration, dep)) .filter(Objects::nonNull) .collect(Collectors.toMap(lib -> lib.name, lib -> lib.type.getFormat())); } finally { project.getConfigurations().remove(dummyDependencyConfiguration); } }
Example #4
Source File: CreateDependencyInfoFile.java From shipkit with MIT License | 6 votes |
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()); }
Example #5
Source File: DefaultConfigurationsToArtifactsConverter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
public Artifact createIvyArtifact(PublishArtifact publishArtifact, ModuleRevisionId moduleRevisionId) { 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 = moduleRevisionId.getName(); } return new DefaultArtifact( moduleRevisionId, publishArtifact.getDate(), name, publishArtifact.getType(), publishArtifact.getExtension(), extraAttributes); }
Example #6
Source File: DependencyManager.java From javaide with GNU General Public License v3.0 | 6 votes |
private void ensureConfigured(Configuration config) { for (Dependency dependency : config.getAllDependencies()) { if (dependency instanceof ProjectDependency) { ProjectDependency projectDependency = (ProjectDependency) dependency; project.evaluationDependsOn(projectDependency.getDependencyProject().getPath()); try { ensureConfigured(projectDependency.getProjectConfiguration()); } catch (Throwable e) { throw new UnknownProjectException(String.format( "Cannot evaluate module %s : %s", projectDependency.getName(), e.getMessage()), e); } } } }
Example #7
Source File: WarAttachClassesPlugin.java From gradle-plugins with MIT License | 6 votes |
@Override public void apply(Project project) { project.getPlugins().apply(WarPlugin.class); WarAttachClassesConvention attachClassesConvention = new WarAttachClassesConvention(); project.getTasks().named(WarPlugin.WAR_TASK_NAME, War.class, war -> war.getConvention().getPlugins().put("attachClasses", attachClassesConvention) ); project.afterEvaluate(p -> { if (attachClassesConvention.isAttachClasses()) { TaskProvider<Jar> jar = project.getTasks().named(JavaPlugin.JAR_TASK_NAME, Jar.class, j -> j.getArchiveClassifier().convention(attachClassesConvention.getClassesClassifier()) ); project.getArtifacts().add(Dependency.ARCHIVES_CONFIGURATION, jar); } }); }
Example #8
Source File: AppModelGradleResolver.java From quarkus with Apache License 2.0 | 6 votes |
private Dependency processQuarkusDir(AppArtifact a, Path quarkusDir, AppModel.Builder appBuilder) { if (!Files.exists(quarkusDir)) { return null; } final Path quarkusDescr = quarkusDir.resolve(BootstrapConstants.DESCRIPTOR_FILE_NAME); if (!Files.exists(quarkusDescr)) { return null; } final Properties extProps = resolveDescriptor(quarkusDescr); if (extProps == null) { return null; } appBuilder.handleExtensionProperties(extProps, a.toString()); String value = extProps.getProperty(BootstrapConstants.PROP_DEPLOYMENT_ARTIFACT); final String[] split = value.split(":"); return new DefaultExternalModuleDependency(split[0], split[1], split[2], null); }
Example #9
Source File: GolangDependency.java From gradle-golang-plugin with Mozilla Public License 2.0 | 6 votes |
public GolangDependency(@Nonnull Dependency raw) { if (raw instanceof GolangDependency) { final GolangDependency original = (GolangDependency) raw; setGroup(original.getGroup()); setVersion(original.getVersion()); setRepositoryUri(original.getRepositoryUri()); setRepositoryType(original.getRepositoryType()); setUpdatePolicy(original.getUpdatePolicy()); } else { final String name = raw.getName(); if (StringUtils.isEmpty(name)) { setGroup(raw.getGroup()); } else { setGroup(raw.getGroup() + "/" + name); } final String version = raw.getVersion(); if (StringUtils.isNotEmpty(version) && !"default".equalsIgnoreCase(version)) { setVersion(version); } } }
Example #10
Source File: Publisher.java From firebase-android-sdk with Apache License 2.0 | 6 votes |
private static Library getType(Configuration config, Dependency d) { if (d instanceof ProjectDependency) { FirebaseLibraryExtension library = getFirebaseLibrary(((ProjectDependency) d).getDependencyProject()); return new Library(library.getMavenName(), library.type); } Optional<Library> path = StreamSupport.stream(config.spliterator(), false) .map(File::getAbsolutePath) .filter( absPath -> absPath.matches( MessageFormat.format( ".*\\Q{0}/{1}/{2}/\\E[a-zA-Z0-9]+/\\Q{1}-{2}.\\E[aj]ar", d.getGroup(), d.getName(), d.getVersion()))) .findFirst() .map(absPath -> absPath.endsWith(".aar") ? LibraryType.ANDROID : LibraryType.JAVA) .map(type -> new Library(d.getGroup() + ":" + d.getName(), type)); return path.orElse(null); }
Example #11
Source File: CodeServerBuilder.java From putnami-gradle-plugin with GNU Lesser General Public License v3.0 | 6 votes |
private Collection<File> listProjectDepsSrcDirs(Project project) { ConfigurationContainer configs = project.getConfigurations(); Configuration compileConf = configs.getByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME); DependencySet depSet = compileConf.getAllDependencies(); List<File> result = Lists.newArrayList(); for (Dependency dep : depSet) { if (dep instanceof ProjectDependency) { Project projectDependency = ((ProjectDependency) dep).getDependencyProject(); if (projectDependency.getPlugins().hasPlugin(PwtLibPlugin.class)) { JavaPluginConvention javaConvention = projectDependency.getConvention().getPlugin(JavaPluginConvention.class); SourceSet mainSourceSet = javaConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME); result.addAll(mainSourceSet.getAllSource().getSrcDirs()); } } } return result; }
Example #12
Source File: DefaultProjectDependency.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public boolean contentEquals(Dependency dependency) { if (this == dependency) { return true; } if (dependency == null || getClass() != dependency.getClass()) { return false; } ProjectDependency that = (ProjectDependency) dependency; if (!isCommonContentEquals(that)) { return false; } return dependencyProject.equals(that.getDependencyProject()); }
Example #13
Source File: JavaPlugin.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
void configureConfigurations(Project project) { ConfigurationContainer configurations = project.getConfigurations(); Configuration compileConfiguration = configurations.getByName(COMPILE_CONFIGURATION_NAME); Configuration runtimeConfiguration = configurations.getByName(RUNTIME_CONFIGURATION_NAME); Configuration compileTestsConfiguration = configurations.getByName(TEST_COMPILE_CONFIGURATION_NAME); compileTestsConfiguration.extendsFrom(compileConfiguration); configurations.getByName(TEST_RUNTIME_CONFIGURATION_NAME).extendsFrom(runtimeConfiguration, compileTestsConfiguration); configurations.getByName(Dependency.DEFAULT_CONFIGURATION).extendsFrom(runtimeConfiguration); }
Example #14
Source File: DefaultProjectDependency.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void resolve(DependencyResolveContext context) { boolean transitive = isTransitive() && context.isTransitive(); if (transitive) { for (Dependency dependency : getProjectConfiguration().getAllDependencies()) { context.add(dependency); } } }
Example #15
Source File: DefaultClientModule.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public boolean contentEquals(Dependency dependency) { if (this == dependency) { return true; } if (dependency == null || getClass() != dependency.getClass()) { return false; } ClientModule that = (ClientModule) dependency; if (!isContentEqualsFor(that)) { return false; } return dependencies.equals(that.getDependencies()); }
Example #16
Source File: GroovyBasePlugin.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private void deprecateGroovyConfiguration(Configuration groovyConfiguration) { groovyConfiguration.getDependencies().whenObjectAdded(new Action<Dependency>() { public void execute(Dependency dependency) { DeprecationLogger.nagUserOfDiscontinuedConfiguration(GROOVY_CONFIGURATION_NAME, "Typically, usages of 'groovy' " + "can simply be replaced with 'compile'. In some cases, it may be necessary to additionally configure " + "the 'groovyClasspath' property of GroovyCompile and Groovydoc tasks."); } }); }
Example #17
Source File: DefaultProjectDependency.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void resolve(DependencyResolveContext context) { boolean transitive = isTransitive() && context.isTransitive(); if (transitive) { for (Dependency dependency : getProjectConfiguration().getAllDependencies()) { context.add(dependency); } } }
Example #18
Source File: DefaultClientModule.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public boolean contentEquals(Dependency dependency) { if (this == dependency) { return true; } if (dependency == null || getClass() != dependency.getClass()) { return false; } ClientModule that = (ClientModule) dependency; return isContentEqualsFor(that) && dependencies.equals(that.getDependencies()); }
Example #19
Source File: DependencyResolverIvyPublisher.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private Artifact createIvyArtifact(IvyArtifact ivyArtifact, ModuleRevisionId moduleRevisionId) { Map<String, String> extraAttributes = new HashMap<String, String>(); if (GUtil.isTrue(ivyArtifact.getClassifier())) { extraAttributes.put(Dependency.CLASSIFIER, ivyArtifact.getClassifier()); } return new DefaultArtifact( moduleRevisionId, null, GUtil.elvis(ivyArtifact.getName(), moduleRevisionId.getName()), ivyArtifact.getType(), ivyArtifact.getExtension(), extraAttributes); }
Example #20
Source File: JavaPlugin.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
void configureConfigurations(Project project) { ConfigurationContainer configurations = project.getConfigurations(); Configuration compileConfiguration = configurations.getByName(COMPILE_CONFIGURATION_NAME); Configuration runtimeConfiguration = configurations.getByName(RUNTIME_CONFIGURATION_NAME); Configuration compileTestsConfiguration = configurations.getByName(TEST_COMPILE_CONFIGURATION_NAME); compileTestsConfiguration.extendsFrom(compileConfiguration); configurations.getByName(TEST_RUNTIME_CONFIGURATION_NAME).extendsFrom(runtimeConfiguration, compileTestsConfiguration); configurations.getByName(Dependency.DEFAULT_CONFIGURATION).extendsFrom(runtimeConfiguration); }
Example #21
Source File: MavenPlugin.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private void configureInstall(Project project) { Upload installUpload = project.getTasks().create(INSTALL_TASK_NAME, Upload.class); Configuration configuration = project.getConfigurations().getByName(Dependency.ARCHIVES_CONFIGURATION); installUpload.setConfiguration(configuration); MavenRepositoryHandlerConvention repositories = new DslObject(installUpload.getRepositories()).getConvention().getPlugin(MavenRepositoryHandlerConvention.class); repositories.mavenInstaller(); installUpload.setDescription("Installs the 'archives' artifacts into the local Maven repository."); }
Example #22
Source File: DefaultClientModule.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public boolean contentEquals(Dependency dependency) { if (this == dependency) { return true; } if (dependency == null || getClass() != dependency.getClass()) { return false; } ClientModule that = (ClientModule) dependency; return isContentEqualsFor(that) && dependencies.equals(that.getDependencies()); }
Example #23
Source File: EarPlugin.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private void configureConfigurations(final Project project) { ConfigurationContainer configurations = project.getConfigurations(); Configuration moduleConfiguration = configurations.create(DEPLOY_CONFIGURATION_NAME).setVisible(false) .setTransitive(false).setDescription("Classpath for deployable modules, not transitive."); Configuration earlibConfiguration = configurations.create(EARLIB_CONFIGURATION_NAME).setVisible(false) .setDescription("Classpath for module dependencies."); configurations.getByName(Dependency.DEFAULT_CONFIGURATION) .extendsFrom(moduleConfiguration, earlibConfiguration); }
Example #24
Source File: DependenciesSettings.java From gradle-golang-plugin with Mozilla Public License 2.0 | 5 votes |
@Nonnull protected Dependency doAdd(@Nonnull String configurationName, @Nonnull Map<String, Object> arguments, @Nullable Closure<?> configureWith) { final String group = requiredArgument(arguments, "group"); final String version = argument(arguments, "version"); final URI repositoryUri = uriArgument(arguments, "repositoryUri"); final VcsType repositoryType = vcsTypeArgument(arguments, "repositoryType"); final UpdatePolicy updatePolicy = updatePolicyArgument(arguments, "updatePolicy"); return doAdd(configurationName, new GolangDependency() .setGroup(group) .setVersion(version) .setRepositoryUri(repositoryUri) .setRepositoryType(repositoryType) .setUpdatePolicy(updatePolicy) , configureWith); }
Example #25
Source File: DependencyResolverIvyPublisher.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private Artifact createIvyArtifact(IvyArtifact ivyArtifact, ModuleRevisionId moduleRevisionId) { Map<String, String> extraAttributes = new HashMap<String, String>(); if (GUtil.isTrue(ivyArtifact.getClassifier())) { extraAttributes.put(Dependency.CLASSIFIER, ivyArtifact.getClassifier()); } return new DefaultArtifact( moduleRevisionId, null, GUtil.elvis(ivyArtifact.getName(), moduleRevisionId.getName()), ivyArtifact.getType(), ivyArtifact.getExtension(), extraAttributes); }
Example #26
Source File: JCenterPluginMapper.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public Dependency map(final PluginRequest request, DependencyHandler dependencyHandler) { final String pluginId = request.getId(); String systemId = cacheSupplier.supplyTo(new Transformer<String, PersistentIndexedCache<PluginRequest, String>>() { public String transform(PersistentIndexedCache<PluginRequest, String> cache) { return doCacheAwareSearch(request, pluginId, cache); } }); if (systemId.equals(NOT_FOUND)) { return null; } else { return dependencyHandler.create(systemId + ":" + request.getVersion()); } }
Example #27
Source File: DefaultConfigurationsToArtifactsConverter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
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 #28
Source File: ModuleMappingPluginResolver.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public PluginResolution resolve(final PluginRequest pluginRequest) { final Dependency dependency = mapper.map(pluginRequest, dependencyResolutionServices.getDependencyHandler()); if (dependency == null) { return null; } else { // TODO the dependency resolution config of this guy needs to be externalized Factory<ClassPath> classPathFactory = new DependencyResolvingClasspathProvider(dependencyResolutionServices, dependency, repositoriesConfigurer); return new ClassPathPluginResolution(instantiator, pluginRequest.getId(), classPathFactory); } }
Example #29
Source File: Utils.java From Injector with Apache License 2.0 | 5 votes |
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 #30
Source File: DefaultExternalModuleDependency.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public boolean contentEquals(Dependency dependency) { if (this == dependency) { return true; } if (dependency == null || getClass() != dependency.getClass()) { return false; } DefaultExternalModuleDependency that = (DefaultExternalModuleDependency) dependency; if (!isContentEqualsFor(that)) { return false; } return changing == that.isChanging(); }