use of com.github.jengelman.gradle.plugins.shadow.internal.DependencyFilter in project checkstyle-addons by checkstyle-addons.
the class FatJarConfigAction method configureTaskFor.
@Override
protected void configureTaskFor(@Nonnull ShadowJar pFatJarTask, @Nullable DependencyConfig pDepConfig) {
Objects.requireNonNull(pDepConfig, "required dependency config not present");
pFatJarTask.setGroup(TaskCreator.ARTIFACTS_GROUP_NAME);
pFatJarTask.getArchiveClassifier().set("all");
// set appendix for archive name
final String appendix = pDepConfig.getName();
if (!pDepConfig.isDefaultConfig()) {
pFatJarTask.getArchiveAppendix().set(appendix);
}
// dependency on the corresponding (thin) Jar task
final Jar thinJarTask = buildUtil.getTask(TaskNames.jar, Jar.class, pDepConfig);
pFatJarTask.dependsOn(thinJarTask);
pFatJarTask.setDescription("Create a combined JAR of project and runtime dependencies of '" + SourceSet.MAIN_SOURCE_SET_NAME + "' for dependency configuration '" + pDepConfig.getName() + "'");
buildUtil.inheritManifest(pFatJarTask, pDepConfig);
pFatJarTask.from(thinJarTask.getArchiveFile());
Configuration cfg = new ClasspathBuilder(project).buildMainRuntimeConfiguration(pDepConfig);
pFatJarTask.setConfigurations(Collections.singletonList(cfg));
pFatJarTask.exclude("META-INF/INDEX.LIST", "META-INF/*.SF", "META-INF/*.DSA", "META-INF/*.RSA", "META-INF/maven/**/*", "pom.xml");
final Set<String> deps = getNonCheckstyleDeps(cfg);
if (deps.size() > 0) {
// append all licenses found in dependent Jars into one
pFatJarTask.append("META-INF/LICENSE");
pFatJarTask.dependencies((final DependencyFilter pDependencyFilter) -> {
for (String dep : deps) {
pDependencyFilter.include(pDependencyFilter.dependency(dep));
}
});
}
}
Aggregations