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); }
/** * Create and configure default compileGosu and compileTestGosu tasks * Gradle 4.0+: call local equivalent of o.g.a.p.i.SourceSetUtil.configureForSourceSet(sourceSet, gosuSourceSet.getGosu(), gosuCompile, _project) * Gradle 2.x, 3.x: call javaPlugin.configureForSourceSet(sourceSet, gosuCompile); */ private void configureGosuCompile(JavaBasePlugin javaPlugin, SourceSet sourceSet, GosuSourceSet gosuSourceSet) { String compileTaskName = sourceSet.getCompileTaskName("gosu"); GosuCompile gosuCompile = _project.getTasks().create(compileTaskName, GosuCompile.class); VersionNumber gradleVersion = VersionNumber.parse(_project.getGradle().getGradleVersion()); if(gradleVersion.compareTo(VersionNumber.parse("4.0")) >= 0) { //Gradle 4.0+ configureForSourceSet(sourceSet, gosuSourceSet.getGosu(), gosuCompile, _project); } else { javaPlugin.configureForSourceSet(sourceSet, gosuCompile); gosuCompile.setDescription("Compiles the " + gosuSourceSet.getGosu() + "."); } gosuCompile.dependsOn(sourceSet.getCompileJavaTaskName()); gosuCompile.setSource((Object) gosuSourceSet.getGosu()); // Gradle 4.0 overloads setSource; must upcast to Object for backwards compatibility _project.getTasks().getByName(sourceSet.getClassesTaskName()).dependsOn(compileTaskName); }
public void execute(final SourceSet sourceSet) { FregeSourceSetDirectoryFactory factory = new FregeSourceSetDirectoryFactory((ProjectInternal) project, fileResolver); final DefaultFregeSourceSet fregeSourceSet = new DefaultFregeSourceSet(((DefaultSourceSet) sourceSet).getDisplayName(), factory); new DslObject(sourceSet).getConvention().getPlugins().put("frege", fregeSourceSet); final String defaultSourcePath = String.format("src/%s/frege", sourceSet.getName()); fregeSourceSet.getFrege().srcDir(defaultSourcePath); sourceSet.getResources().getFilter().exclude(new Spec<FileTreeElement>() { public boolean isSatisfiedBy(FileTreeElement element) { return fregeSourceSet.getFrege().contains(element.getFile()); } }); sourceSet.getAllJava().source(fregeSourceSet.getFrege()); sourceSet.getAllSource().source(fregeSourceSet.getFrege()); String compileTaskName = sourceSet.getCompileTaskName("frege"); FregeCompile compile = project.getTasks().create(compileTaskName, FregeCompile.class); compile.setModule(project.file(defaultSourcePath).getAbsolutePath()); javaBasePlugin.configureForSourceSet(sourceSet, compile); compile.getConventionMapping().map("fregepath", new Callable() { public Object call() throws Exception { return sourceSet.getCompileClasspath(); } }); compile.dependsOn(sourceSet.getCompileJavaTaskName()); compile.setDescription(String.format("Compiles the %s Frege source.", sourceSet.getName())); compile.setSource(fregeSourceSet.getFrege()); project.getTasks().getByName(sourceSet.getClassesTaskName()).dependsOn(compileTaskName); sourceSet.compiledBy(compile); } });