public static Provisioner fromProject(Project project) { Objects.requireNonNull(project); return (withTransitives, mavenCoords) -> { try { Dependency[] deps = mavenCoords.stream() .map(project.getBuildscript().getDependencies()::create) .toArray(Dependency[]::new); Configuration config = project.getRootProject().getBuildscript().getConfigurations().detachedConfiguration(deps); config.setDescription(mavenCoords.toString()); config.setTransitive(withTransitives); return config.resolve(); } catch (Exception e) { logger.log(Level.SEVERE, StringPrinter.buildStringFromLines("You probably need to add a repository containing the '" + mavenCoords + "' artifact in the 'build.gradle' of your root project.", "E.g.: 'buildscript { repositories { mavenCentral() }}'", "Note that included buildscripts (using 'apply from') do not share their buildscript repositories with the underlying project.", "You have to specify the missing repository explicitly in the buildscript of the root project."), e); throw e; } }; }
/** * Creates a Provisioner for the given repositories. * * The first time a project is created, there are ~7 seconds of configuration * which will go away for all subsequent runs. * * Every call to resolve will take about 1 second, even when all artifacts are resolved. */ private static Supplier<Provisioner> createLazyWithRepositories(Consumer<RepositoryHandler> repoConfig) { // Running this takes ~3 seconds the first time it is called. Probably because of classloading. return Suppliers.memoize(() -> { Project project = ProjectBuilder.builder().build(); repoConfig.accept(project.getRepositories()); return (withTransitives, mavenCoords) -> { Dependency[] deps = mavenCoords.stream() .map(project.getDependencies()::create) .toArray(Dependency[]::new); Configuration config = project.getConfigurations().detachedConfiguration(deps); config.setTransitive(withTransitives); config.setDescription(mavenCoords.toString()); try { return config.resolve(); } catch (ResolveException e) { /* Provide Maven coordinates in exception message instead of static string 'detachedConfiguration' */ throw new ResolveException(config.getDescription(), e); } }; }); }
private void addWebJarConfig() { this.project.getConfigurations().create( "webjar", conf -> conf.setTransitive( true ) ); }
@Override public void execute(Configuration files) { files.setVisible(false); files.setTransitive(true); files.setDescription("The Jacoco agent to use to get coverage data."); } });
@Override public void execute(Configuration files) { files.setVisible(false); files.setTransitive(true); files.setDescription( "The Jacoco ant tasks to use to get execute Gradle tasks."); } });
private void addConfigurations() { this.project.getConfigurations().create( APP_CONFIG ).setTransitive( false ); this.project.getConfigurations().create( DISTRO_CONFIG ).setTransitive( false ); }
private void addConfigurations() { this.project.getConfigurations().create( APP_CONFIG ).setTransitive( false ); this.project.getConfigurations().create( DISTRO_CONFIG ).setTransitive( false ); }
private void addWebJarConfig() { this.project.getConfigurations().create( "webjar", conf -> conf.setTransitive( true ) ); }
private void configureSpotBugsConfigurations() { Configuration configuration = project.getConfigurations().create("spotbugsPlugins"); configuration.setVisible(false); configuration.setTransitive(true); configuration.setDescription("The SpotBugs plugins to be used for this project."); }
private void configureFindBugsConfigurations() { Configuration configuration = project.getConfigurations().create("findbugsPlugins"); configuration.setVisible(false); configuration.setTransitive(true); configuration.setDescription("The FindBugs plugins to be used for this project."); }
private void configureSpotBugsConfigurations() { Configuration configuration = project.getConfigurations().create("spotbugsPlugins"); configuration.setVisible(false); configuration.setTransitive(true); configuration.setDescription("The SpotBugs plugins to be used for this project."); }
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; }
@Override public void apply(Project project) { setGroup(CHECK_DEPENDENCY_VERSIONS_TASK_GROUP); setDescription(CHECK_DEPENDENCY_VERSIONS_TASK_DESCRIPTION); project.getBuildscript().getConfigurations().create(CHECK_BUILDSCRIPT_DEPENDENCY_VERSIONS_CONFIGURATION_NAME) .setVisible(false).setTransitive(false); project.getConfigurations().create(CHECK_PROJECT_DEPENDENCY_VERSIONS_CONFIGURATION_NAME).setVisible(false) .setTransitive(false); }
private void addLibraryConfig() { final Configuration libConfig = this.project.getConfigurations().create( "include", conf -> conf.setTransitive( true ) ); this.project.getConfigurations().getByName( "compile" ).extendsFrom( libConfig ); }
private void addLibraryConfig() { final Configuration libConfig = this.project.getConfigurations().create( "include", conf -> conf.setTransitive( true ) ); this.project.getConfigurations().getByName( "compile" ).extendsFrom( libConfig ); }
private FileCollection resolveShim() { Dependency shimImpl = project.getDependencies().create("org.projectodd.shimdandy:shimdandy-impl:" + SHIMDANDY_VERSION); Dependency tools = project.getDependencies().create("io.github.gradle-clojure:gradle-clojure-tools:" + GRADLE_CLOJURE_VERSION); Dependency nrepl = project.getDependencies().create("org.clojure:tools.nrepl:" + NREPL_VERSION); return project.getConfigurations().detachedConfiguration(shimImpl, tools, nrepl).setTransitive(false); }
private Configuration configureAgentDependencies(Project project, ScottPluginExtension extension) { Configuration agentConf = project.getConfigurations().create(AGENT_CONFIGURATION_NAME); agentConf.setVisible(false); agentConf.setTransitive(true); agentConf.setDescription("The Scott agent to use detailed failure reports and hassle free assertions for Java tests"); agentConf.defaultDependencies(dependencies -> dependencies.add(project.getDependencies().create("hu.advancedweb:scott:" + extension.getToolVersion())) ); return agentConf; }
private Configuration configureAgentDependencies(Project project, ScottPluginExtension extension) { Configuration agentConf = project.getConfigurations().create(AGENT_CONFIGURATION_NAME); agentConf.setVisible(false); agentConf.setTransitive(true); agentConf.setDescription("The Scott agent to use detailed failure reports and hassle free assertions for Java tests"); agentConf.defaultDependencies(dependencies -> dependencies.add(project.getDependencies().create("hu.advancedweb:scott:" + extension.getToolVersion())) ); return agentConf; }
/** * @see me.seeber.gradle.plugin.AbstractProjectConfigPlugin#initialize() */ @Override protected void initialize() { getProject().getPlugins().apply(ProjectConfigPlugin.class); getProject().getPlugins().apply(JavaPlugin.class); getProject().getConfigurations().create("annotate", c -> { c.setDescription("Modules annotated by this project."); c.setVisible(true); c.setTransitive(false); }); } }
/** * @see me.seeber.gradle.plugin.AbstractProjectConfigPlugin#initialize() */ @Override protected void initialize() { getProject().getPlugins().apply(ProjectConfigPlugin.class); getProject().getPlugins().apply(JavaPlugin.class); getProject().getConfigurations().create("annotate", c -> { c.setDescription("Modules annotated by this project."); c.setVisible(true); c.setTransitive(false); }); } }