public Set<File> classpath() { SourceSet sourceSet = sourceSet(project); // conf & public Set<File> cp = new LinkedHashSet<>(sourceSet.getResources().getSrcDirs()); // classes/main, resources/main + jars cp.addAll(sourceSet.getRuntimeClasspath().getFiles()); // provided? Configuration provided = project.getConfigurations().findByName("provided"); if (provided != null) { cp.addAll(provided.getFiles()); } return cp; }
private URL[] getClassPath() throws MalformedURLException { List<URL> urls = new ArrayList<>(); urls.add(this.getCompiledClassesDir().toURL()); for (File eachFile : this.getProject().getConfigurations().findByName("compile").getFiles()) { urls.add(eachFile.toURI().toURL()); } return urls.toArray(new URL[urls.size()]); }
private URL[] getClassPath() throws MalformedURLException { List<URL> urls = new ArrayList<>(); urls.add(this.getCompiledClassesDir().toURL()); for (File eachFile : this.getProject().getConfigurations().findByName("compile").getFiles()) { urls.add(eachFile.toURI().toURL()); } return urls.toArray(new URL[urls.size()]); }
private void addArtifacts(Provider<File> artifact, String... configurationNames) { for (String configurationName : configurationNames) { final Configuration configuration = project.getConfigurations().findByName(configurationName); if (configuration != null) { ConfigurationUtils.getEtaConfiguration(configuration).getArtifacts() .add(artifact); } } }
private void addArtifacts(Provider<File> artifact, String... configurationNames) { for (String configurationName : configurationNames) { final Configuration configuration = project.getConfigurations().findByName(configurationName); if (configuration != null) { ConfigurationUtils.getEtaConfiguration(configuration).getArtifacts() .add(artifact); } } }
@Nullable public Object methodMissing(@Nonnull String name, @Nullable Object args) { final Object[] argsArray = (Object[]) args; final Configuration configuration = _project.getConfigurations().findByName(name); if (configuration == null) { throw new MissingMethodException(name, this.getClass(), argsArray); } final List<?> normalizedArgs = CollectionUtils.flattenCollections(argsArray); if (normalizedArgs.size() == 2 && normalizedArgs.get(1) instanceof Closure) { //noinspection rawtypes return doAdd(name, normalizedArgs.get(0), (Closure) normalizedArgs.get(1)); } else if (normalizedArgs.size() == 1) { return doAdd(name, normalizedArgs.get(0), null); } else { for (final Object arg : normalizedArgs) { doAdd(name, arg, null); } return null; } } }
/** * Obtains the classloader from a set of file paths. * * @return the classloader, not null */ private ClassLoader obtainClassLoader() { final List<URL> compileClasspath = new ArrayList<>(); for (final String configName : CONFIGURATIONS_TO_SEARCH) { final Configuration config = getProject().getConfigurations().findByName(configName); if (config != null && config.isCanBeResolved()) { for (final File classpathFile : config.getFiles()) { try { compileClasspath.add(classpathFile.toURI().toURL()); } catch (final MalformedURLException e) { getLogger().debug( "Skipping " + classpathFile.getAbsolutePath() + " from the compile classpath."); } } } } return new URLClassLoader(compileClasspath.toArray(new URL[compileClasspath.size()]), AbstractJodaBeansTask.class.getClassLoader()); }
private Set<GradleLibrary> getLibraries(String configurationName, LibraryScope scope) { Configuration configuration = (configurationName == null ? null : this.project.getConfigurations().findByName(configurationName)); if (configuration == null) { return null; } Set<GradleLibrary> libraries = new LinkedHashSet<GradleLibrary>(); for (ResolvedArtifact artifact : configuration.getResolvedConfiguration().getResolvedArtifacts()) { libraries.add(new ResolvedArtifactLibrary(artifact, scope)); } libraries.addAll(getLibrariesForFileDependencies(configuration, scope)); return libraries; }
protected Configuration getOrCreateConfiguration(String name) { Configuration configuration = project.getConfigurations().findByName( name ); if ( configuration == null ) { configuration = project.getConfigurations().create( name ); } return configuration; } }
protected Configuration getOrCreateConfiguration(String name) { Configuration configuration = project.getConfigurations().findByName( name ); if ( configuration == null ) { configuration = project.getConfigurations().create( name ); } return configuration; } }
private void clearJavaFXDependencies() { var implementationConfiguration = project.getConfigurations().findByName("implementation"); if (implementationConfiguration != null) { implementationConfiguration.getDependencies() .removeIf(dependency -> MAVEN_JAVAFX_ARTIFACT_GROUP_ID.equals(dependency.getGroup())); } } }
private boolean hasWearAppDependency( BaseVariantData<? extends BaseVariantOutputData> variantData) { // get all possible configurations for the variant. We'll take the highest priority // of them that have a file. List<String> wearConfigNames = variantData.getWearConfigNames(); for (String configName : wearConfigNames) { Configuration config = project.getConfigurations().findByName(configName); // this shouldn't happen, but better safe. if (config == null) { continue; } if (!config.getFiles().isEmpty()) { return true; } } return false; } }
private void performWeaving(ClassLoader classLoader) throws URISyntaxException, IOException { this.logger.debug("source = " + this.source); this.logger.debug("target = " + this.target); this.logger.debug("classpath = " + this.getProject().getConfigurations().findByName("compile").getAsPath()); final StaticWeaveProcessor weaveProcessor = new StaticWeaveProcessor(this.source, this.target); weaveProcessor.setPersistenceInfo(this.getTemporaryDir().toURI().toURL()); weaveProcessor.setClassLoader(classLoader); weaveProcessor.setLog(new PrintWriter(System.out)); weaveProcessor.setLogLevel(AbstractSessionLog.translateStringToLoggingLevel(Optional.ofNullable(this.logLevel).orElse(DEFAULT_LOG_LEVEL).toUpperCase())); weaveProcessor.performWeaving(); } }
public static Configuration cqPackageConfiguration(Project project) { val conf = project.getConfigurations().findByName(CqPackagePlugin.CQ_PACKAGE); if (conf == null) { createCqPackageConf(project); return project.getConfigurations().getByName(CqPackagePlugin.CQ_PACKAGE); } return conf; }
/** * Executes {@linkplain CheckDependencyVersionsTask}. */ @TaskAction public void executeCheckDependencyVersions() { Project project = getProject(); executeCheckDependencyVersions(DependencyMap.fromBuildscript(project), project.getBuildscript().getConfigurations() .findByName(CHECK_BUILDSCRIPT_DEPENDENCY_VERSIONS_CONFIGURATION_NAME), new CheckDependencyVersionsReport(project, CHECK_BUILDSCRIPT_DEPENDENCY_VERSIONS_REPORT_TITLE)); executeCheckDependencyVersions(DependencyMap.fromProject(project), project.getConfigurations().findByName(CHECK_PROJECT_DEPENDENCY_VERSIONS_CONFIGURATION_NAME), new CheckDependencyVersionsReport(project, CHECK_PROJECT_DEPENDENCY_VERSIONS_REPORT_TITLE)); }
/** * Get the configurations that export an artifact * * @param projects Projects to search * @return Exporting configurations */ protected Multimap<@NonNull String, @NonNull ExportingConfiguration> getExportingConfigurations( Collection<@NonNull Project> projects) { Multimap<@NonNull String, @NonNull ExportingConfiguration> exports = Multimaps.newSetMultimap(new HashMap<>(), () -> new TreeSet<>(CONFIGURATION_INFO_COMPARATOR)); for (Project project : projects) { Set<String> configurationNames = ImmutableSet.of("default"); WorkspaceConfig workspaceConfig = project.getExtensions().findByType(WorkspaceConfig.class); if (workspaceConfig != null) { configurationNames = workspaceConfig.getExportedConfigurations(); } for (String configurationName : configurationNames) { Configuration configuration = project.getConfigurations().findByName(configurationName); if (configuration != null) { getExportingConfigurations(project, configuration, exports); } } } return exports; }
@Test public void testConfigurationAvailable() { assertNotNull(project.getConfigurations().findByName(GwtBasePlugin.GWT_CONFIGURATION)); }
/** * 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)); }); } }
/** * 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)); }); } }
public void configure() { setMain("io.sitoolkit.cv.app.SitCvApplication"); FileCollection classpath = getProject().getBuildscript().getConfigurations() .findByName("classpath"); setClasspath(classpath); setArgs(getCvArgsAsList()); getConventionMapping().map("jvmArgs", new Callable<Iterable<String>>() { @SuppressWarnings("unchecked") @Override public Iterable<String> call() throws Exception { if (getProject().hasProperty("applicationDefaultJvmArgs")) { return (Iterable<String>) getProject().property("applicationDefaultJvmArgs"); } return Collections.emptyList(); } }); }