private void defineConfigurationsForSourceSet(SourceSet sourceSet, ConfigurationContainer configurations) { Configuration compileConfiguration = configurations.maybeCreate(sourceSet.getCompileConfigurationName()); compileConfiguration.setVisible(false); compileConfiguration.setDescription("Dependencies for " + sourceSet + "."); Configuration runtimeConfiguration = configurations.maybeCreate(sourceSet.getRuntimeConfigurationName()); runtimeConfiguration.setVisible(false); runtimeConfiguration.extendsFrom(compileConfiguration); runtimeConfiguration.setDescription("Runtime dependencies for " + sourceSet + "."); Configuration compileOnlyConfiguration = configurations.maybeCreate(sourceSet.getCompileOnlyConfigurationName()); compileOnlyConfiguration.setVisible(false); compileOnlyConfiguration.extendsFrom(compileConfiguration); compileOnlyConfiguration.setDescription("Compile dependencies for " + sourceSet + "."); Configuration compileClasspathConfiguration = configurations.maybeCreate(sourceSet.getCompileClasspathConfigurationName()); compileClasspathConfiguration.setVisible(false); compileClasspathConfiguration.extendsFrom(compileOnlyConfiguration); compileClasspathConfiguration.setDescription("Compile classpath for " + sourceSet + "."); sourceSet.setCompileClasspath(compileClasspathConfiguration); sourceSet.setRuntimeClasspath(sourceSet.getOutput().plus(runtimeConfiguration)); }
@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); }
/** * Configure configurations * * @param configurations Configurations to configure * @param javaConfig Java configuration to apply */ @Mutate public void configureConfigurations(ConfigurationContainer configurations, JavaConfig javaConfig) { configurations.all(c -> { DependencySubstitutions ds = c.getResolutionStrategy().getDependencySubstitution(); ds.substitute(ds.module("ch.qos.logback:logback-classic")) .with(ds.module("org.slf4j:slf4j-api:" + javaConfig.getSlf4jVersion())); ds.substitute(ds.module("commons-logging:commons-logging")) .with(ds.module("org.slf4j:jcl-over-slf4j:" + javaConfig.getSlf4jVersion())); ds.substitute(ds.module("log4j:log4j")) .with(ds.module("org.slf4j:log4j-over-slf4j:" + javaConfig.getSlf4jVersion())); c.exclude(ImmutableMap.of("group", "org.slf4j", "module", "slf4j-log4j12")); c.exclude(ImmutableMap.of("group", "org.slf4j", "module", "slf4j-nop")); c.exclude(ImmutableMap.of("group", "org.slf4j", "module", "slf4j-simple")); c.exclude(ImmutableMap.of("group", "org.slf4j", "module", "slf4j-jcl")); }); }
/** * Initialize the Maven configuration * * @param mavenConfig Maven configuration to initialize * @param projectContext Project context * @param configurations Configuration container */ @Defaults public void initializeMavenConfig(MavenConfig mavenConfig, ProjectContext projectContext, ConfigurationContainer configurations) { mavenConfig.getPublications().create(SourceSet.MAIN_SOURCE_SET_NAME, p -> { p.setArtifactId(projectContext.getName()); p.setArchivesConfiguration(Dependency.ARCHIVES_CONFIGURATION); p.setAddProjectArtifacts(false); p.setCompileConfigurations(Collections.singletonList(JavaPlugin.COMPILE_CONFIGURATION_NAME)); p.setRuntimeConfigurations(Collections.singletonList(JavaPlugin.RUNTIME_CONFIGURATION_NAME)); }); if (configurations.findByName("testArchives") != null) { mavenConfig.getPublications().create(SourceSet.TEST_SOURCE_SET_NAME, p -> { p.setArtifactId(projectContext.getName() + "-" + SourceSet.TEST_SOURCE_SET_NAME); p.setArchivesConfiguration(Names.formatName("", Dependency.ARCHIVES_CONFIGURATION, SourceSet.TEST_SOURCE_SET_NAME)); p.setAddProjectArtifacts(true); p.setCompileConfigurations( Collections.singletonList(JavaPlugin.TEST_COMPILE_CONFIGURATION_NAME)); p.setRuntimeConfigurations( Collections.singletonList(JavaPlugin.TEST_RUNTIME_CONFIGURATION_NAME)); }); } }
/** * Create Eclipse annotations tasks * * @param tasks Task container * @param configurations Container to access configurations * @param buildDir Build directory */ @Mutate public void createEclipseAnnotationsTasks(ModelMap<Task> tasks, ConfigurationContainer configurations, @Path("buildDir") File buildDir) { tasks.create("eclipseAnnotations", EclipseAnnotationsTask.class, t -> { t.setDescription("Generates external nullability annotations for dependencies."); t.setGroup("IDE"); ConventionMapping parameters = t.getConventionMapping(); parameters.map("jars", () -> { Set<File> jars = configurations.stream() .filter(c -> c.isCanBeResolved() && !c.getName().equals(JavaConfigPlugin.ANNOTATIONS_CONFIGURATION)) .map(c -> c.getResolvedConfiguration().getLenientConfiguration()) .flatMap(c -> c.getArtifacts().stream().filter( a -> !(a.getId().getComponentIdentifier() instanceof ProjectComponentIdentifier) && a.getType().equals("jar")) .map(a -> a.getFile())) .collect(Collectors.toSet()); return jars; }); }); }
/** * @param eclipseClasspath * @param eclipseConfigPlugin * @param configurations */ @Finalize public void finalizeEclipseClasspathTask(@Each GenerateEclipseClasspath eclipseClasspath, EclipseConfigPlugin eclipseConfigPlugin, ConfigurationContainer configurations) { EclipseClasspath classpath = eclipseClasspath.getClasspath(); Configuration integrationCompileConfiguration = configurations.getAsMap() .get(JavaConfigPlugin.INTEGRATION_COMPILE_CLASSPATH_CONFIGURATION); if (integrationCompileConfiguration != null) { classpath.getPlusConfigurations().add(integrationCompileConfiguration); } Configuration integrationRuntimeConfiguration = configurations.getAsMap() .get(JavaConfigPlugin.INTEGRATION_RUNTIME_CLASSPATH_CONFIGURATION); if (integrationRuntimeConfiguration != null) { classpath.getPlusConfigurations().add(integrationRuntimeConfiguration); } classpath.getFile().whenMerged((Classpath c) -> { c.getEntries().removeIf(e -> (e instanceof Library) && Files.getFileExtension(((Library) e).getPath()).equalsIgnoreCase("pom")); }); }
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); }
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; }
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()); }
/** * Setup the the 'providedCompile' and 'providedRuntime' configurations, just like War. * TODO See if we can recursively get all the dependent projects and apply it to them too. * But it would have to be a future action. */ public static void configureProvidedConfigurations(final Project project) { ConfigurationContainer configurationContainer = project.getConfigurations(); Configuration provideCompileConfiguration = configurationContainer.findByName(WarPlugin.PROVIDED_COMPILE_CONFIGURATION_NAME); if (provideCompileConfiguration==null) { provideCompileConfiguration = configurationContainer.create(WarPlugin.PROVIDED_COMPILE_CONFIGURATION_NAME) .setVisible(false) .setDescription("Additional compile classpath for libraries that should not be part of the archive."); configurationContainer.getByName(JavaPlugin.COMPILE_CONFIGURATION_NAME).extendsFrom(provideCompileConfiguration); } Configuration provideRuntimeConfiguration = configurationContainer.findByName(WarPlugin.PROVIDED_RUNTIME_CONFIGURATION_NAME); if (provideRuntimeConfiguration==null) { provideRuntimeConfiguration = configurationContainer.create(WarPlugin.PROVIDED_RUNTIME_CONFIGURATION_NAME) .setVisible(false) .extendsFrom(provideCompileConfiguration) .setDescription("Additional runtime classpath for libraries that should not be part of the archive."); configurationContainer.getByName(JavaPlugin.RUNTIME_CONFIGURATION_NAME).extendsFrom(provideRuntimeConfiguration); } }
@TaskAction public void before() { final JMHPluginExtension extension = getProject().getExtensions().getByType(JMHPluginExtension.class); extension.resolveArgs(); final ExtensionOptions options = new ExtensionOptions(extension); extension.getResultsFile().getParentFile().mkdirs(); workerExecutor.submit(IsolatedRunner.class, new Action<WorkerConfiguration>() { @Override public void execute(final WorkerConfiguration workerConfiguration) { workerConfiguration.setIsolationMode(IsolationMode.PROCESS); ConfigurationContainer configurations = getProject().getConfigurations(); FileCollection classpath = configurations.getByName("jmh").plus(getProject().files(getJarArchive())); if (extension.isIncludeTests()) { classpath = classpath.plus(configurations.getByName("testRuntimeClasspath")); } workerConfiguration.classpath(classpath); workerConfiguration.params(options.asSerializable()); workerConfiguration.getForkOptions().getSystemProperties().put(JAVA_IO_TMPDIR, getTemporaryDir()); } }); }
public void establishSonarQubeSourceSet() { final JavaPluginConvention javaConvention = project.getConvention().getPlugin(JavaPluginConvention.class); final SourceSetContainer sourceSets = javaConvention.getSourceSets(); final ConfigurationContainer configs = project.getConfigurations(); final SourceSet testSourceSet = sourceSets.getByName(SourceSet.TEST_SOURCE_SET_NAME); final SourceSet sqSourceSet = sourceSets.create(BuildUtil.SONARQUBE_SOURCE_SET_NAME); configs.getByName(testSourceSet.getImplementationConfigurationName()).extendsFrom( configs.getByName(sqSourceSet.getImplementationConfigurationName())); configs.getByName(testSourceSet.getRuntimeOnlyConfigurationName()).extendsFrom( configs.getByName(sqSourceSet.getRuntimeOnlyConfigurationName())); final TaskContainer tasks = project.getTasks(); tasks.getByName(JavaPlugin.COMPILE_TEST_JAVA_TASK_NAME).dependsOn( tasks.getByName(sqSourceSet.getClassesTaskName())); final FileCollection sqOutputs = sqSourceSet.getOutput().getClassesDirs().plus( project.files(sqSourceSet.getOutput().getResourcesDir())); testSourceSet.setCompileClasspath(testSourceSet.getCompileClasspath().plus(sqOutputs)); testSourceSet.setRuntimeClasspath(testSourceSet.getRuntimeClasspath().plus(sqOutputs)); }
public DefaultMavenPomFactory(ConfigurationContainer configurationContainer, Conf2ScopeMappingContainer conf2ScopeMappingContainer, PomDependenciesConverter pomDependenciesConverter, FileResolver fileResolver) { this.configurationContainer = configurationContainer; this.conf2ScopeMappingContainer = conf2ScopeMappingContainer; this.pomDependenciesConverter = pomDependenciesConverter; this.fileResolver = fileResolver; }
public DefaultMavenPom(ConfigurationContainer configurationContainer, Conf2ScopeMappingContainer scopeMappings, PomDependenciesConverter pomDependenciesConverter, PathToFileResolver fileResolver) { this.configurations = configurationContainer; this.scopeMappings = scopeMappings; this.pomDependenciesConverter = pomDependenciesConverter; this.fileResolver = fileResolver; model.setModelVersion("4.0.0"); }
public DefaultDeployerFactory(MavenFactory mavenFactory, Factory<LoggingManagerInternal> loggingManagerFactory, FileResolver fileResolver, MavenPomMetaInfoProvider pomMetaInfoProvider, ConfigurationContainer configurationContainer, Conf2ScopeMappingContainer scopeMapping, MavenSettingsProvider mavenSettingsProvider, LocalMavenRepositoryLocator mavenRepositoryLocator) { this.mavenFactory = mavenFactory; this.loggingManagerFactory = loggingManagerFactory; this.fileResolver = fileResolver; this.pomMetaInfoProvider = pomMetaInfoProvider; this.configurationContainer = configurationContainer; this.scopeMapping = scopeMapping; this.mavenSettingsProvider = mavenSettingsProvider; this.mavenRepositoryLocator = mavenRepositoryLocator; }
private void configureJavaScopeMappings(ConfigurationContainer configurations, Conf2ScopeMappingContainer mavenScopeMappings) { mavenScopeMappings.addMapping(COMPILE_PRIORITY, configurations.getByName(JavaPlugin.COMPILE_CONFIGURATION_NAME), Conf2ScopeMappingContainer.COMPILE); mavenScopeMappings.addMapping(RUNTIME_PRIORITY, configurations.getByName(JavaPlugin.RUNTIME_CONFIGURATION_NAME), Conf2ScopeMappingContainer.RUNTIME); mavenScopeMappings.addMapping(TEST_COMPILE_PRIORITY, configurations.getByName(JavaPlugin.TEST_COMPILE_CONFIGURATION_NAME), Conf2ScopeMappingContainer.TEST); mavenScopeMappings.addMapping(TEST_RUNTIME_PRIORITY, configurations.getByName(JavaPlugin.TEST_RUNTIME_CONFIGURATION_NAME), Conf2ScopeMappingContainer.TEST); }
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); }
public Configuration addConfiguration(ConfigurationContainer configurations, final DependencyHandler dependencies, final JsHintExtension extension) { Configuration configuration = configurations.create(JsHintExtension.CONFIGURATION_NAME); configuration.defaultDependencies(new Action<DependencySet>() { @Override public void execute(DependencySet configDependencies) { String notation = JsHintExtension.DEFAULT_DEPENDENCY_GROUP + ":" + JsHintExtension.DEFAULT_DEPENDENCY_MODULE + ":" + extension.getVersion() + "@js"; Dependency dependency = dependencies.create(notation); configDependencies.add(dependency); } }); return configuration; }
public Configuration addConfiguration(ConfigurationContainer configurations, final DependencyHandler dependencies, final EnvJsExtension extension) { Configuration configuration = configurations.create(EnvJsExtension.CONFIGURATION_NAME); configuration.defaultDependencies(new Action<DependencySet>() { @Override public void execute(DependencySet configDependencies) { String notation = EnvJsExtension.DEFAULT_DEPENDENCY_GROUP + ":" + EnvJsExtension.DEFAULT_DEPENDENCY_MODULE + ":" + extension.getVersion() + "@js"; Dependency dependency = dependencies.create(notation); configDependencies.add(dependency); } }); return configuration; }
private Configuration addJsConfiguration(ConfigurationContainer configurations, final DependencyHandler dependencies, final CoffeeScriptExtension extension) { Configuration configuration = configurations.create(CoffeeScriptExtension.JS_CONFIGURATION_NAME); configuration.defaultDependencies(new Action<DependencySet>() { @Override public void execute(DependencySet configDependencies) { String notation = CoffeeScriptExtension.DEFAULT_JS_DEPENDENCY_GROUP + ":" + CoffeeScriptExtension.DEFAULT_JS_DEPENDENCY_MODULE + ":" + extension.getVersion() + "@js"; Dependency dependency = dependencies.create(notation); configDependencies.add(dependency); } }); return configuration; }
private boolean exists(PluginRequest request) { // This works because the corresponding BackedByArtifactRepository PluginRepository sets // registers an ArtifactRepository in the DependencyResolutionServices instance which is // exclusively used by this ArtifactRepositoryPluginResolver. If the plugin marker // doesn't exist in that isolated ArtifactRepository, this resolver won't look anywhere else. Dependency dependency = resolution.getDependencyHandler().create(getMarkerCoordinates(request)); ConfigurationContainer configurations = resolution.getConfigurationContainer(); Configuration configuration = configurations.detachedConfiguration(dependency); configuration.setTransitive(false); return !configuration.getResolvedConfiguration().hasError(); }
public DownloadingScalaToolChain(File gradleUserHomeDir, File rootProjectDir, WorkerDaemonManager compilerDaemonManager, ConfigurationContainer configurationContainer, DependencyHandler dependencyHandler) { this.gradleUserHomeDir = gradleUserHomeDir; this.rootProjectDir = rootProjectDir; this.compilerDaemonManager = compilerDaemonManager; this.configurationContainer = configurationContainer; this.dependencyHandler = dependencyHandler; this.javaVersion = JavaVersion.current(); }
public DefaultDependencyHandler(ConfigurationContainer configurationContainer, DependencyFactory dependencyFactory, ProjectFinder projectFinder, ComponentMetadataHandler componentMetadataHandler, ComponentModuleMetadataHandler componentModuleMetadataHandler, ArtifactResolutionQueryFactory resolutionQueryFactory) { this.configurationContainer = configurationContainer; this.dependencyFactory = dependencyFactory; this.projectFinder = projectFinder; this.componentMetadataHandler = componentMetadataHandler; this.componentModuleMetadataHandler = componentModuleMetadataHandler; this.resolutionQueryFactory = resolutionQueryFactory; }
@Override public Configuration findProjectConfiguration() { ConfigurationContainer dependencyConfigurations = getDependencyProject().getConfigurations(); String declaredConfiguration = getTargetConfiguration(); Configuration selectedConfiguration = dependencyConfigurations.getByName(GUtil.elvis(declaredConfiguration, Dependency.DEFAULT_CONFIGURATION)); if (!selectedConfiguration.isCanBeConsumed()) { throw new ConfigurationNotConsumableException(dependencyProject.getDisplayName(), selectedConfiguration.getName()); } return selectedConfiguration; }
private Map<String, Map<String, Collection<Configuration>>> buildScopes(ConfigurationContainer configurations) { return ImmutableMap.<String, Map<String, Collection<Configuration>>>builder(). put("PROVIDED", buildScope()). put("COMPILE", buildScope(configurations.getByName(PlayPluginConfigurations.COMPILE_CONFIGURATION))). put("RUNTIME", buildScope(configurations.getByName(PlayPluginConfigurations.RUN_CONFIGURATION))). put("TEST", buildScope(configurations.getByName(PlayPluginConfigurations.TEST_COMPILE_CONFIGURATION))). build(); }
public DefaultPlayToolChain(FileResolver fileResolver, WorkerDaemonManager compilerDaemonManager, ConfigurationContainer configurationContainer, DependencyHandler dependencyHandler, WorkerProcessFactory workerProcessBuilderFactory) { this.fileResolver = fileResolver; this.compilerDaemonManager = compilerDaemonManager; this.configurationContainer = configurationContainer; this.dependencyHandler = dependencyHandler; this.workerProcessBuilderFactory = workerProcessBuilderFactory; }
/** * Provides the configuration that signature artifacts are added to. Called once during construction. */ protected Configuration getDefaultConfiguration() { ConfigurationContainer configurations = project.getConfigurations(); Configuration configuration = configurations.findByName(DEFAULT_CONFIGURATION_NAME); return configuration != null ? configuration : configurations.create(DEFAULT_CONFIGURATION_NAME); }
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); }
public void configureConfigurations(ConfigurationContainer configurationContainer) { Configuration provideCompileConfiguration = configurationContainer.create(PROVIDED_COMPILE_CONFIGURATION_NAME).setVisible(false). setDescription("Additional compile classpath for libraries that should not be part of the WAR archive."); Configuration provideRuntimeConfiguration = configurationContainer.create(PROVIDED_RUNTIME_CONFIGURATION_NAME).setVisible(false). extendsFrom(provideCompileConfiguration). setDescription("Additional runtime classpath for libraries that should not be part of the WAR archive."); configurationContainer.getByName(JavaPlugin.COMPILE_CONFIGURATION_NAME).extendsFrom(provideCompileConfiguration); configurationContainer.getByName(JavaPlugin.RUNTIME_CONFIGURATION_NAME).extendsFrom(provideRuntimeConfiguration); }
private BridgedBinaries configureSourceSetDefaults(final JavaPluginConvention pluginConvention) { final Project project = pluginConvention.getProject(); final List<ClassDirectoryBinarySpecInternal> binaries = Lists.newArrayList(); pluginConvention.getSourceSets().all(new Action<SourceSet>() { public void execute(final SourceSet sourceSet) { ConventionMapping outputConventionMapping = ((IConventionAware) sourceSet.getOutput()).getConventionMapping(); ConfigurationContainer configurations = project.getConfigurations(); defineConfigurationsForSourceSet(sourceSet, configurations); definePathsForSourceSet(sourceSet, outputConventionMapping, project); createProcessResourcesTaskForBinary(sourceSet, sourceSet.getResources(), project); createCompileJavaTaskForBinary(sourceSet, sourceSet.getJava(), project); createBinaryLifecycleTask(sourceSet, project); DefaultComponentSpecIdentifier binaryId = new DefaultComponentSpecIdentifier(project.getPath(), sourceSet.getName()); ClassDirectoryBinarySpecInternal binary = instantiator.newInstance(DefaultClassDirectoryBinarySpec.class, binaryId, sourceSet, javaToolChain, DefaultJavaPlatform.current(), instantiator, taskFactory); Classpath compileClasspath = new SourceSetCompileClasspath(sourceSet); DefaultJavaSourceSet javaSourceSet = instantiator.newInstance(DefaultJavaSourceSet.class, binaryId.child("java"), sourceSet.getJava(), compileClasspath); JvmResourceSet resourceSet = instantiator.newInstance(DefaultJvmResourceSet.class, binaryId.child("resources"), sourceSet.getResources()); binary.addSourceSet(javaSourceSet); binary.addSourceSet(resourceSet); attachTasksToBinary(binary, sourceSet, project); binaries.add(binary); } }); return new BridgedBinaries(binaries); }
public Set<File> getProjectLibraries() { Set<File> classpath = new HashSet<>(); SourceSetContainer sourceSets = (SourceSetContainer) project.getProperties().get("sourceSets"); if (sourceSets != null) { SortedSet<String> availableSourceSetNames = sourceSets.getNames(); for (String sourceSetName : Arrays.asList("main", "test", "integrationTest")) { if (availableSourceSetNames.contains(sourceSetName)) { SourceSet sourceSet = sourceSets.getByName(sourceSetName); classpath.add(sourceSet.getOutput().getClassesDir()); } } } // add dependencies from configured gradle configuration to url (usually test or integrationTest) TSGeneratorConfig generatorConfiguration = project.getExtensions().getByType(TSGeneratorConfig.class); String configurationName = generatorConfiguration.getRuntime().getConfiguration(); ConfigurationContainer configurations = project.getConfigurations(); Configuration runtimeConfiguration = configurations.findByName(configurationName + "Runtime"); if (runtimeConfiguration == null) { runtimeConfiguration = configurations.getByName(configurationName); } classpath.addAll(runtimeConfiguration.getFiles()); for (File file : classpath) { LOGGER.debug("classpath entry: {}", file); } return classpath; }
/** * Replace BasePlugin's apply method for component model. */ @Override public void apply(Project project) { ExecutionConfigurationUtil.setThreadPoolSize(project); try { ProcessRecorderFactory.initialize( new LoggerWrapper(project.getLogger()), project.getRootProject() .file("profiler" + System.currentTimeMillis() + ".json")); } catch (IOException e) { throw new RuntimeException("Unable to initialize ProcessRecorderFactory"); } project.getGradle().addListener(new RecordingBuildListener(ThreadRecorder.get())); project.getPlugins().apply(AndroidComponentModelPlugin.class); project.getPlugins().apply(JavaBasePlugin.class); project.getPlugins().apply(JacocoPlugin.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"); project.getPlugins().apply(NdkComponentModelPlugin.class); // Remove this when our models no longer depends on Project. modelRegistry.create(ModelCreators .bridgedInstance(ModelReference.of("projectModel", Project.class), project) .descriptor("Model of project.").build()); toolingRegistry.register(new ComponentModelBuilder(modelRegistry)); // Inserting the ToolingModelBuilderRegistry into the model so that it can be use to create // TaskManager in child classes. modelRegistry.create(ModelCreators.bridgedInstance( ModelReference.of("toolingRegistry", ToolingModelBuilderRegistry.class), toolingRegistry).descriptor("Tooling model builder model registry.").build()); }
private static void createConfiguration(@NonNull ConfigurationContainer configurations, @NonNull String configurationName, @NonNull String configurationDescription) { Configuration configuration = configurations.findByName(configurationName); if (configuration == null) { configuration = configurations.create(configurationName); } configuration.setVisible(false); configuration.setDescription(configurationDescription); }
private static void createConfiguration( @NonNull ConfigurationContainer configurations, @NonNull String configurationName, @NonNull String configurationDescription) { Configuration configuration = configurations.findByName(configurationName); if (configuration == null) { configuration = configurations.create(configurationName); } // Disable modification to configurations as this causes issues when accessed through the // tooling-api. Check that it works with Studio's ImportProjectAction before re-enabling // them. //configuration.setVisible(false); //configuration.setDescription(configurationDescription); }
public DefaultDeployerFactory(MavenFactory mavenFactory, Factory<LoggingManagerInternal> loggingManagerFactory, FileResolver fileResolver, MavenPomMetaInfoProvider pomMetaInfoProvider, ConfigurationContainer configurationContainer, Conf2ScopeMappingContainer scopeMapping) { this.mavenFactory = mavenFactory; this.loggingManagerFactory = loggingManagerFactory; this.fileResolver = fileResolver; this.pomMetaInfoProvider = pomMetaInfoProvider; this.configurationContainer = configurationContainer; this.scopeMapping = scopeMapping; }
public DefaultMavenPom(ConfigurationContainer configurationContainer, Conf2ScopeMappingContainer scopeMappings, PomDependenciesConverter pomDependenciesConverter, FileResolver fileResolver) { this.configurations = configurationContainer; this.scopeMappings = scopeMappings; this.pomDependenciesConverter = pomDependenciesConverter; this.fileResolver = fileResolver; mavenProject.setModelVersion("4.0.0"); }
public ScriptHandler create(ScriptSource scriptSource, ClassLoaderScope classLoaderScope, DomainObjectContext context) { DependencyResolutionServices services = dependencyManagementServices.create(fileResolver, dependencyMetaDataProvider, projectFinder, context); RepositoryHandler repositoryHandler = services.getResolveRepositoryHandler(); ConfigurationContainer configurationContainer = services.getConfigurationContainer(); DependencyHandler dependencyHandler = services.getDependencyHandler(); return new DefaultScriptHandler(scriptSource, repositoryHandler, dependencyHandler, configurationContainer, new ScriptHandlerClassLoaderFactory(scriptSource, classLoaderScope)); }