@Override public void execute(Task task) { project.getLogger().debug( "Starting Hibernate enhancement on SourceSet.{}", sourceSet.getName() );
project.getLogger().debug( "Applying Hibernate enhancement action to SourceSet.{}", sourceSet.getName() );
public static final String getSourceSetFormatted(SourceSet sourceSet, String template) { String name = sourceSet.getName(); name = name.substring(0, 1).toUpperCase() + name.substring(1); // convert 1st char to upper case. return String.format(template, name); } }
public String getRelativeOutputDir() { String prefix; if (sourceSet != null) { prefix = sourceSet.getName(); } else { prefix = "main"; } return NamingScheme.getRelativeOutputDir(prefix); }
@NonNull @Override public String getName() { return sourceSet.getName(); }
@NonNull @Override public String getName() { return sourceSet.getName(); }
private static File getAvroSourceDir(Project project, SourceSet sourceSet) { return project.file(String.format("src/%s/avro", sourceSet.getName())); }
private List<String> outputDirsPath() { final JavaPluginConvention javaPlugin = project.getConvention().getPlugin(JavaPluginConvention.class); final SourceSetContainer sourceSets = javaPlugin.getSourceSets(); return sourceSets.stream() .filter(ss -> "main".equals(ss.getName())) .peek(sourceSet -> LOGGER.debug("finding output dir for sourceSet " + sourceSet.getName())) .map(SourceSet::getJava) .map(SourceDirectorySet::getOutputDir) .map(outputDir -> outputDir.toPath().toAbsolutePath().toString()) .collect(Collectors.toList()); } @Override
private List<String> mainOutputDirsPath() { final JavaPluginConvention javaPlugin = project.getConvention().getPlugin(JavaPluginConvention.class); final SourceSetContainer sourceSets = javaPlugin.getSourceSets(); return sourceSets.stream() .filter(ss -> "main".equals(ss.getName())) .peek(sourceSet -> LOGGER.debug("finding output dir for sourceSet " + sourceSet.getName())) .map(SourceSet::getJava) .map(SourceDirectorySet::getOutputDir) .map(outputDir -> outputDir.toPath().toAbsolutePath().toString()) .collect(Collectors.toList()); }
private String sourceDirsPath() { final JavaPluginConvention javaPlugin = project.getConvention().getPlugin(JavaPluginConvention.class); final SourceSetContainer sourceSets = javaPlugin.getSourceSets(); return sourceSets.stream() .filter(ss -> "test".equals(ss.getName())) .peek(sourceSet -> LOGGER.debug("finding source dir for sourceSet " + sourceSet.getName())) .map(SourceSet::getJava) .map(SourceDirectorySet::getSrcDirs) .flatMap(Set::stream) .map(srcDir -> srcDir.toPath().toAbsolutePath().toString()) .collect(Collectors.joining(":")); }
private String testOutputDirsPath() { final JavaPluginConvention javaPlugin = project.getConvention().getPlugin(JavaPluginConvention.class); final SourceSetContainer sourceSets = javaPlugin.getSourceSets(); return sourceSets.stream() .filter(ss -> "test".equals(ss.getName())) .peek(sourceSet -> LOGGER.debug("finding output dir for sourceSet " + sourceSet.getName())) .map(SourceSet::getJava) .map(SourceDirectorySet::getOutputDir) .map(outputDir -> outputDir.toPath().toAbsolutePath().toString()) .collect(Collectors.joining(":")); } @Override
/** * get gradle main source set */ private static Set< SourceSet > sourceSetMain( Project project ) { JavaPluginConvention convention = project.getConvention().findPlugin( JavaPluginConvention.class ); Set< SourceSet > sourceSets = convention.getSourceSets().stream().filter( sourceSet -> sourceSet.getName().equals( SourceSet.MAIN_SOURCE_SET_NAME ) ).collect( Collectors.toSet() ); return sourceSets; }
@Override public FileCollection call() { ConfigurableFileTree fileTree = StreamSupport.stream(sourceSet.getOutput().getClassesDirs().spliterator(), false) .map(project::fileTree) .reduce((lhs, rhs) -> { lhs.plus(rhs); return lhs; }).orElseThrow(() -> new InvalidUserDataException("No classes dir configured for source set " + sourceSet.getName()) ); return fileTree.builtBy(sourceSet.getClassesTaskName()); } });
@TaskAction public void compileJavascript() { SourceSetContainer cont = (SourceSetContainer) getProject().getProperties().get("sourceSets"); cont.all((SourceSet ss) -> { JavaScriptExtension jse = (JavaScriptExtension) getProject() .getExtensions() .getByName("javascript"); JavaScriptSourceSet jsss = jse .getSourceSetsContainer() .maybeCreate(ss.getName()); }); } }
private static String getHydraConfigFolderFromTask(Project project, ScalaCompile scalaCompile) { SourceSetContainer sourceSets = project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets(); String hydraConfigFolder = "main"; for (SourceSet set : sourceSets) { if (set.getCompileTaskName("scala").equals(scalaCompile.getName())) { hydraConfigFolder = set.getName(); } } return hydraConfigFolder; }
private void configureSourceSetInjection(final Project p, SourceSet sourceSet) { EtaInjectDependencies injectDependenciesTask = p.getTasks() .create(NamingScheme.getInjectDependenciesTaskName(sourceSet.getName()), EtaInjectDependencies.class); injectDependenciesTask.setTargetConfiguration (project.provider(() -> sourceSet.getCompileClasspathConfigurationName())); injectDependenciesTask.dependsOnProjects(); sourceSet.setCompileClasspath (sourceSet.getCompileClasspath() .plus(p.files().builtBy(injectDependenciesTask))); }
private void configureGosuCompile(JavaBasePlugin javaPlugin, SourceSet sourceSet, GosuSourceSet gosuSourceSet) { String compileTaskName = sourceSet.getCompileTaskName("gosu"); GosuCompile gosuCompile = _project.getTasks().create(compileTaskName, GosuCompile.class); javaPlugin.configureForSourceSet(sourceSet, gosuCompile); gosuCompile.dependsOn(sourceSet.getCompileJavaTaskName()); gosuCompile.setDescription("Compiles the " + sourceSet.getName() + " Gosu source"); gosuCompile.setSource(gosuSourceSet.getGosu()); gosuCompile.setSourceRoots(gosuSourceSet.getGosu().getSrcDirs()); _project.getTasks().getByName(sourceSet.getClassesTaskName()).dependsOn(compileTaskName); }
private static void configureOutputDirectoryForSourceSet(final SourceSet sourceSet, final SourceDirectorySet sourceDirectorySet, AbstractCompile compile, final Project target) { final String sourceSetChildPath = "classes/" + sourceDirectorySet.getName() + "/" + sourceSet.getName(); sourceDirectorySet.setOutputDir(target.provider(() -> { if (sourceSet.getOutput().isLegacyLayout()) { return sourceSet.getOutput().getClassesDir(); } return new File(target.getBuildDir(), sourceSetChildPath); })); ((ConfigurableFileCollection) sourceSet.getOutput().getClassesDirs()).from(target.provider( sourceDirectorySet::getOutputDir)); compile.setDestinationDir(target.provider(sourceDirectorySet::getOutputDir)); }
private void configureSourceSetDefaults(final JavaBasePlugin javaBasePlugin) { _project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().all(sourceSet -> { GosuSourceSet gosuSourceSet = new DefaultGosuSourceSet(sourceSet.getName(), _sourceDirectorySetFactory); Convention sourceSetConvention = (Convention) InvokerHelper.getProperty(sourceSet, "convention"); sourceSetConvention.getPlugins().put("gosu", gosuSourceSet); gosuSourceSet.getGosu().srcDir("src/" + sourceSet.getName() + "/gosu"); sourceSet.getResources().getFilter().exclude(element -> gosuSourceSet.getGosu().contains(element.getFile())); sourceSet.getAllSource().source(gosuSourceSet.getGosu()); configureGosuCompile(javaBasePlugin, sourceSet, gosuSourceSet); }); }
private void configureSourceSetDefaults(final JavaBasePlugin javaBasePlugin) { _project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().all( sourceSet -> { DefaultGosuSourceSet gosuSourceSet = new DefaultGosuSourceSet(((DefaultSourceSet) sourceSet).getDisplayName(), _fileResolver); new DslObject(sourceSet).getConvention().getPlugins().put("gosu", gosuSourceSet); gosuSourceSet.getGosu().srcDir("src/" + sourceSet.getName() + "/gosu"); sourceSet.getResources().getFilter().exclude( element -> { return gosuSourceSet.getGosu().contains(element.getFile()); }); sourceSet.getAllSource().source(gosuSourceSet.getGosu()); configureGosuCompile(javaBasePlugin, sourceSet, gosuSourceSet); }); }