org.gradle.api.artifacts.Configuration Java Examples

The following examples show how to use org.gradle.api.artifacts.Configuration. 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 Project: pushfish-android   Author: PushFish   File: AsciiDependencyReportRenderer.java    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void startConfiguration(final Configuration configuration) {
    if (hasConfigs) {
        getTextOutput().println();
    }
    hasConfigs = true;
    GraphRenderer renderer = new GraphRenderer(getTextOutput());
    renderer.visit(new Action<StyledTextOutput>() {
        public void execute(StyledTextOutput styledTextOutput) {
            getTextOutput().withStyle(Identifier).text(configuration.getName());
            getTextOutput().withStyle(Description).text(getDescription(configuration));
        }
    }, true);

    NodeRenderer nodeRenderer = new SimpleNodeRenderer();
    dependencyGraphRenderer = new DependencyGraphRenderer(renderer, nodeRenderer);
}
 
Example #2
Source Project: pushfish-android   Author: PushFish   File: IdeaDependenciesProvider.java    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
private boolean isMappedToIdeaScope(final Configuration configuration, IdeaModule ideaModule) {
    Iterable<IdeaScopeMappingRule> rules = Iterables.concat(scopeMappings.values());
    boolean matchesRule = Iterables.any(rules, new Predicate<IdeaScopeMappingRule>() {
        public boolean apply(IdeaScopeMappingRule ideaScopeMappingRule) {
            return ideaScopeMappingRule.configurationNames.contains(configuration.getName());
        }
    });
    if (matchesRule) {
        return true;
    }
    for (Map<String, Collection<Configuration>> scopeMap : ideaModule.getScopes().values()) {
        Iterable<Configuration> configurations = Iterables.concat(scopeMap.values());
        if (Iterables.any(configurations, Predicates.equalTo(configuration))) {
            return true;
        }
    }
    return false;
}
 
Example #3
Source Project: Pushjet-Android   Author: Pushjet   File: IdeaDependenciesProvider.java    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
private boolean isMappedToIdeaScope(final Configuration configuration, IdeaModule ideaModule) {
    Iterable<IdeaScopeMappingRule> rules = Iterables.concat(scopeMappings.values());
    boolean matchesRule = Iterables.any(rules, new Predicate<IdeaScopeMappingRule>() {
        public boolean apply(IdeaScopeMappingRule ideaScopeMappingRule) {
            return ideaScopeMappingRule.configurationNames.contains(configuration.getName());
        }
    });
    if (matchesRule) {
        return true;
    }
    for (Map<String, Collection<Configuration>> scopeMap : ideaModule.getScopes().values()) {
        Iterable<Configuration> configurations = Iterables.concat(scopeMap.values());
        if (Iterables.any(configurations, Predicates.equalTo(configuration))) {
            return true;
        }
    }
    return false;
}
 
Example #4
Source Project: pushfish-android   Author: PushFish   File: SonarRunnerPlugin.java    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
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 #5
Source Project: Pushjet-Android   Author: Pushjet   File: DefaultDependencyHandler.java    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
public Object methodMissing(String name, Object args) {
    Object[] argsArray = (Object[]) args;
    Configuration configuration = configurationContainer.findByName(name);
    if (configuration == null) {
        throw new MissingMethodException(name, this.getClass(), argsArray);
    }

    List<?> normalizedArgs = CollectionUtils.flattenCollections(argsArray);
    if (normalizedArgs.size() == 2 && normalizedArgs.get(1) instanceof Closure) {
        return doAdd(configuration, normalizedArgs.get(0), (Closure) normalizedArgs.get(1));
    } else if (normalizedArgs.size() == 1) {
        return doAdd(configuration, normalizedArgs.get(0), null);
    } else {
        for (Object arg : normalizedArgs) {
            doAdd(configuration, arg, null);
        }
        return null;
    }
}
 
Example #6
Source Project: Pushjet-Android   Author: Pushjet   File: SonarRunnerPlugin.java    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
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 #7
Source Project: native-samples   Author: gradle   File: CppPublicMacrosPlugin.java    License: Apache License 2.0 6 votes vote down vote up
private static Configuration createConfiguration(ConfigurationContainer configurations, ObjectFactory objectFactory) {
    return configurations.create("cppPublicMacros", new Action<Configuration>() {
        @Override
        public void execute(Configuration configuration) {
            configurations.all(new Action<Configuration>() {
                @Override
                public void execute(Configuration it) {
                    if (it.getName().toLowerCase().endsWith("implementation")) {
                        configuration.extendsFrom(it);
                    }
                }
            });
            configuration.setCanBeConsumed(false);
            configuration.setCanBeResolved(true);
            configuration.getAttributes().attribute(Usage.USAGE_ATTRIBUTE, objectFactory.named(Usage.class, "cpp-public-macros"));
        }
    });
}
 
Example #8
Source Project: Pushjet-Android   Author: Pushjet   File: IdeDependenciesExtractor.java    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
public Collection<IdeExtendedRepoFileDependency> extractRepoFileDependencies(DependencyHandler dependencyHandler, Collection<Configuration> plusConfigurations, Collection<Configuration> minusConfigurations, boolean downloadSources, boolean downloadJavadoc) {
    // can have multiple IDE dependencies with same component identifier (see GRADLE-1622)
    Multimap<ComponentIdentifier, IdeExtendedRepoFileDependency> resolvedDependenciesComponentMap = LinkedHashMultimap.create();
    for (IdeExtendedRepoFileDependency dep : resolvedExternalDependencies(plusConfigurations, minusConfigurations)) {
        resolvedDependenciesComponentMap.put(toComponentIdentifier(dep.getId()), dep);
    }

    List<Class<? extends Artifact>> artifactTypes = new ArrayList<Class<? extends Artifact>>(2);
    if (downloadSources) {
        artifactTypes.add(SourcesArtifact.class);
    }

    if (downloadJavadoc) {
        artifactTypes.add(JavadocArtifact.class);
    }

    downloadAuxiliaryArtifacts(dependencyHandler, resolvedDependenciesComponentMap, artifactTypes);

    Collection<UnresolvedIdeRepoFileDependency> unresolvedDependencies = unresolvedExternalDependencies(plusConfigurations, minusConfigurations);
    Collection<IdeExtendedRepoFileDependency> resolvedDependencies = resolvedDependenciesComponentMap.values();

    Collection<IdeExtendedRepoFileDependency> resolvedAndUnresolved = new ArrayList<IdeExtendedRepoFileDependency>(unresolvedDependencies.size() + resolvedDependencies.size());
    resolvedAndUnresolved.addAll(resolvedDependencies);
    resolvedAndUnresolved.addAll(unresolvedDependencies);
    return resolvedAndUnresolved;
}
 
Example #9
Source Project: Pushjet-Android   Author: Pushjet   File: AsciiDependencyReportRenderer.java    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void startConfiguration(final Configuration configuration) {
    if (hasConfigs) {
        getTextOutput().println();
    }
    hasConfigs = true;
    GraphRenderer renderer = new GraphRenderer(getTextOutput());
    renderer.visit(new Action<StyledTextOutput>() {
        public void execute(StyledTextOutput styledTextOutput) {
            getTextOutput().withStyle(Identifier).text(configuration.getName());
            getTextOutput().withStyle(Description).text(getDescription(configuration));
        }
    }, true);

    NodeRenderer nodeRenderer = new SimpleNodeRenderer();
    dependencyGraphRenderer = new DependencyGraphRenderer(renderer, nodeRenderer);
}
 
Example #10
Source Project: play-services-plugins   Author: google   File: DependencyTaskTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testIsTest_fromHierarchy() {
  Configuration configuration = mock(Configuration.class);
  when(configuration.getName()).thenReturn("random");

  Configuration parent = mock(Configuration.class);
  when(parent.getName()).thenReturn("testCompile");

  Set<Configuration> hierarchy = new HashSet<>();
  hierarchy.add(parent);

  when(configuration.getHierarchy()).thenReturn(hierarchy);
  assertTrue(dependencyTask.isTest(configuration));
}
 
Example #11
Source Project: gradle-cpd-plugin   Author: aaschmid   File: CpdPluginTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
void CpdPlugin_shouldAllowConfigureToolDependenciesExplicitlyViaToolVersionProperty(Project project, Configuration cpdConfiguration, CpdExtension cpd, TaskProvider<Cpd> cpdCheck) {
    // Given:
    project.getRepositories().mavenLocal();
    project.getRepositories().mavenCentral();

    // When:
    cpd.setToolVersion("5.2.1");

    // Then:
    assertThat(cpdCheck.get().getPmdClasspath()).isEqualTo(cpdConfiguration);
    assertThat(cpdConfiguration.resolve()).anyMatch(file -> file.getName().equals("pmd-core-5.2.1.jar"));
}
 
Example #12
Source Project: nohttp   Author: spring-io   File: NoHttpCheckstylePlugin.java    License: Apache License 2.0 5 votes vote down vote up
private void configureDefaultDependenciesForProject(Configuration configuration) {
	configuration.defaultDependencies(new Action<DependencySet>() {
		@Override
		public void execute(DependencySet dependencies) {
			NoHttpExtension extension = NoHttpCheckstylePlugin.this.extension;
			dependencies.add(NoHttpCheckstylePlugin.this.project.getDependencies().create("io.spring.nohttp:nohttp-checkstyle:" + extension.getToolVersion()));
		}
	});
}
 
Example #13
Source Project: gradle-plugins   Author: freefair   File: AspectJPostCompileWeavingPlugin.java    License: MIT License 5 votes vote down vote up
private AjcAction enhanceWithWeavingAction(AbstractCompile abstractCompile, Configuration aspectpath, Configuration inpath, Configuration aspectjConfiguration) {
    AjcAction action = project.getObjects().newInstance(AjcAction.class);

    action.getOptions().getAspectpath().from(aspectpath);
    action.getOptions().getInpath().from(inpath);
    action.getAdditionalInpath().from(abstractCompile.getDestinationDir());
    action.getClasspath().from(aspectjConfiguration);

    action.addToTask(abstractCompile);

    return action;
}
 
Example #14
Source Project: native-samples   Author: gradle   File: WrappedNativeApplicationPlugin.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void apply(Project project) {
    project.getPluginManager().apply("org.gradle.samples.wrapped-native-base");

    // Add configurations for incoming dependencies
    final Usage cppApiUsage = project.getObjects().named(Usage.class, Usage.C_PLUS_PLUS_API);
    final Usage linkUsage = project.getObjects().named(Usage.class, Usage.NATIVE_LINK);

    Configuration implementation = project.getConfigurations().create("implementation", it -> {
        it.setCanBeConsumed(false);
        it.setCanBeResolved(false);
    });

    // incoming compile time headers
    project.getConfigurations().create("cppCompile", it -> {
        it.setCanBeConsumed(false);
        it.getAttributes().attribute(Usage.USAGE_ATTRIBUTE, cppApiUsage);
        it.extendsFrom(implementation);
    });

    // incoming link files
    project.getConfigurations().create("linkDebug", it -> {
        it.setCanBeConsumed(false);
        it.getAttributes().attribute(Usage.USAGE_ATTRIBUTE, linkUsage);
        it.getAttributes().attribute(CppBinary.DEBUGGABLE_ATTRIBUTE, true);
        it.getAttributes().attribute(CppBinary.OPTIMIZED_ATTRIBUTE, false);
        it.extendsFrom(implementation);
    });
    project.getConfigurations().create("linkRelease", it -> {
        it.setCanBeConsumed(false);
        it.getAttributes().attribute(Usage.USAGE_ATTRIBUTE, linkUsage);
        it.getAttributes().attribute(CppBinary.DEBUGGABLE_ATTRIBUTE, true);
        it.getAttributes().attribute(CppBinary.OPTIMIZED_ATTRIBUTE, true);
        it.extendsFrom(implementation);
    });
}
 
Example #15
Source Project: play-services-plugins   Author: google   File: DependencyTaskTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testGetResolvedArtifacts_isPackagedImplementation() {
  Set<ResolvedArtifact> artifactSet = prepareArtifactSet(2);
  ResolvedConfiguration resolvedConfiguration = mockResolvedConfiguration(artifactSet);

  Configuration configuration = mock(Configuration.class);
  when(configuration.isCanBeResolved()).thenReturn(true);
  when(configuration.getResolvedConfiguration()).thenReturn(resolvedConfiguration);

  when(configuration.getName()).thenReturn("implementation");

  assertThat(dependencyTask.getResolvedArtifacts(configuration), is(artifactSet));
}
 
Example #16
public Conf2ScopeMapping getMapping(Collection<Configuration> configurations) {
    Set<Conf2ScopeMapping> result = getMappingsWithHighestPriority(configurations);
    if (result.size() > 1) {
        throw new InvalidUserDataException(
                "The configuration to scope mapping is not unique. The following configurations "
                        + "have the same priority: " + result);
    }
    return result.size() == 0 ? null : result.iterator().next();
}
 
Example #17
public org.apache.ivy.core.module.descriptor.Configuration getIvyConfiguration(Configuration configuration) {
    String[] superConfigs = Configurations.getNames(configuration.getExtendsFrom(), false).toArray(new String[configuration.getExtendsFrom().size()]);
    Arrays.sort(superConfigs);
    return new org.apache.ivy.core.module.descriptor.Configuration(
            configuration.getName(),
            configuration.isVisible() ? org.apache.ivy.core.module.descriptor.Configuration.Visibility.PUBLIC : org.apache.ivy.core.module.descriptor.Configuration.Visibility.PRIVATE,
            configuration.getDescription(),
            superConfigs,
            configuration.isTransitive(),
            null);
}
 
Example #18
public void addArtifacts(MutableLocalComponentMetaData metaData, Iterable<? extends Configuration> configurations) {
    DefaultModuleDescriptor moduleDescriptor = metaData.getModuleDescriptor();
    for (Configuration configuration : configurations) {
        for (PublishArtifact publishArtifact : configuration.getArtifacts()) {
            Artifact ivyArtifact = createIvyArtifact(publishArtifact, moduleDescriptor.getModuleRevisionId());
            metaData.addArtifact(configuration.getName(), ivyArtifact, publishArtifact.getFile());
        }
    }
}
 
Example #19
public Conf2ScopeMapping getMapping(Collection<Configuration> configurations) {
    Set<Conf2ScopeMapping> result = getMappingsWithHighestPriority(configurations);
    if (result.size() > 1) {
        throw new InvalidUserDataException(
                "The configuration to scope mapping is not unique. The following configurations "
                        + "have the same priority: " + result);
    }
    return result.size() == 0 ? null : result.iterator().next();
}
 
Example #20
Source Project: transport   Author: linkedin   File: ShadeTask.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Returns all the classes present in all the dependencies of the input configuration
 */
private Set<String> classesInConfiguration(Configuration conf) {
  // Do not modify original as it will be used in building fat jar
  Configuration configuration = conf.copyRecursive();

  FileCollection fileCollection = super.getDependencyFilter().resolve(configuration);
  FileCollection jars = fileCollection.getAsFileTree().filter(file -> file.getName().endsWith(".jar"));

  LOG.info("Will shade the following jars for project " + getProject().getName());
  new TreeSet<>(jars.getFiles()).forEach(jar -> LOG.info(jar.toString()));
  Set<String> classes = new HashSet<>();
  jars.forEach(jar -> classes.addAll(classesInJar(jar)));
  return classes;
}
 
Example #21
Source Project: javaccPlugin   Author: johnmartel   File: JavaccPlugin.java    License: MIT License 5 votes vote down vote up
private Configuration createJavaccConfiguration(Project project) {
    Configuration configuration = project.getConfigurations().create("javacc");
    configuration.setVisible(false);
    configuration.setTransitive(true);
    configuration.setDescription("The javacc dependencies to be used.");
    return configuration;
}
 
Example #22
Source Project: javafxmobile-plugin   Author: javafxports   File: RetrolambdaExec.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static VersionNumber retrolambdaVersion(Configuration retrolambdaConfig) {
    retrolambdaConfig.resolve();
    Dependency retrolambdaDep = retrolambdaConfig.getDependencies().iterator().next();
    if (retrolambdaDep.getVersion() == null) {
        // Don't know version
        return null;
    }
    return VersionNumber.parse(retrolambdaDep.getVersion());
}
 
Example #23
Source Project: pushfish-android   Author: PushFish   File: IvyBackedArtifactPublisher.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void publish(final Iterable<? extends PublicationAwareRepository> repositories, final ModuleInternal module, final Configuration configuration, final File descriptor) throws PublishException {
    ivyContextManager.withIvy(new Action<Ivy>() {
        public void execute(Ivy ivy) {
            Set<Configuration> allConfigurations = configuration.getAll();
            Set<Configuration> configurationsToPublish = configuration.getHierarchy();

            MutableLocalComponentMetaData componentMetaData = publishLocalComponentFactory.convert(allConfigurations, module);
            if (descriptor != null) {
                ModuleDescriptor moduleDescriptor = componentMetaData.getModuleDescriptor();
                ivyModuleDescriptorWriter.write(moduleDescriptor, descriptor);
            }

            // Need to convert a second time, to determine which artifacts to publish (and yes, this isn't a great way to do things...)
            componentMetaData = publishLocalComponentFactory.convert(configurationsToPublish, module);
            BuildableIvyModulePublishMetaData publishMetaData = componentMetaData.toPublishMetaData();
            if (descriptor != null) {
                Artifact artifact = MDArtifact.newIvyArtifact(componentMetaData.getModuleDescriptor());
                publishMetaData.addArtifact(artifact, descriptor);
            }

            List<ModuleVersionPublisher> publishResolvers = new ArrayList<ModuleVersionPublisher>();
            for (PublicationAwareRepository repository : repositories) {
                ModuleVersionPublisher publisher = repository.createPublisher();
                publishResolvers.add(publisher);
            }

            dependencyPublisher.publish(publishResolvers, publishMetaData);
        }
    });
}
 
Example #24
Source Project: Pushjet-Android   Author: Pushjet   File: ResolveLocalComponentFactory.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
public MutableLocalComponentMetaData convert(Set<? extends Configuration> configurations, ModuleInternal module) {
    assert configurations.size() > 0 : "No configurations found for module: " + module.getName() + ". Configure them or apply a plugin that does it.";
    DefaultModuleDescriptor moduleDescriptor = new DefaultModuleDescriptor(IvyUtil.createModuleRevisionId(module), module.getStatus(), null);
    moduleDescriptor.addExtraAttributeNamespace(IVY_MAVEN_NAMESPACE_PREFIX, IVY_MAVEN_NAMESPACE);
    ComponentIdentifier componentIdentifier = componentIdentifierFactory.createComponentIdentifier(module);
    DefaultLocalComponentMetaData metaData = new DefaultLocalComponentMetaData(moduleDescriptor, componentIdentifier);
    configurationsToModuleDescriptorConverter.addConfigurations(metaData, configurations);
    dependenciesToModuleDescriptorConverter.addDependencyDescriptors(metaData, configurations);
    configurationsToArtifactsConverter.addArtifacts(metaData, configurations);
    return metaData;
}
 
Example #25
Source Project: gradle-golang-plugin   Author: echocat   File: DependenciesSettings.java    License: Mozilla Public License 2.0 5 votes vote down vote up
@Nonnull
protected Dependency doAdd(@Nonnull String configurationName, @Nonnull Dependency dependency, @Nullable Closure<?> configureWith) {
    if (!_root) {
        throw new IllegalStateException("Adding of dependencies for golang is currently not support at task level.");
    }
    final Configuration configuration = _project.getConfigurations().getByName(configurationName);
    configuration.getDependencies().add(dependency);
    if (configureWith != null) {
        return configure(configureWith, dependency);
    }
    return dependency;
}
 
Example #26
Source Project: pushfish-android   Author: PushFish   File: ResolveLocalComponentFactory.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
public MutableLocalComponentMetaData convert(Set<? extends Configuration> configurations, ModuleInternal module) {
    assert configurations.size() > 0 : "No configurations found for module: " + module.getName() + ". Configure them or apply a plugin that does it.";
    DefaultModuleDescriptor moduleDescriptor = new DefaultModuleDescriptor(IvyUtil.createModuleRevisionId(module), module.getStatus(), null);
    moduleDescriptor.addExtraAttributeNamespace(IVY_MAVEN_NAMESPACE_PREFIX, IVY_MAVEN_NAMESPACE);
    ComponentIdentifier componentIdentifier = componentIdentifierFactory.createComponentIdentifier(module);
    DefaultLocalComponentMetaData metaData = new DefaultLocalComponentMetaData(moduleDescriptor, componentIdentifier);
    configurationsToModuleDescriptorConverter.addConfigurations(metaData, configurations);
    dependenciesToModuleDescriptorConverter.addDependencyDescriptors(metaData, configurations);
    configurationsToArtifactsConverter.addArtifacts(metaData, configurations);
    return metaData;
}
 
Example #27
Source Project: Pushjet-Android   Author: Pushjet   File: UploadRule.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void apply(String taskName) {
    for (Configuration configuration :  project.getConfigurations()) {
        if (taskName.equals(configuration.getUploadTaskName())) {
            createUploadTask(configuration.getUploadTaskName(), configuration, project);
        }
    }
}
 
Example #28
Source Project: pygradle   Author: linkedin   File: DependencyOrder.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Collects configuration files in post-order.
 *
 * @param configuration Gradle configuration to work with
 * @return set of files corresponding to post-order of dependency tree
 */
public static Collection<File> configurationPostOrderFiles(Configuration configuration) {
    Map<ModuleVersionIdentifier, File> idToFileMap = new HashMap<>();
    Set<File> files = new LinkedHashSet<>();
    Set<File> configurationFiles = configuration.getFiles();

    // Create an id:file mapping.
    Set<ResolvedArtifact> artifacts = configuration.getResolvedConfiguration().getResolvedArtifacts();
    for (ResolvedArtifact artifact : artifacts) {
        ModuleVersionIdentifier id = artifact.getModuleVersion().getId();
        File file = artifact.getFile();
        idToFileMap.put(id, file);
    }

    // Prepare an ordered set of files in post-order.
    for (ResolvedComponentResult d : configurationPostOrderDependencies(configuration)) {
        if (!idToFileMap.containsKey(d.getModuleVersion())) {
            logger.warn("***** WARNING Missing resolved artifact for " + d);
        } else {
            files.add(idToFileMap.get(d.getModuleVersion()));
        }
    }

    // Make sure the files set is a subset of configuration files.
    if (!configurationFiles.containsAll(files)) {
        throw new GradleException("Could not find matching dependencies for all configuration files");
    }

    /*
     * Our rest.li generated packages will extend configuration and
     * will not appear in the resolved results. We are going to add
     * them at the end in the same order they were added to
     * configuration files.
     */
    if (files.size() != configurationFiles.size()) {
        files.addAll(difference(configurationFiles, files));
    }

    return files;
}
 
Example #29
Source Project: javaccPlugin   Author: johnmartel   File: JjtreeProgramInvokerTest.java    License: MIT License 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    project = mock(Project.class);
    Configuration classpath = mock(Configuration.class);
    tempOutputDirectory = testFolder.newFolder("tempOutput");
    programInvoker = new JjtreeProgramInvoker(project, classpath, tempOutputDirectory);
}
 
Example #30
Source Project: pushfish-android   Author: PushFish   File: DefaultProjectDependency.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void resolve(TaskDependencyResolveContext context) {
    if (!buildProjectDependencies) {
        return;
    }
    projectAccessListener.beforeResolvingProjectDependency(dependencyProject);

    Configuration configuration = getProjectConfiguration();
    context.add(configuration);
    context.add(configuration.getAllArtifacts());
}