Search in sources :

Example 56 with Dependency

use of org.gradle.api.artifacts.Dependency in project gradle-apt-plugin by tbroyer.

the class AptPlugin method createAptConfiguration.

private void createAptConfiguration(final Project project, SourceSet sourceSet, AptSourceSetConvention convention, final Configuration annotationProcessorConfiguration) {
    final Configuration aptConfiguration = project.getConfigurations().create(convention.getAptConfigurationName());
    aptConfiguration.setVisible(false);
    aptConfiguration.setDescription("Processor path for " + sourceSet.getName() + ". Deprecated, please use the " + annotationProcessorConfiguration.getName() + " configuration instead.");
    aptConfiguration.getDependencies().whenObjectAdded(new Action<Dependency>() {

        @Override
        public void execute(Dependency dependency) {
            DeprecationLogger.nagUserWith(project, "The " + aptConfiguration.getName() + " configuration has been deprecated. Please use the " + annotationProcessorConfiguration.getName() + " configuration instead.");
        }
    });
    annotationProcessorConfiguration.extendsFrom(aptConfiguration);
}
Also used : Configuration(org.gradle.api.artifacts.Configuration) Dependency(org.gradle.api.artifacts.Dependency)

Example 57 with Dependency

use of org.gradle.api.artifacts.Dependency in project checkstyle-idea by jshiell.

the class CsaccessTestTask method getClasspath.

/**
 * Overriding getClasspath() in order to set the final classpath is an unusual solution, but it was the only
 * solution which included the classpath entries generated by the IntelliJ plugin creation plugin (which, in my
 * humble opinion, should be considered seriously broken).
 *
 * @return the classpath to use to execute the tests
 */
@Override
public FileCollection getClasspath() {
    final FileCollection originalClasspath = super.getClasspath();
    FileCollection effectiveClasspath = null;
    if (originalClasspath != null) {
        final Project project = getProject();
        final JavaPluginExtension jpc = project.getExtensions().getByType(JavaPluginExtension.class);
        final SourceSetContainer sourceSets = jpc.getSourceSets();
        final SourceSet mainSourceSet = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
        final SourceSet testSourceSet = sourceSets.getByName(SourceSet.TEST_SOURCE_SET_NAME);
        final SourceSet csaccessSourceSet = sourceSets.getByName(CustomSourceSetCreator.CSACCESS_SOURCESET_NAME);
        final SourceSet csaccessTestSrcSet = sourceSets.getByName(CustomSourceSetCreator.CSACCESSTEST_SOURCESET_NAME);
        final Dependency csDep = CheckstyleVersions.createCheckstyleDependency(project, csVersion);
        final ConfigurationContainer configurations = project.getConfigurations();
        final Set<File> csJars = configurations.detachedConfiguration(csDep).getFiles();
        effectiveClasspath = project.files(csaccessTestSrcSet.getOutput().getResourcesDir(), csaccessSourceSet.getOutput().getResourcesDir(), mainSourceSet.getOutput().getResourcesDir()).plus(csaccessTestSrcSet.getOutput().getClassesDirs()).plus(csaccessSourceSet.getOutput().getClassesDirs()).plus(mainSourceSet.getOutput().getClassesDirs()).plus(project.files(csJars)).plus(originalClasspath).minus(testSourceSet.getOutput().getClassesDirs()).minus(project.files(testSourceSet.getOutput().getResourcesDir()));
        if (getLogger().isDebugEnabled()) {
            getLogger().debug("--------------------------------------------------------------------------");
            getLogger().debug("Effective classpath of " + getName() + ":");
            for (File f : effectiveClasspath) {
                getLogger().debug("\t- " + f.getAbsolutePath());
            }
        }
    }
    return effectiveClasspath;
}
Also used : Project(org.gradle.api.Project) SourceSet(org.gradle.api.tasks.SourceSet) ConfigurationContainer(org.gradle.api.artifacts.ConfigurationContainer) JavaPluginExtension(org.gradle.api.plugins.JavaPluginExtension) Dependency(org.gradle.api.artifacts.Dependency) FileCollection(org.gradle.api.file.FileCollection) SourceSetContainer(org.gradle.api.tasks.SourceSetContainer) File(java.io.File)

Example 58 with Dependency

use of org.gradle.api.artifacts.Dependency in project checkstyle-idea by jshiell.

the class GatherCheckstyleArtifactsTask method resolveDependencies.

private Set<File> resolveDependencies(final Project project, final String checkstyleVersion) {
    final Dependency csDep = CheckstyleVersions.createCheckstyleDependency(project, checkstyleVersion);
    final Configuration csConf = project.getConfigurations().detachedConfiguration(csDep);
    return csConf.resolve();
}
Also used : Configuration(org.gradle.api.artifacts.Configuration) Dependency(org.gradle.api.artifacts.Dependency)

Aggregations

Dependency (org.gradle.api.artifacts.Dependency)58 Configuration (org.gradle.api.artifacts.Configuration)20 ProjectDependency (org.gradle.api.artifacts.ProjectDependency)16 File (java.io.File)13 Project (org.gradle.api.Project)13 ModuleDependency (org.gradle.api.artifacts.ModuleDependency)12 ExternalModuleDependency (org.gradle.api.artifacts.ExternalModuleDependency)8 MinimalExternalModuleDependency (org.gradle.api.artifacts.MinimalExternalModuleDependency)8 ArrayList (java.util.ArrayList)7 List (java.util.List)7 FileCollectionDependency (org.gradle.api.artifacts.FileCollectionDependency)6 Collectors (java.util.stream.Collectors)5 Inject (javax.inject.Inject)5 DependencySet (org.gradle.api.artifacts.DependencySet)5 ObjectFactory (org.gradle.api.model.ObjectFactory)5 TaskDependency (org.gradle.api.tasks.TaskDependency)5 EtaDependency (com.typelead.gradle.eta.api.EtaDependency)4 EtaProjectDependency (com.typelead.gradle.eta.api.EtaProjectDependency)4 Map (java.util.Map)4 Provider (org.gradle.api.provider.Provider)4