Java Code Examples for org.gradle.api.project#getConfigurations()
The following examples show how to use
org.gradle.api.project#getConfigurations() .
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: JettyServerBuilder.java From putnami-gradle-plugin with GNU Lesser General Public License v3.0 | 6 votes |
public void configure(Project project, JettyOption jettyOption, File jettyConf) { ConfigurationContainer configs = project.getConfigurations(); Configuration runtimeConf = configs.getByName(WarPlugin.PROVIDED_RUNTIME_CONFIGURATION_NAME); Configuration jettyClassPath = configs.getByName(PwtLibPlugin.CONF_JETTY); configureJavaArgs(jettyOption); addClassPath(jettyClassPath.getAsPath()); addClassPath(runtimeConf.getAsPath()); if (jettyOption.getLogRequestFile() != null) { ResourceUtils.ensureDir(jettyOption.getLogRequestFile().getParentFile()); addArg("--log", jettyOption.getLogRequestFile()); } if (jettyOption.getLogFile() != null) { ResourceUtils.ensureDir(jettyOption.getLogFile().getParentFile()); addArg("--out", jettyOption.getLogFile()); } addArg("--host", jettyOption.getBindAddress()); addArg("--port", jettyOption.getPort()); addArg("--stop-port", jettyOption.getStopPort()); addArg("--stop-key", jettyOption.getStopKey()); addArg(jettyConf.getAbsolutePath()); }
Example 2
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 3
Source File: PwtPlugin.java From putnami-gradle-plugin with GNU Lesser General Public License v3.0 | 6 votes |
private void createCompileTask(final Project project) { project.getTasks().create(GwtCompileTask.NAME, GwtCompileTask.class); final PutnamiExtension extension = project.getExtensions().getByType(PutnamiExtension.class); final War warTask = project.getTasks().withType(War.class).getByName("war"); warTask.dependsOn(GwtCompileTask.NAME); project.getTasks().withType(GwtCompileTask.class, new Action<GwtCompileTask>() { @Override public void execute(final GwtCompileTask task) { task.configure(project, extension); warTask.from(extension.getCompile().getWar()); } }); ConfigurationContainer configurationContainer = project.getConfigurations(); // Configuration gwtConfig = configurationContainer.getByName(PwtLibPlugin.CONF_GWT_SDM); // FileCollection warClasspath = warTask.getClasspath().minus(gwtConfig); // warTask.setClasspath(warClasspath); }
Example 4
Source File: GolangPluginSupport.java From gradle-golang-plugin with Mozilla Public License 2.0 | 6 votes |
@Override public void apply(Project project) { final ConfigurationContainer configurations = project.getConfigurations(); configurations.maybeCreate("test"); configurations.maybeCreate("build"); configurations.maybeCreate("tool"); final ExtensionContainer extensions = project.getExtensions(); final ExtensionAware golang = (ExtensionAware) extensions.create("golang", GolangSettings.class, true, project); golang.getExtensions().create("build", BuildSettings.class, true, project); golang.getExtensions().create("toolchain", ToolchainSettings.class, true, project); golang.getExtensions().create("dependencies", DependenciesSettings.class, true, project); golang.getExtensions().create("testing", TestingSettings.class, true, project); extensions.create(INSTANCE_PROPERTY_NAME, Reference.class, this); final TaskContainer tasks = project.getTasks(); addTasks(tasks); }
Example 5
Source File: BasePlugin.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
private void configureConfigurations(final Project project) { ConfigurationContainer configurations = project.getConfigurations(); project.setProperty("status", "integration"); Configuration archivesConfiguration = configurations.create(Dependency.ARCHIVES_CONFIGURATION). setDescription("Configuration for archive artifacts."); configurations.create(Dependency.DEFAULT_CONFIGURATION). setDescription("Configuration for default artifacts."); final DefaultArtifactPublicationSet defaultArtifacts = project.getExtensions().create( "defaultArtifacts", DefaultArtifactPublicationSet.class, archivesConfiguration.getArtifacts() ); configurations.all(new Action<Configuration>() { public void execute(Configuration configuration) { configuration.getArtifacts().all(new Action<PublishArtifact>() { public void execute(PublishArtifact artifact) { defaultArtifacts.addCandidate(artifact); } }); } }); }
Example 6
Source File: BasePlugin.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
private void configureConfigurations(final Project project) { ConfigurationContainer configurations = project.getConfigurations(); project.setProperty("status", "integration"); Configuration archivesConfiguration = configurations.create(Dependency.ARCHIVES_CONFIGURATION). setDescription("Configuration for archive artifacts."); configurations.create(Dependency.DEFAULT_CONFIGURATION). setDescription("Configuration for default artifacts."); final DefaultArtifactPublicationSet defaultArtifacts = project.getExtensions().create( "defaultArtifacts", DefaultArtifactPublicationSet.class, archivesConfiguration.getArtifacts() ); configurations.all(new Action<Configuration>() { public void execute(Configuration configuration) { configuration.getArtifacts().all(new Action<PublishArtifact>() { public void execute(PublishArtifact artifact) { defaultArtifacts.addCandidate(artifact); } }); } }); }
Example 7
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 8
Source File: EarPlugin.java From pushfish-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 9
Source File: JavaPlugin.java From Pushjet-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 10
Source File: BaseComponentModelPlugin.java From javaide with GNU General Public License v3.0 | 5 votes |
/** * Replace BasePlugin's apply method for component model. */ @Override public void apply(Project project) { try { List<Recorder.Property> propertyList = Lists.newArrayList( new Recorder.Property("plugin_version", Version.ANDROID_GRADLE_PLUGIN_VERSION), new Recorder.Property("next_gen_plugin", "true"), new Recorder.Property("gradle_version", project.getGradle().getGradleVersion()) ); ProcessRecorderFactory.initialize( new LoggerWrapper(project.getLogger()), project.getRootProject() .file("profiler" + System.currentTimeMillis() + ".json"), propertyList); } catch (IOException e) { throw new RuntimeException("Unable to initialize ProcessRecorderFactory"); } project.getPlugins().apply(JavaBasePlugin.class); // TODO: Create configurations for build types and flavors, or migrate to new dependency // management if it's ready. ConfigurationContainer configurations = project.getConfigurations(); createConfiguration(configurations, "compile", "Classpath for default sources."); createConfiguration(configurations, "default-metadata", "Metadata for published APKs"); createConfiguration(configurations, "default-mapping", "Metadata for published APKs"); }
Example 11
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 12
Source File: DependencyHandler.java From gradle-golang-plugin with Mozilla Public License 2.0 | 5 votes |
@Nonnull protected Collection<GolangDependency> allProjectDependencies() { final Collection<GolangDependency> result = new LinkedHashSet<>(); final Project project = _settings.getProject(); for (final Configuration configuration : project.getConfigurations()) { appendDependenciesOf(configuration, result); } return result; }
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: EarPlugin.java From pushfish-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 15
Source File: CMakeLibraryPlugin.java From native-samples with Apache License 2.0 | 4 votes |
public void apply(final Project project) { project.getPluginManager().apply("org.gradle.samples.wrapped-native-library"); // Add a CMake extension to the Gradle model final CMakeExtension extension = project.getExtensions().create("cmake", CMakeExtension.class, project.getLayout(), project.getObjects()); /* * Create some tasks to drive the CMake build */ TaskContainer tasks = project.getTasks(); final TaskProvider<CMake> cmakeDebug = tasks.register("cmakeDebug", CMake.class, task -> { task.setBuildType("Debug"); task.getIncludeDirs().from(project.getConfigurations().getByName("cppCompile")); task.getLinkFiles().from(project.getConfigurations().getByName("cppLinkDebug")); task.getVariantDirectory().set(project.getLayout().getBuildDirectory().dir("debug")); task.getProjectDirectory().set(extension.getProjectDirectory()); }); final TaskProvider<CMake> cmakeRelease = tasks.register("cmakeRelease", CMake.class, task -> { task.setBuildType("RelWithDebInfo"); task.getIncludeDirs().from(project.getConfigurations().getByName("cppCompile")); task.getLinkFiles().from(project.getConfigurations().getByName("cppLinkRelease")); task.getVariantDirectory().set(project.getLayout().getBuildDirectory().dir("release")); task.getProjectDirectory().set(extension.getProjectDirectory()); }); final TaskProvider<Make> assembleDebug = tasks.register("assembleDebug", Make.class, task -> { task.setGroup("Build"); task.setDescription("Builds the debug binaries"); task.generatedBy(cmakeDebug); task.binary(extension.getBinary()); }); TaskProvider<Make> assembleRelease = tasks.register("assembleRelease", Make.class, task -> { task.setGroup("Build"); task.setDescription("Builds the release binaries"); task.generatedBy(cmakeRelease); task.binary(extension.getBinary()); }); tasks.named("assemble", task -> task.dependsOn(assembleDebug)); /* * Configure the artifacts which should be exposed by this build * to other Gradle projects. (Note that this build does not currently * expose any runtime (shared library) artifacts) */ ConfigurationContainer configurations = project.getConfigurations(); configurations.getByName("headers").getOutgoing().artifact(extension.getIncludeDirectory()); configurations.getByName("linkDebug").getOutgoing().artifact(assembleDebug.flatMap(it -> it.getBinary())); configurations.getByName("linkRelease").getOutgoing().artifact(assembleRelease.flatMap(it -> it.getBinary())); }
Example 16
Source File: CMakeLibraryPlugin.java From native-samples with Apache License 2.0 | 4 votes |
public void apply(final Project project) { project.getPluginManager().apply("org.gradle.samples.wrapped-native-library"); // Add a CMake extension to the Gradle model final CMakeExtension extension = project.getExtensions().create("cmake", CMakeExtension.class, project.getLayout(), project.getObjects()); /* * Create some tasks to drive the CMake build */ TaskContainer tasks = project.getTasks(); final TaskProvider<CMake> cmakeDebug = tasks.register("cmakeDebug", CMake.class, task -> { task.setBuildType("Debug"); task.getIncludeDirs().from(project.getConfigurations().getByName("cppCompile")); task.getLinkFiles().from(project.getConfigurations().getByName("cppLinkDebug")); task.getVariantDirectory().set(project.getLayout().getBuildDirectory().dir("debug")); task.getProjectDirectory().set(extension.getProjectDirectory()); }); final TaskProvider<CMake> cmakeRelease = tasks.register("cmakeRelease", CMake.class, task -> { task.setBuildType("RelWithDebInfo"); task.getIncludeDirs().from(project.getConfigurations().getByName("cppCompile")); task.getLinkFiles().from(project.getConfigurations().getByName("cppLinkRelease")); task.getVariantDirectory().set(project.getLayout().getBuildDirectory().dir("release")); task.getProjectDirectory().set(extension.getProjectDirectory()); }); final TaskProvider<Make> assembleDebug = tasks.register("assembleDebug", Make.class, task -> { task.setGroup("Build"); task.setDescription("Builds the debug binaries"); task.generatedBy(cmakeDebug); task.binary(extension.getBinary()); }); TaskProvider<Make> assembleRelease = tasks.register("assembleRelease", Make.class, task -> { task.setGroup("Build"); task.setDescription("Builds the release binaries"); task.generatedBy(cmakeRelease); task.binary(extension.getBinary()); }); tasks.named("assemble", task -> task.dependsOn(assembleDebug)); /* * Configure the artifacts which should be exposed by this build * to other Gradle projects. (Note that this build does not currently * expose any runtime (shared library) artifacts) */ ConfigurationContainer configurations = project.getConfigurations(); configurations.getByName("headers").getOutgoing().artifact(extension.getIncludeDirectory()); configurations.getByName("linkDebug").getOutgoing().artifact(assembleDebug.flatMap(it -> it.getBinary())); configurations.getByName("linkRelease").getOutgoing().artifact(assembleRelease.flatMap(it -> it.getBinary())); }
Example 17
Source File: CMakeLibraryPlugin.java From native-samples with Apache License 2.0 | 4 votes |
public void apply(final Project project) { project.getPluginManager().apply("org.gradle.samples.wrapped-native-library"); // Add a CMake extension to the Gradle model final CMakeExtension extension = project.getExtensions().create("cmake", CMakeExtension.class, project.getLayout(), project.getObjects()); /* * Create some tasks to drive the CMake build */ TaskContainer tasks = project.getTasks(); final TaskProvider<CMake> cmakeDebug = tasks.register("cmakeDebug", CMake.class, task -> { task.setBuildType("Debug"); task.getIncludeDirs().from(project.getConfigurations().getByName("cppCompile")); task.getLinkFiles().from(project.getConfigurations().getByName("cppLinkDebug")); task.getVariantDirectory().set(project.getLayout().getBuildDirectory().dir("debug")); task.getProjectDirectory().set(extension.getProjectDirectory()); }); final TaskProvider<CMake> cmakeRelease = tasks.register("cmakeRelease", CMake.class, task -> { task.setBuildType("RelWithDebInfo"); task.getIncludeDirs().from(project.getConfigurations().getByName("cppCompile")); task.getLinkFiles().from(project.getConfigurations().getByName("cppLinkRelease")); task.getVariantDirectory().set(project.getLayout().getBuildDirectory().dir("release")); task.getProjectDirectory().set(extension.getProjectDirectory()); }); final TaskProvider<Make> assembleDebug = tasks.register("assembleDebug", Make.class, task -> { task.setGroup("Build"); task.setDescription("Builds the debug binaries"); task.generatedBy(cmakeDebug); task.binary(extension.getBinary()); }); TaskProvider<Make> assembleRelease = tasks.register("assembleRelease", Make.class, task -> { task.setGroup("Build"); task.setDescription("Builds the release binaries"); task.generatedBy(cmakeRelease); task.binary(extension.getBinary()); }); tasks.named("assemble", task -> task.dependsOn(assembleDebug)); /* * Configure the artifacts which should be exposed by this build * to other Gradle projects. (Note that this build does not currently * expose any runtime (shared library) artifacts) */ ConfigurationContainer configurations = project.getConfigurations(); configurations.getByName("headers").getOutgoing().artifact(extension.getIncludeDirectory()); configurations.getByName("linkDebug").getOutgoing().artifact(assembleDebug.flatMap(it -> it.getBinary())); configurations.getByName("linkRelease").getOutgoing().artifact(assembleRelease.flatMap(it -> it.getBinary())); }
Example 18
Source File: PwtLibPlugin.java From putnami-gradle-plugin with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void apply(Project project) { project.getPlugins().apply(JavaPlugin.class); project.getPlugins().apply(MavenPlugin.class); final PutnamiExtension extention = project.getExtensions().create(PutnamiExtension.PWT_EXTENSION, PutnamiExtension.class); ConfigurationContainer configurationContainer = project.getConfigurations(); Configuration gwtConfig = configurationContainer.create(CONF_GWT_SDM).setVisible(false); configurationContainer.create(CONF_JETTY).setVisible(false); includeSourcesToJar(project); project.afterEvaluate(new Action<Project>() { @Override public void execute(final Project p) { String gwtVersion = extention.getGwtVersion(); String jettyVersion = extention.getJettyVersion(); DependencyHandler dependencies = p.getDependencies(); dependencies.add(CONF_GWT_SDM, "com.google.gwt:gwt-codeserver" + ":" + gwtVersion); dependencies.add(CONF_GWT_SDM, "com.google.gwt:gwt-user" + ":" + gwtVersion); dependencies.add(JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME, "com.google.gwt:gwt-codeserver" + ":" + gwtVersion); dependencies.add(JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME, "com.google.gwt:gwt-user" + ":" + gwtVersion); dependencies.add(JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME, "com.google.gwt:gwt-user" + ":" + gwtVersion); if (extention.isGwtElementalLib()) { dependencies.add( JavaPlugin.IMPLEMENTATION_CONFIGURATION_NAME, "com.google.gwt:gwt-elemental" + ":" + gwtVersion); } if (extention.isGwtServletLib()) { dependencies.add( JavaPlugin.IMPLEMENTATION_CONFIGURATION_NAME, "com.google.gwt:gwt-servlet" + ":" + gwtVersion); } dependencies.add(CONF_JETTY, "org.eclipse.jetty:jetty-runner" + ":" + jettyVersion); includeSourcesForTest(p); } }); initGpe(project); }
Example 19
Source File: DependencyHandler.java From gradle-golang-plugin with Mozilla Public License 2.0 | 4 votes |
protected void appendDependenciesOf(@Nonnull String configurationName, @Nonnull Collection<GolangDependency> to) { final Project project = _settings.getProject(); final ConfigurationContainer configurations = project.getConfigurations(); final Configuration configuration = configurations.getByName(configurationName); appendDependenciesOf(configuration, to); }
Example 20
Source File: CodeServerBuilder.java From putnami-gradle-plugin with GNU Lesser General Public License v3.0 | 4 votes |
public void configure(Project project, DevOption devOption, Collection<String> modules) { ConfigurationContainer configs = project.getConfigurations(); Configuration sdmConf = configs.getByName(PwtLibPlugin.CONF_GWT_SDM); PutnamiExtension putnami = project.getExtensions().getByType(PutnamiExtension.class); SourceSet mainSourceSet = project.getConvention() .getPlugin(JavaPluginConvention.class).getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME); FileCollection sources = project.files(mainSourceSet.getAllJava().getSrcDirs()); configureJavaArgs(devOption); addClassPath(mainSourceSet.getOutput().getAsPath()); addClassPath(mainSourceSet.getAllJava().getSrcDirs()); addClassPath(mainSourceSet.getCompileClasspath().getAsPath()); addClassPath(sdmConf.getAsPath()); addSrc(sources); addSrc(listProjectDepsSrcDirs(project)); addArg("-bindAddress", devOption.getBindAddress()); addArgIf(devOption.getFailOnError(), "-failOnError", "-nofailOnError"); addArgIf(devOption.getPrecompile(), "-precompile", "-noprecompile"); addArg("-port", devOption.getPort()); addArgIf(devOption.getStrict(), "-strict"); addArgIf(devOption.getEnforceStrictResources(), "-XenforceStrictResources ", "-XnoenforceStrictResources"); addArg("-workDir", ResourceUtils.ensureDir(devOption.getWorkDir())); addArgIf(devOption.getIncremental(), "-incremental", "-noincremental"); addArg("-sourceLevel", devOption.getSourceLevel()); if (!putnami.getGwtVersion().startsWith("2.6")) { addArg("-logLevel", devOption.getLogLevel()); } addArg("-XmethodNameDisplayMode", devOption.getMethodNameDisplayMode()); addArg("-XjsInteropMode", devOption.getJsInteropMode()); addArgIf(devOption.getGenerateJsInteropExports(), "-generateJsInteropExports"); if (devOption.getExtraArgs() != null) { for (String arg : devOption.getExtraArgs()) { if (arg != null && arg.length() > 0) { addArg(arg); } } } for (String module : modules) { addArg(module); } }