/** * Configure the compile tasks * * @param javaCompile Compile task to configure */ @Mutate public void configureCompileTask(@Each JavaCompile javaCompile) { List<String> compilerArgs = javaCompile.getOptions().getCompilerArgs(); compilerArgs.add("-Xlint:unchecked"); compilerArgs.add("-Xlint:deprecation"); }
/** * Configure the compile tasks * * @param javaCompile Compile task to configure */ @Mutate public void configureCompileTask(@Each JavaCompile javaCompile) { List<String> compilerArgs = javaCompile.getOptions().getCompilerArgs(); compilerArgs.add("-Xlint:unchecked"); compilerArgs.add("-Xlint:deprecation"); }
/** * Validate a Git repository * * @param repository Git repository to validate */ @Validate public void validateGitConfig(@Each GitRepository repository) { if (repository.getUrl() == null) { throw new GradleException( String.format("Please set 'gitConfig.remoteRepositories.%s.url'", repository.getName())); } }
/** * Configure the eclipse task * * @param task Task to configure * @param pluginExtension Plugin extension */ @Mutate public void configureTasks(@Each Task task, GradlePluginDevelopmentExtension pluginExtension) { if (task.getName().equals("eclipse")) { task.dependsOn("pluginUnderTestMetadata"); } }
/** * Configure the eclipse task * * @param task Task to configure * @param pluginExtension Plugin extension */ @Mutate public void configureTasks(@Each Task task, GradlePluginDevelopmentExtension pluginExtension) { if (task.getName().equals("eclipse")) { task.dependsOn("pluginUnderTestMetadata"); } }
/** * Configure the eclipse task * * <ul> * <li>Make eclipse task depend on pluginUnterTestMetadata * </ul> * * @param task Task to configure * @param pluginExtension Plugin development extension * @param bundleExtension Plugin bundle extension */ @Mutate public void configureTasks(@Each Task task, GradlePluginDevelopmentExtension pluginExtension, PluginBundleExtension bundleExtension) { if (task.getName().equals("eclipse")) { task.dependsOn("pluginUnderTestMetadata"); } }
/** * Configure the eclipse task * * <ul> * <li>Make eclipse task depend on pluginUnterTestMetadata * </ul> * * @param task Task to configure * @param pluginExtension Plugin development extension * @param bundleExtension Plugin bundle extension */ @Mutate public void configureTasks(@Each Task task, GradlePluginDevelopmentExtension pluginExtension, PluginBundleExtension bundleExtension) { if (task.getName().equals("eclipse")) { task.dependsOn("pluginUnderTestMetadata"); } }
/** * Configure the wrapper task * * @param wrapper Wrapper task to configure * @param projectConfig Project configuration to get required Gradle version */ @Defaults public void configureWrapperTask(@Each Wrapper wrapper, ProjectConfig projectConfig) { if (!Strings.isNullOrEmpty(projectConfig.getGradleVersion())) { wrapper.setGradleVersion(projectConfig.getGradleVersion()); } }
/** * Configure the wrapper task * * @param wrapper Wrapper task to configure * @param projectConfig Project configuration to get required Gradle version */ @Defaults public void configureWrapperTask(@Each Wrapper wrapper, ProjectConfig projectConfig) { if (!Strings.isNullOrEmpty(projectConfig.getGradleVersion())) { wrapper.setGradleVersion(projectConfig.getGradleVersion()); } }
/** * Configure each Checkstyle task * * @param task Checkstyle task to configure * @param sources Source sets to get source directories * @param files File operations object to resolve file names */ @Defaults public void configureCheckstyleTask(@Each Checkstyle task, ProjectSourceSet sources, FileOperations files) { String sourceSetName = Tasks.namePart(CHECKSTYLE_TASK_PREFIX.matcher(task.getName()).replaceAll(""), AdjustCase.LOWER); Optional<JavaSourceSet> source = sources.withType(JavaSourceSet.class).stream() .filter(s -> s.getParentName().equals(sourceSetName)).findAny(); source.ifPresent(s -> { File checkstyleConfigFile = getCheckstyleConfigFile(Validate.notNull(s), files); if (checkstyleConfigFile.exists()) { task.setConfigFile(checkstyleConfigFile); } }); if (task.getConfigFile() != null && task.getConfigFile().getParentFile() != null) { task.getConfigProperties().putIfAbsent("config_loc", task.getConfigFile().getParent()); } }
/** * Configure each Checkstyle task * * @param task Checkstyle task to configure * @param sources Source sets to get source directories * @param files File operations object to resolve file names */ @Defaults public void configureCheckstyleTask(@Each Checkstyle task, ProjectSourceSet sources, FileOperations files) { String sourceSetName = Tasks.namePart(CHECKSTYLE_TASK_PREFIX.matcher(task.getName()).replaceAll(""), AdjustCase.LOWER); Optional<JavaSourceSet> source = sources.withType(JavaSourceSet.class).stream() .filter(s -> s.getParentName().equals(sourceSetName)).findAny(); source.ifPresent(s -> { File checkstyleConfigFile = getCheckstyleConfigFile(Validate.notNull(s), files); if (checkstyleConfigFile.exists()) { task.setConfigFile(checkstyleConfigFile); } }); if (task.getConfigFile() != null && task.getConfigFile().getParentFile() != null) { task.getConfigProperties().putIfAbsent("config_loc", task.getConfigFile().getParent()); } }
/** * Configure license tasks * * @param license License task to configure */ @Mutate public void configureLicenseTask(@Each License license) { // This seems to be the only way... license.doFirst(t -> { license.setSource( license.getSource().minus(t.getProject().fileTree(license.getProject().getBuildDir()))); }); }
/** * Configure license tasks * * @param license License task to configure */ @Mutate public void configureLicenseTask(@Each License license) { // This seems to be the only way... license.doFirst(t -> { license.setSource( license.getSource().minus(t.getProject().fileTree(license.getProject().getBuildDir()))); }); }
/** * Initialize a Docker image * * @param image Docker image to initialize * @param project Project context * @param files File operations */ @Defaults public void initializeImage(@Each DockerImage image, ProjectContext project, FileOperations files) { image.setDependsOn(new HashSet<>()); image.setFiles(files.copySpec()); image.setRepository(project.getName()); image.setTag(project.getVersion()); }
/** * Configure the Eclipse classpath task * * @param eclipseClasspath Eclipse classpath task to configure * @param eclipseConfigPlugin Eclipse configuration plugin to configure task */ @Mutate public void configureEclipseClasspathTask(@Each GenerateEclipseClasspath eclipseClasspath, EclipseConfigPlugin eclipseConfigPlugin) { EclipseClasspath classpath = eclipseClasspath.getClasspath(); classpath.setDownloadSources(true); classpath.setDownloadJavadoc(true); classpath.getContainers().remove(EclipseWtpPlugin.WEB_LIBS_CONTAINER); classpath.getFile().withXml(xml -> eclipseConfigPlugin.configureClasspathXml(Validate.notNull(xml))); }
/** * Configure the Eclipse JDT task * * @param eclipseJdt Eclipse JDT task */ @Mutate public void configureEclipseJdtTask(@Each GenerateEclipseJdt eclipseJdt) { Properties properties = loadProperties("org.eclipse.jdt.core.prefs"); eclipseJdt.getJdt().getFile().withProperties(p -> { properties.forEach((name, value) -> { p.computeIfAbsent(name, n -> value); }); }); }
/** * Configure the Eclipse classpath task * * @param eclipseClasspath Eclipse classpath task to configure * @param eclipseConfigPlugin Eclipse configuration plugin to configure task */ @Mutate public void configureEclipseClasspathTask(@Each GenerateEclipseClasspath eclipseClasspath, EclipseConfigPlugin eclipseConfigPlugin) { EclipseClasspath classpath = eclipseClasspath.getClasspath(); classpath.setDownloadSources(true); classpath.setDownloadJavadoc(true); classpath.getContainers().remove(EclipseWtpPlugin.WEB_LIBS_CONTAINER); classpath.getFile().withXml(xml -> eclipseConfigPlugin.configureClasspathXml(Validate.notNull(xml))); }
/** * Configure the Eclipse JDT task * * @param eclipseJdt Eclipse JDT task */ @Mutate public void configureEclipseJdtTask(@Each GenerateEclipseJdt eclipseJdt) { Properties properties = loadProperties("org.eclipse.jdt.core.prefs"); eclipseJdt.getJdt().getFile().withProperties(p -> { properties.forEach((name, value) -> { p.computeIfAbsent(name, n -> value); }); }); }