Java Code Examples for org.gradle.api.tasks.SourceSet
The following examples show how to use
org.gradle.api.tasks.SourceSet. These examples are extracted from open source projects.
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 Project: gradle-plugins Source File: AspectJPlugin.java License: MIT License | 6 votes |
@Override public void apply(Project project) { this.project = project; project.getPlugins().apply(AspectJBasePlugin.class); project.getPlugins().apply(JavaBasePlugin.class); JavaPluginConvention plugin = project.getConvention().getPlugin(JavaPluginConvention.class); plugin.getSourceSets().all(this::configureSourceSet); project.getPlugins().withType(JavaPlugin.class, javaPlugin -> { SourceSet main = plugin.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME); SourceSet test = plugin.getSourceSets().getByName(SourceSet.TEST_SOURCE_SET_NAME); DefaultAspectjSourceSet mainAj = new DslObject(main).getConvention().getPlugin(DefaultAspectjSourceSet.class); DefaultAspectjSourceSet testAj = new DslObject(test).getConvention().getPlugin(DefaultAspectjSourceSet.class); Configuration aspectpath = project.getConfigurations().getByName(mainAj.getAspectConfigurationName()); Configuration testAspectpath = project.getConfigurations().getByName(testAj.getAspectConfigurationName()); testAspectpath.extendsFrom(aspectpath); testAj.setAspectPath(project.getObjects().fileCollection().from(main.getOutput(), testAspectpath)); }); }
Example 2
Source Project: Pushjet-Android Source File: JavaBasePlugin.java License: BSD 2-Clause "Simplified" License | 6 votes |
public void configureForSourceSet(final SourceSet sourceSet, AbstractCompile compile) { ConventionMapping conventionMapping; compile.setDescription(String.format("Compiles the %s.", sourceSet.getJava())); conventionMapping = compile.getConventionMapping(); compile.setSource(sourceSet.getJava()); conventionMapping.map("classpath", new Callable<Object>() { public Object call() throws Exception { return sourceSet.getCompileClasspath(); } }); conventionMapping.map("destinationDir", new Callable<Object>() { public Object call() throws Exception { return sourceSet.getOutput().getClassesDir(); } }); }
Example 3
Source Project: gradle-plugins Source File: AspectJPlugin.java License: MIT License | 6 votes |
@Override public void apply(Project project) { this.project = project; project.getPlugins().apply(AspectJBasePlugin.class); project.getPlugins().apply(JavaBasePlugin.class); JavaPluginConvention plugin = project.getConvention().getPlugin(JavaPluginConvention.class); plugin.getSourceSets().all(this::configureSourceSet); project.getPlugins().withType(JavaPlugin.class, javaPlugin -> { SourceSet main = plugin.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME); SourceSet test = plugin.getSourceSets().getByName(SourceSet.TEST_SOURCE_SET_NAME); DefaultAspectjSourceSet mainAj = new DslObject(main).getConvention().getPlugin(DefaultAspectjSourceSet.class); DefaultAspectjSourceSet testAj = new DslObject(test).getConvention().getPlugin(DefaultAspectjSourceSet.class); Configuration aspectpath = project.getConfigurations().getByName(mainAj.getAspectConfigurationName()); Configuration testAspectpath = project.getConfigurations().getByName(testAj.getAspectConfigurationName()); testAspectpath.extendsFrom(aspectpath); testAj.setAspectPath(project.getObjects().fileCollection().from(main.getOutput(), testAspectpath)); }); }
Example 4
Source Project: gradle-plugins Source File: SourcesJarPlugin.java License: MIT License | 6 votes |
@Override public void apply(Project project) { project.getLogger().warn("io.freefair.sources-jar is deprecated. Use java.withSourcesJar() instead"); project.getPluginManager().withPlugin("java", appliedPlugin -> { sourcesJar = project.getTasks().register("sourcesJar", Jar.class, sourcesJar -> { sourcesJar.setDescription("Assembles a jar archive containing the sources."); sourcesJar.getArchiveClassifier().set("sources"); sourcesJar.setGroup(BasePlugin.BUILD_GROUP); sourcesJar.dependsOn(project.getTasks().named(JavaPlugin.CLASSES_TASK_NAME)); JavaPluginConvention javaPluginConvention = project.getConvention().getPlugin(JavaPluginConvention.class); DefaultSourceSet mainSourceSet = (DefaultSourceSet) javaPluginConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME); sourcesJar.from(mainSourceSet.getAllSource()); }); project.getArtifacts().add(Dependency.ARCHIVES_CONFIGURATION, sourcesJar); }); }
Example 5
Source Project: gradle-java-modules Source File: JigsawPlugin.java License: Apache License 2.0 | 6 votes |
private void configureCompileTestJavaTask(final Project project) { final JavaCompile compileTestJava = (JavaCompile) project.getTasks() .findByName(JavaPlugin.COMPILE_TEST_JAVA_TASK_NAME); final SourceSet test = ((SourceSetContainer) project.getProperties().get("sourceSets")).getByName("test"); final JavaModule module = (JavaModule) project.getExtensions().getByName(EXTENSION_NAME); compileTestJava.getInputs().property("moduleName", module.geName()); compileTestJava.doFirst(new Action<Task>() { @Override public void execute(Task task) { List<String> args = new ArrayList<>(); args.add("--module-path"); args.add(compileTestJava.getClasspath().getAsPath()); args.add("--add-modules"); args.add("junit"); args.add("--add-reads"); args.add(module.geName() + "=junit"); args.add("--patch-module"); args.add(module.geName() + "=" + test.getJava().getSourceDirectories().getAsPath()); compileTestJava.getOptions().setCompilerArgs(args); compileTestJava.setClasspath(project.files()); } }); }
Example 6
Source Project: pushfish-android Source File: GroovyBasePlugin.java License: BSD 2-Clause "Simplified" License | 6 votes |
private void configureSourceSetDefaults(final JavaBasePlugin javaBasePlugin) { project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().all(new Action<SourceSet>() { public void execute(SourceSet sourceSet) { final DefaultGroovySourceSet groovySourceSet = new DefaultGroovySourceSet(((DefaultSourceSet) sourceSet).getDisplayName(), fileResolver); new DslObject(sourceSet).getConvention().getPlugins().put("groovy", groovySourceSet); groovySourceSet.getGroovy().srcDir(String.format("src/%s/groovy", sourceSet.getName())); sourceSet.getResources().getFilter().exclude(new Spec<FileTreeElement>() { public boolean isSatisfiedBy(FileTreeElement element) { return groovySourceSet.getGroovy().contains(element.getFile()); } }); sourceSet.getAllJava().source(groovySourceSet.getGroovy()); sourceSet.getAllSource().source(groovySourceSet.getGroovy()); String compileTaskName = sourceSet.getCompileTaskName("groovy"); GroovyCompile compile = project.getTasks().create(compileTaskName, GroovyCompile.class); javaBasePlugin.configureForSourceSet(sourceSet, compile); compile.dependsOn(sourceSet.getCompileJavaTaskName()); compile.setDescription(String.format("Compiles the %s Groovy source.", sourceSet.getName())); compile.setSource(groovySourceSet.getGroovy()); project.getTasks().getByName(sourceSet.getClassesTaskName()).dependsOn(compileTaskName); } }); }
Example 7
Source Project: pushfish-android Source File: JavaBasePlugin.java License: BSD 2-Clause "Simplified" License | 6 votes |
public void configureForSourceSet(final SourceSet sourceSet, AbstractCompile compile) { ConventionMapping conventionMapping; compile.setDescription(String.format("Compiles the %s.", sourceSet.getJava())); conventionMapping = compile.getConventionMapping(); compile.setSource(sourceSet.getJava()); conventionMapping.map("classpath", new Callable<Object>() { public Object call() throws Exception { return sourceSet.getCompileClasspath(); } }); conventionMapping.map("destinationDir", new Callable<Object>() { public Object call() throws Exception { return sourceSet.getOutput().getClassesDir(); } }); }
Example 8
Source Project: Pushjet-Android Source File: JavaBasePlugin.java License: BSD 2-Clause "Simplified" License | 6 votes |
public void configureForSourceSet(final SourceSet sourceSet, AbstractCompile compile) { ConventionMapping conventionMapping; compile.setDescription(String.format("Compiles the %s.", sourceSet.getJava())); conventionMapping = compile.getConventionMapping(); compile.setSource(sourceSet.getJava()); conventionMapping.map("classpath", new Callable<Object>() { public Object call() throws Exception { return sourceSet.getCompileClasspath(); } }); conventionMapping.map("destinationDir", new Callable<Object>() { public Object call() throws Exception { return sourceSet.getOutput().getClassesDir(); } }); }
Example 9
Source Project: pushfish-android Source File: JavaBasePlugin.java License: BSD 2-Clause "Simplified" License | 6 votes |
public void configureForSourceSet(final SourceSet sourceSet, AbstractCompile compile) { ConventionMapping conventionMapping; compile.setDescription(String.format("Compiles the %s.", sourceSet.getJava())); conventionMapping = compile.getConventionMapping(); compile.setSource(sourceSet.getJava()); conventionMapping.map("classpath", new Callable<Object>() { public Object call() throws Exception { return sourceSet.getCompileClasspath(); } }); conventionMapping.map("destinationDir", new Callable<Object>() { public Object call() throws Exception { return sourceSet.getOutput().getClassesDir(); } }); }
Example 10
Source Project: transport Source File: SourceSetUtils.java License: BSD 2-Clause "Simplified" License | 6 votes |
private static String getConfigurationNameForSourceSet(SourceSet sourceSet, ConfigurationType configurationType) { final String configName; switch (configurationType) { case ANNOTATION_PROCESSOR: configName = sourceSet.getAnnotationProcessorConfigurationName(); break; case IMPLEMENTATION: configName = sourceSet.getImplementationConfigurationName(); break; case COMPILE_ONLY: configName = sourceSet.getCompileOnlyConfigurationName(); break; case RUNTIME_CLASSPATH: configName = sourceSet.getRuntimeClasspathConfigurationName(); break; case RUNTIME_ONLY: configName = sourceSet.getRuntimeOnlyConfigurationName(); break; default: throw new UnsupportedOperationException("Configuration " + configurationType + " not supported"); } return configName; }
Example 11
Source Project: javaide Source File: JavaBasePlugin.java License: GNU General Public License v3.0 | 6 votes |
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)); }
Example 12
Source Project: gradle-cpd-plugin Source File: CpdPluginTest.java License: Apache License 2.0 | 6 votes |
@Test void CpdPlugin_shouldSetCpdCheckSourceEqualsToMainAndTestSourceSetsIfJavaPluginIsApplied(Project project, TaskProvider<Cpd> cpd) { // Given: String mainFile = "src/main/java/Clazz.java"; String testFile = "src/test/java/ClazzTest.java"; // When: project.getPlugins().apply(JavaPlugin.class); createProjectFiles(project, mainFile, "src/resources/java/message.properties", testFile); project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME, sourceSet -> { sourceSet.getJava().srcDir(testFile(JAVA, "de/aaschmid/annotation")); sourceSet.getAllJava().srcDir(testFile(JAVA, "de/aaschmid/clazz")); sourceSet.getResources().srcDir(testFile(JAVA, "de/aaschmid/foo")); }); project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().getByName(SourceSet.TEST_SOURCE_SET_NAME, sourceSet -> sourceSet.getJava().srcDir(testFile(JAVA, "de/aaschmid/test"))); // Then: List<File> expected = testFilesRecurseIn(JAVA, "de/aaschmid/annotation", "de/aaschmid/clazz", "de/aaschmid/test"); expected.add(project.file(mainFile)); expected.add(project.file(testFile)); assertThat(cpd.get().getSource()).containsExactlyInAnyOrderElementsOf(expected); }
Example 13
Source Project: transport Source File: ShadedJarPackaging.java License: BSD 2-Clause "Simplified" License | 6 votes |
/** * Creates a {@link ShadeTask} which generates a shaded JAR containing all runtime dependencies of the platform's * {@link SourceSet} * * TODO: This code is borrowed from the Shade plugin. Call the functionality residing in the Shade plugin once it is * available */ private TaskProvider<ShadeTask> createShadeTask(Project project, Platform platform, SourceSet sourceSet, SourceSet mainSourceSet) { TaskProvider<ShadeTask> shadeTask = project.getTasks().register(sourceSet.getTaskName("shade", "Jar"), ShadeTask.class, task -> { task.setGroup(ShadowJavaPlugin.getSHADOW_GROUP()); task.setDescription("Create a combined JAR of " + platform.getName() + " output and runtime dependencies"); task.setClassifier(platform.getName()); task.getManifest() .inheritFrom(project.getTasks().named(mainSourceSet.getJarTaskName(), Jar.class).get().getManifest()); task.from(sourceSet.getOutput()); task.setConfigurations(ImmutableList.of(getConfigurationForSourceSet(project, sourceSet, RUNTIME_CLASSPATH))); task.exclude("META-INF/INDEX.LIST", "META-INF/*.SF", "META-INF/*.DSA", "META-INF/*.RSA"); }); // TODO: Figure out why this artifact is generated but not being published in Maven project.getArtifacts().add(ShadowBasePlugin.getCONFIGURATION_NAME(), shadeTask); return shadeTask; }
Example 14
Source Project: playframework Source File: PlayApplicationPlugin.java License: Apache License 2.0 | 6 votes |
private void configureJavaAndScalaSourceSet(Project project) { SourceSet mainSourceSet = PlayPluginHelper.getMainJavaSourceSet(project); SourceDirectorySet mainResourcesDirectorySet = mainSourceSet.getResources(); mainResourcesDirectorySet.setSrcDirs(Arrays.asList("conf")); SourceDirectorySet mainScalaSourceDirectorySet = PlayPluginHelper.getMainScalaSourceDirectorySet(project); mainScalaSourceDirectorySet.setSrcDirs(Arrays.asList("app")); mainScalaSourceDirectorySet.include("**/*.scala", "**/*.java"); mainScalaSourceDirectorySet.srcDir(getTwirlCompileTask(project).flatMap(task -> task.getOutputDirectory())); mainScalaSourceDirectorySet.srcDir(getRoutesCompileTask(project).flatMap(task -> task.getOutputDirectory())); SourceDirectorySet testScalaSourceDirectorySet = PlayPluginHelper.getTestScalaSourceDirectorySet(project); testScalaSourceDirectorySet.setSrcDirs(Arrays.asList("test")); testScalaSourceDirectorySet.include("**/*.scala", "**/*.java"); }
Example 15
Source Project: javaide Source File: DefaultAndroidSourceSet.java License: GNU General Public License v3.0 | 6 votes |
@Override @NonNull public String getPackageConfigurationName() { if (isLibrary) { if (name.equals(SourceSet.MAIN_SOURCE_SET_NAME)) { return "publish"; } else { return String.format("%sPublish", name); } } if (name.equals(SourceSet.MAIN_SOURCE_SET_NAME)) { return "apk"; } else { return String.format("%sApk", name); } }
Example 16
Source Project: jpa2ddl Source File: GeneratePlugin.java License: Apache License 2.0 | 6 votes |
@Override public void apply(Project project) { GeneratePluginExtension generatePluginExtension = project.getExtensions().create(EXTENSION_NAME, GeneratePluginExtension.class, project); GenerateTask generateTask = project.getTasks().create(TASK_NAME, GenerateTask.class); generateTask.setGroup(BasePlugin.BUILD_GROUP); generateTask.setDescription("Generates DDL scripts based on JPA model."); generateTask.setExtension(generatePluginExtension); generateTask.dependsOn(JavaBasePlugin.BUILD_TASK_NAME); project.afterEvaluate(evaluatedProject -> { fillDefaults(evaluatedProject, generatePluginExtension); SourceSetContainer sourceSets = (SourceSetContainer) project.getProperties().get("sourceSets"); Set<File> paths; if (sourceSets != null) { UnionFileCollection mainClasspath = (UnionFileCollection) sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME).getRuntimeClasspath(); paths = mainClasspath.getFiles(); } else { paths = new HashSet<>(); } generateTask.setOutputClassesDirs(paths); }); }
Example 17
Source Project: gradle-plugins Source File: MavenProjectWrapper.java License: MIT License | 6 votes |
public MavenProjectWrapper(Project project, File pomFile) throws IOException, XmlPullParserException { this.project = project; this.pomFile = pomFile; MavenXpp3Reader reader = new MavenXpp3Reader(); Model model = reader.read(new FileReader(pomFile)); setModel(model); getBuild().setDirectory(project.getBuildDir().getAbsolutePath()); SourceSetContainer sourceSets = project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets(); SourceSet main = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME); getBuild().setSourceDirectory(main.getJava().getSrcDirs().iterator().next().getAbsolutePath()); getBuild().setOutputDirectory(main.getJava().getOutputDir().getAbsolutePath()); SourceSet test = sourceSets.getByName(SourceSet.TEST_SOURCE_SET_NAME); getBuild().setTestSourceDirectory(test.getJava().getSrcDirs().iterator().next().getAbsolutePath()); getBuild().setTestOutputDirectory(test.getJava().getOutputDir().getAbsolutePath()); setArtifact(new ProjectArtifact(this)); }
Example 18
Source Project: client-gradle-plugin Source File: ConfigBuild.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
private List<Path> getClassPathFromSourceSets() { List<Path> classPath = Collections.emptyList(); SourceSetContainer sourceSetContainer = (SourceSetContainer) project.getProperties().get("sourceSets"); SourceSet mainSourceSet = sourceSetContainer.findByName("main"); if (mainSourceSet != null) { classPath = mainSourceSet.getRuntimeClasspath().getFiles().stream() .filter(File::exists) .map(File::toPath).collect(Collectors.toList()); } return classPath; }
Example 19
Source Project: javaide Source File: JavaBasePlugin.java License: GNU General Public License v3.0 | 5 votes |
private void createBinaryLifecycleTask(SourceSet sourceSet, Project target) { sourceSet.compiledBy(sourceSet.getClassesTaskName()); Task binaryLifecycleTask = target.task(sourceSet.getClassesTaskName()); binaryLifecycleTask.setGroup(LifecycleBasePlugin.BUILD_GROUP); binaryLifecycleTask.setDescription("Assembles " + sourceSet.getOutput() + "."); binaryLifecycleTask.dependsOn(sourceSet.getOutput().getDirs()); binaryLifecycleTask.dependsOn(sourceSet.getCompileJavaTaskName()); binaryLifecycleTask.dependsOn(sourceSet.getProcessResourcesTaskName()); }
Example 20
Source Project: gradle-avro-plugin Source File: AvroPlugin.java License: Apache License 2.0 | 5 votes |
private static void configureTaskDependencies(final Project project, final SourceSet sourceSet, final TaskProvider<GenerateAvroJavaTask> javaTaskProvider) { project.getPluginManager().withPlugin("org.jetbrains.kotlin.jvm", appliedPlugin -> project.getTasks() .withType(SourceTask.class) .matching(task -> sourceSet.getCompileTaskName("kotlin").equals(task.getName())) .configureEach(task -> task.source(javaTaskProvider.get().getOutputs()) ) ); }
Example 21
Source Project: putnami-gradle-plugin Source File: PwtLibPlugin.java License: GNU Lesser General Public License v3.0 | 5 votes |
private void includeSourcesForTest(Project project) { JavaPluginConvention javaConvention = project.getConvention().getPlugin(JavaPluginConvention.class); SourceSet mainSourset = javaConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME); SourceSet testSourset = javaConvention.getSourceSets().getByName(SourceSet.TEST_SOURCE_SET_NAME); FileCollection testClasspath = project .files(mainSourset.getAllSource().getSrcDirs().toArray()) .plus(project.files(testSourset.getAllSource().getSrcDirs().toArray())) .plus(testSourset.getRuntimeClasspath()); testSourset.setRuntimeClasspath(testClasspath); Test test = project.getTasks().withType(Test.class).getByName("test"); test.getSystemProperties().put("gwt.persistentunitcachedir", project.getBuildDir() + "/putnami/test"); }
Example 22
Source Project: web3j-gradle-plugin Source File: Web3jPlugin.java License: Apache License 2.0 | 5 votes |
private File buildSourceDir(final Web3jExtension extension, final SourceSet sourceSet) { if (extension.getGeneratedFilesBaseDir().isEmpty()) { throw new InvalidUserDataException("Generated web3j package cannot be empty"); } return new File(extension.getGeneratedFilesBaseDir() + "/" + sourceSet.getName() + "/java"); }
Example 23
Source Project: gradle-cpd-plugin Source File: CpdPluginTest.java License: Apache License 2.0 | 5 votes |
@Test void CpdPlugin_shouldAddSourcesOfSubProjectsEvenIfAppliedOnlyOnParentProject(Project project, TaskProvider<Cpd> cpdCheck) { // When: Project subProject1 = ProjectBuilder.builder().withName("sub1").withParent(project).build(); subProject1.getPlugins().apply(JavaPlugin.class); createProjectFiles(subProject1, "src/main/java/Clazz.java", "src/test/java/ClazzTest.java"); Project subProject2 = ProjectBuilder.builder().withName("sub2").withParent(project).build(); subProject2.getPlugins().apply(GroovyPlugin.class); createProjectFiles(subProject2, "src/main/groovy/Clazz.groovy", "src/main/resources/clazz.properties"); subProject1.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME, sourceSet -> { sourceSet.getJava().srcDir(testFile(JAVA, "de/aaschmid/annotation")); sourceSet.getAllJava().srcDir(testFile(JAVA, "de/aaschmid/clazz")); sourceSet.getResources().srcDir(testFile(JAVA, "de/aaschmid/foo")); }); subProject2.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().getByName(SourceSet.TEST_SOURCE_SET_NAME, sourceSet -> sourceSet.getJava().srcDir(testFile(JAVA, "de/aaschmid/test"))); // Then: List<File> expected = testFilesRecurseIn(JAVA, "de/aaschmid/annotation", "de/aaschmid/clazz", "de/aaschmid/test"); expected.add(subProject1.file("src/main/java/Clazz.java")); expected.add(subProject1.file("src/test/java/ClazzTest.java")); expected.add(subProject2.file("src/main/groovy/Clazz.groovy")); assertThat(cpdCheck.get().getSource()).containsExactlyInAnyOrderElementsOf(expected); assertThat(subProject1.getTasks().findByName("cpdCheck")).isNull(); assertThat(subProject2.getTasks().findByName("cpdCheck")).isNull(); }
Example 24
Source Project: putnami-gradle-plugin Source File: GwtCompileTask.java License: GNU Lesser General Public License v3.0 | 5 votes |
public void configure(final Project project, final PutnamiExtension extention) { final CompilerOption options = extention.getCompile(); options.init(project); options.setLocalWorkers(evalWorkers(options)); final ConfigurableFileCollection sources = project.files(); addSourceSet(sources, project, SourceSet.MAIN_SOURCE_SET_NAME); final Configuration compileClasspath = project.getConfigurations().getByName( JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME); compileClasspath.getDependencies().withType(ProjectDependency.class, new Action<ProjectDependency>() { @Override public void execute(ProjectDependency dep) { addSourceSet(sources, dep.getDependencyProject(), SourceSet.MAIN_SOURCE_SET_NAME); } }); ConventionMapping mapping = ((IConventionAware) this).getConventionMapping(); mapping.map("modules", new Callable<List<String>>() { @Override public List<String> call() { return extention.getModule(); } }); mapping.map("war", new Callable<File>() { @Override public File call() { return options.getWar(); } }); mapping.map("src", new Callable<FileCollection>() { @Override public FileCollection call() { return sources; } }); }
Example 25
Source Project: gradle-plugins Source File: DefaultAspectjSourceSet.java License: MIT License | 5 votes |
public DefaultAspectjSourceSet(ObjectFactory objectFactory, SourceSet sourceSet) { super(sourceSet); String name = sourceSet.getName(); String displayName = ((DefaultSourceSet) sourceSet).getDisplayName(); aspectj = objectFactory.sourceDirectorySet("aspectj", displayName + " AspectJ source"); aspectj.getFilter().include("**/*.java", "**/*.aj"); allAspectj = objectFactory.sourceDirectorySet("all" + name, displayName + " AspectJ source"); allAspectj.source(aspectj); allAspectj.getFilter().include("**/*.aj"); }
Example 26
Source Project: putnami-gradle-plugin Source File: GwtCompileTask.java License: GNU Lesser General Public License v3.0 | 5 votes |
private void addSourceSet(FileCollection sources, Project project, String sourceSet) { JavaPluginConvention javaConvention = project.getConvention().getPlugin(JavaPluginConvention.class); SourceSet mainSourceSet = javaConvention.getSourceSets().getByName(sourceSet); sources.add(project.files(mainSourceSet.getOutput().getResourcesDir())) .plus(project.files(mainSourceSet.getOutput().getClassesDirs())) .plus(project.files(mainSourceSet.getAllSource().getSrcDirs())); }
Example 27
Source Project: pushfish-android Source File: JavaPlugin.java License: BSD 2-Clause "Simplified" License | 5 votes |
private void configureJavaDoc(final JavaPluginConvention pluginConvention) { Project project = pluginConvention.getProject(); SourceSet mainSourceSet = pluginConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME); Javadoc javadoc = project.getTasks().create(JAVADOC_TASK_NAME, Javadoc.class); javadoc.setDescription("Generates Javadoc API documentation for the main source code."); javadoc.setGroup(JavaBasePlugin.DOCUMENTATION_GROUP); javadoc.setClasspath(mainSourceSet.getOutput().plus(mainSourceSet.getCompileClasspath())); javadoc.setSource(mainSourceSet.getAllJava()); addDependsOnTaskInOtherProjects(javadoc, true, JAVADOC_TASK_NAME, COMPILE_CONFIGURATION_NAME); }
Example 28
Source Project: pushfish-android Source File: JavaPlugin.java License: BSD 2-Clause "Simplified" License | 5 votes |
private void configureArchivesAndComponent(final Project project, final JavaPluginConvention pluginConvention) { Jar jar = project.getTasks().create(JAR_TASK_NAME, Jar.class); jar.setDescription("Assembles a jar archive containing the main classes."); jar.setGroup(BasePlugin.BUILD_GROUP); jar.from(pluginConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME).getOutput()); ArchivePublishArtifact jarArtifact = new ArchivePublishArtifact(jar); Configuration runtimeConfiguration = project.getConfigurations().getByName(RUNTIME_CONFIGURATION_NAME); runtimeConfiguration.getArtifacts().add(jarArtifact); project.getExtensions().getByType(DefaultArtifactPublicationSet.class).addCandidate(jarArtifact); project.getComponents().add(new JavaLibrary(jarArtifact, runtimeConfiguration.getAllDependencies())); }
Example 29
Source Project: pushfish-android Source File: WarPlugin.java License: BSD 2-Clause "Simplified" License | 5 votes |
public void apply(final Project project) { project.getPlugins().apply(JavaPlugin.class); final WarPluginConvention pluginConvention = new WarPluginConvention(project); project.getConvention().getPlugins().put("war", pluginConvention); project.getTasks().withType(War.class, new Action<War>() { public void execute(War task) { task.from(new Callable() { public Object call() throws Exception { return pluginConvention.getWebAppDir(); } }); task.dependsOn(new Callable() { public Object call() throws Exception { return project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().getByName( SourceSet.MAIN_SOURCE_SET_NAME).getRuntimeClasspath(); } }); task.classpath(new Object[] {new Callable() { public Object call() throws Exception { FileCollection runtimeClasspath = project.getConvention().getPlugin(JavaPluginConvention.class) .getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME).getRuntimeClasspath(); Configuration providedRuntime = project.getConfigurations().getByName( PROVIDED_RUNTIME_CONFIGURATION_NAME); return runtimeClasspath.minus(providedRuntime); } }}); } }); War war = project.getTasks().create(WAR_TASK_NAME, War.class); war.setDescription("Generates a war archive with all the compiled classes, the web-app content and the libraries."); war.setGroup(BasePlugin.BUILD_GROUP); ArchivePublishArtifact warArtifact = new ArchivePublishArtifact(war); project.getExtensions().getByType(DefaultArtifactPublicationSet.class).addCandidate(warArtifact); configureConfigurations(project.getConfigurations()); configureComponent(project, warArtifact); }
Example 30
Source Project: Pushjet-Android Source File: JavaPlugin.java License: BSD 2-Clause "Simplified" License | 5 votes |
private void configureJavaDoc(final JavaPluginConvention pluginConvention) { Project project = pluginConvention.getProject(); SourceSet mainSourceSet = pluginConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME); Javadoc javadoc = project.getTasks().create(JAVADOC_TASK_NAME, Javadoc.class); javadoc.setDescription("Generates Javadoc API documentation for the main source code."); javadoc.setGroup(JavaBasePlugin.DOCUMENTATION_GROUP); javadoc.setClasspath(mainSourceSet.getOutput().plus(mainSourceSet.getCompileClasspath())); javadoc.setSource(mainSourceSet.getAllJava()); addDependsOnTaskInOtherProjects(javadoc, true, JAVADOC_TASK_NAME, COMPILE_CONFIGURATION_NAME); }