use of com.thomasjensen.checkstyle.addons.build.DependencyConfig in project checkstyle-addons by checkstyle-addons.
the class PrintDepConfigsTask method printDepConfigs.
@TaskAction
public void printDepConfigs() {
final Logger log = getProject().getLogger();
log.info("-----------------------------------------------------------------------------------------------");
log.lifecycle("Dependency Configurations:");
log.lifecycle("--------------------------");
log.lifecycle("Default Checkstyle version: " + depConfigs.getDefault().getCheckstyleBaseVersion());
log.lifecycle("Active dependency configurations:");
for (Map.Entry<String, DependencyConfig> entry : depConfigs.getAll().entrySet()) {
DependencyConfig depConfig = entry.getValue();
log.lifecycle(" - " + entry.getKey() + ": Checkstyle " + depConfig.getCheckstyleBaseVersion() + ", Java " + depConfig.getJavaLevel() + ", compatible: " + depConfig.getCompatibleCheckstyleVersions());
}
log.info("-----------------------------------------------------------------------------------------------");
log.info("Full contents:");
for (final Map.Entry<String, DependencyConfig> entry : depConfigs.getAll().entrySet()) {
log.info(" - " + entry.getKey() + ":\t" + entry.getValue());
}
log.info("-----------------------------------------------------------------------------------------------");
}
use of com.thomasjensen.checkstyle.addons.build.DependencyConfig in project checkstyle-addons by checkstyle-addons.
the class SiteCopyAllChecksConfigAction method configureTaskFor.
@Override
protected void configureTaskFor(@Nonnull Copy pCopyTask, @Nullable DependencyConfig pUnused) {
pCopyTask.setDescription("Copy list of all checks to site directory");
pCopyTask.setGroup(SiteTask.SITE_GROUP);
pCopyTask.setDestinationDir(new File(project.getBuildDir(), "site"));
final SourceSet mainSourceSet = buildUtil.getSourceSet(SourceSet.MAIN_SOURCE_SET_NAME);
final String checksPackage = buildUtil.getBuildConfig().getChecksPackage().get();
final File originalFile = new File(mainSourceSet.getResources().getSrcDirs().iterator().next(), "/" + checksPackage + "/all_checks.html");
final Action<CopySpec> action = copySpec -> {
copySpec.from(originalFile);
copySpec.rename((String fileName) -> fileName.replace(originalFile.getName(), "index.html"));
copySpec.filter(buildReplacements(project), ReplaceTokens.class);
};
pCopyTask.into("v" + project.getVersion() + "/checks", action);
pCopyTask.into("latest/checks", action);
}
use of com.thomasjensen.checkstyle.addons.build.DependencyConfig in project checkstyle-addons by checkstyle-addons.
the class JarConfigAction method configureTaskFor.
@Override
protected void configureTaskFor(@Nonnull Jar pJarTask, @Nullable DependencyConfig pDepConfig) {
Objects.requireNonNull(pDepConfig, "required dependency config not present");
final BuildConfigExtension buildConfig = buildUtil.getBuildConfig();
final TaskContainer tasks = project.getTasks();
pJarTask.setGroup(TaskCreator.ARTIFACTS_GROUP_NAME);
pJarTask.setDescription("Assembles a jar archive containing the '" + SourceSet.MAIN_SOURCE_SET_NAME + "' classes for dependency configuration '" + pDepConfig.getName() + "'");
// set appendix for archive name
final String appendix = pDepConfig.getName();
if (!pDepConfig.isDefaultConfig()) {
pJarTask.getArchiveAppendix().set(appendix);
}
// Dependency on pom.properties generating task
pJarTask.dependsOn(tasks.named(TaskNames.generatePomProperties.getName(pDepConfig)));
// Task Input: pom.properties file
final File pomPropsUsed = ((GeneratePomPropsTask) tasks.getByName(TaskNames.generatePomProperties.getName(pDepConfig))).getPluginPomProps();
pJarTask.getInputs().file(pomPropsUsed);
// Dependency on pom.xml generating task
final GenerateMavenPom generatePomTask = buildUtil.getTask(TaskNames.generatePomFileForCheckstyleAddonsPublication, GenerateMavenPom.class, pDepConfig);
pJarTask.dependsOn(generatePomTask);
// Dependency on 'classes' task (compile and resources)
pJarTask.dependsOn(buildUtil.getTaskProvider(TaskNames.mainClasses, Task.class, pDepConfig));
// Configuration of JAR file contents
pJarTask.from(generatePomTask.getDestination(), copySpec -> copySpec.rename(filename -> filename.replace("pom-default.xml", "pom.xml")));
final SourceSet mainSourceSet = buildUtil.getSourceSet(SourceSet.MAIN_SOURCE_SET_NAME);
pJarTask.from(new ClasspathBuilder(project).getClassesDirs(mainSourceSet, pDepConfig));
pJarTask.from(mainSourceSet.getOutput().getResourcesDir());
pJarTask.exclude("download-guide.html", "**/*.md", "**/checks/all_checks.html", "eclipsecs-plugin.xml", "**/checkstyle-metadata.*");
pJarTask.into("META-INF", copySpec -> copySpec.from("LICENSE"));
// add generated pom.xml and pom.properties to archive, setting build timestamp in the process
pJarTask.into("META-INF/maven/" + project.getGroup() + "/" + project.getName(), copySpec -> {
copySpec.from(generatePomTask.getDestination());
copySpec.rename(filename -> filename.replace("pom-default.xml", "pom.xml"));
copySpec.from(pomPropsUsed);
Map<String, String> placeHolders = new HashMap<>();
placeHolders.put("buildTimestamp", buildConfig.getBuildTimestamp().get().toString());
Map<String, Object> propsMap = new HashMap<>();
propsMap.put("tokens", placeHolders);
copySpec.filter(propsMap, ReplaceTokens.class);
});
// Manifest
configureManifest(pJarTask, pDepConfig, appendix);
}
use of com.thomasjensen.checkstyle.addons.build.DependencyConfig in project checkstyle-addons by checkstyle-addons.
the class SiteCopyDownloadGuideConfigAction method configureTaskFor.
@Override
protected void configureTaskFor(@Nonnull Copy pCopyTask, @Nullable DependencyConfig pUnused) {
pCopyTask.setDescription("Copy download guide frontmatter stub to site directory");
pCopyTask.setGroup(SiteTask.SITE_GROUP);
pCopyTask.setDestinationDir(new File(project.getBuildDir(), "site"));
final SourceSet mainSourceSet = buildUtil.getSourceSet(SourceSet.MAIN_SOURCE_SET_NAME);
final File originalFile = new File(mainSourceSet.getResources().getSrcDirs().iterator().next(), "/download-guide.html");
final Action<CopySpec> action = copySpec -> {
copySpec.from(originalFile);
copySpec.filter(SiteCopyAllChecksConfigAction.buildReplacements(project), ReplaceTokens.class);
};
pCopyTask.into("v" + project.getVersion(), action);
pCopyTask.into("latest", action);
}
Aggregations