use of org.gradle.api.tasks.SourceSet in project gradle-apt-plugin by tbroyer.
the class AptIdeaPlugin method configureIdeaModule.
private void configureIdeaModule(Project project, final SourceSet mainSourceSet, final SourceSet testSourceSet) {
final IdeaModule ideaModule = project.getExtensions().getByType(IdeaModel.class).getModule();
final ModuleApt apt = new ModuleApt();
new DslObject(ideaModule).getConvention().getPlugins().put("net.ltgt.apt-idea", new ModuleAptConvention(apt));
project.afterEvaluate(new Action<Project>() {
@Override
public void execute(Project project) {
if (apt.isAddGeneratedSourcesDirs()) {
Set<File> excl = new LinkedHashSet<>();
for (SourceSet sourceSet : new SourceSet[] { mainSourceSet, testSourceSet }) {
File generatedSourcesDir = new DslObject(sourceSet.getOutput()).getConvention().getPlugin(AptPlugin.AptSourceSetOutputConvention.class).getGeneratedSourcesDir();
for (File f = generatedSourcesDir; f != null && !f.equals(project.getProjectDir()); f = f.getParentFile()) {
excl.add(f);
}
}
// For some reason, modifying the existing collections doesn't work.
// We need to copy the values and then assign it back.
Set<File> excludeDirs = new LinkedHashSet<>(ideaModule.getExcludeDirs());
if (excl.contains(project.getBuildDir()) && excludeDirs.contains(project.getBuildDir())) {
excludeDirs.remove(project.getBuildDir());
// Race condition: many of these will actually be created afterwards…
File[] subdirs = project.getBuildDir().listFiles(new FileFilter() {
@Override
public boolean accept(File pathname) {
return pathname.isDirectory();
}
});
if (subdirs != null) {
excludeDirs.addAll(Arrays.asList(subdirs));
}
}
excludeDirs.removeAll(excl);
ideaModule.setExcludeDirs(excludeDirs);
File mainGeneratedSourcesDir = new DslObject(mainSourceSet.getOutput()).getConvention().getPlugin(AptPlugin.AptSourceSetOutputConvention.class).getGeneratedSourcesDir();
File testGeneratedSourcesDir = new DslObject(testSourceSet.getOutput()).getConvention().getPlugin(AptPlugin.AptSourceSetOutputConvention.class).getGeneratedSourcesDir();
// For some reason, modifying the existing collections doesn't work.
// We need to copy the values and then assign it back.
ideaModule.setSourceDirs(addToSet(ideaModule.getSourceDirs(), mainGeneratedSourcesDir));
ideaModule.setTestSourceDirs(addToSet(ideaModule.getTestSourceDirs(), testGeneratedSourcesDir));
ideaModule.setGeneratedSourceDirs(addToSet(ideaModule.getGeneratedSourceDirs(), mainGeneratedSourcesDir, testGeneratedSourcesDir));
}
if (apt.isAddCompileOnlyDependencies() || apt.isAddAptDependencies()) {
final AptPlugin.AptSourceSetConvention mainSourceSetConvention = new DslObject(mainSourceSet).getConvention().getPlugin(AptPlugin.AptSourceSetConvention.class);
final AptPlugin.AptSourceSetConvention testSourceSetConvention = new DslObject(testSourceSet).getConvention().getPlugin(AptPlugin.AptSourceSetConvention.class);
final List<Configuration> mainConfigurations = new ArrayList<>();
final List<Configuration> testConfigurations = new ArrayList<>();
if (apt.isAddCompileOnlyDependencies()) {
mainConfigurations.add(project.getConfigurations().getByName(mainSourceSetConvention.getCompileOnlyConfigurationName()));
testConfigurations.add(project.getConfigurations().getByName(testSourceSetConvention.getCompileOnlyConfigurationName()));
}
if (apt.isAddAptDependencies()) {
mainConfigurations.add(project.getConfigurations().getByName(mainSourceSetConvention.getAnnotationProcessorConfigurationName()));
testConfigurations.add(project.getConfigurations().getByName(testSourceSetConvention.getAnnotationProcessorConfigurationName()));
}
ideaModule.getScopes().get(apt.getMainDependenciesScope()).get("plus").addAll(mainConfigurations);
ideaModule.getScopes().get("TEST").get("plus").addAll(testConfigurations);
project.getTasks().withType(GenerateIdeaModule.class, new Action<GenerateIdeaModule>() {
@Override
public void execute(GenerateIdeaModule generateIdeaModule) {
generateIdeaModule.dependsOn(mainConfigurations.toArray());
generateIdeaModule.dependsOn(testConfigurations.toArray());
}
});
}
}
private Set<File> addToSet(Set<File> sourceDirs, File... dirs) {
Set<File> newSet = new LinkedHashSet<>(sourceDirs);
newSet.addAll(Arrays.asList(dirs));
return newSet;
}
});
}
use of org.gradle.api.tasks.SourceSet in project gradle-apt-plugin by tbroyer.
the class AptPlugin method apply.
@Override
public void apply(final Project project) {
configureCompileTasks(project, JavaCompile.class, new GetCompileOptions<JavaCompile>() {
@Override
public CompileOptions getCompileOptions(JavaCompile task) {
return task.getOptions();
}
});
configureCompileTasks(project, GroovyCompile.class, new GetCompileOptions<GroovyCompile>() {
@Override
public CompileOptions getCompileOptions(GroovyCompile task) {
return task.getOptions();
}
});
project.getPlugins().withType(JavaBasePlugin.class, new Action<JavaBasePlugin>() {
@Override
public void execute(JavaBasePlugin javaBasePlugin) {
final JavaPluginConvention javaConvention = project.getConvention().getPlugin(JavaPluginConvention.class);
javaConvention.getSourceSets().all(new Action<SourceSet>() {
@Override
public void execute(final SourceSet sourceSet) {
AptSourceSetConvention convention = IMPL.createAptSourceSetConvention(project, sourceSet);
new DslObject(sourceSet).getConvention().getPlugins().put(PLUGIN_ID, convention);
AptSourceSetOutputConvention outputConvention = new AptSourceSetOutputConvention(project);
outputConvention.setGeneratedSourcesDir(new File(project.getBuildDir(), "generated/source/apt/" + sourceSet.getName()));
new DslObject(sourceSet.getOutput()).getConvention().getPlugins().put(PLUGIN_ID, outputConvention);
ensureConfigurations(project, sourceSet, convention);
configureCompileTaskForSourceSet(project, sourceSet, sourceSet.getCompileJavaTaskName(), JavaCompile.class, new GetCompileOptions<JavaCompile>() {
@Override
public CompileOptions getCompileOptions(JavaCompile task) {
return task.getOptions();
}
});
}
});
}
});
project.getPlugins().withType(GroovyBasePlugin.class, new Action<GroovyBasePlugin>() {
@Override
public void execute(GroovyBasePlugin groovyBasePlugin) {
JavaPluginConvention javaConvention = project.getConvention().getPlugin(JavaPluginConvention.class);
javaConvention.getSourceSets().all(new Action<SourceSet>() {
@Override
public void execute(SourceSet sourceSet) {
AptSourceSetConvention convention = new DslObject(sourceSet).getConvention().getPlugin(AptSourceSetConvention.class);
configureCompileTaskForSourceSet(project, sourceSet, sourceSet.getCompileTaskName("groovy"), GroovyCompile.class, new GetCompileOptions<GroovyCompile>() {
@Override
public CompileOptions getCompileOptions(GroovyCompile task) {
return task.getOptions();
}
});
}
});
}
});
}
use of org.gradle.api.tasks.SourceSet in project spring-security by spring-projects.
the class S101Configurer method hspTemplateValues.
private Map<String, Object> hspTemplateValues(String version, File configurationDirectory) {
Map<String, Object> values = new LinkedHashMap<>();
values.put("version", version);
values.put("patchVersion", version.split("\\.")[2]);
values.put("relativeTo", "const(THIS_FILE)/" + configurationDirectory.toPath().relativize(this.project.getProjectDir().toPath()));
List<Map<String, Object>> entries = new ArrayList<>();
Set<Project> projects = this.project.getAllprojects();
for (Project p : projects) {
SourceSetContainer sourceSets = (SourceSetContainer) p.getExtensions().findByName("sourceSets");
if (sourceSets == null) {
continue;
}
for (SourceSet source : sourceSets) {
Set<File> classDirs = source.getOutput().getClassesDirs().getFiles();
for (File directory : classDirs) {
Map<String, Object> entry = new HashMap<>();
entry.put("path", this.project.getProjectDir().toPath().relativize(directory.toPath()));
entry.put("module", p.getName());
entries.add(entry);
}
}
}
values.put("entries", entries);
return values;
}
use of org.gradle.api.tasks.SourceSet in project rest.li by linkedin.
the class PegasusPlugin method configureRestModelGeneration.
protected void configureRestModelGeneration(Project project, SourceSet sourceSet) {
if (sourceSet.getAllSource().isEmpty()) {
project.getLogger().info("No source files found for sourceSet {}. Skipping idl generation.", sourceSet.getName());
return;
}
// afterEvaluate needed so that api project can be overridden via ext.apiProject
project.afterEvaluate(p -> {
// find api project here instead of in each project's plugin configuration
// this allows api project relation options (ext.api*) to be specified anywhere in the build.gradle file
// alternatively, pass closures to task configuration, and evaluate the closures when task is executed
Project apiProject = getCheckedApiProject(project);
// make sure the api project is evaluated. Important for configure-on-demand mode.
if (apiProject != null) {
project.evaluationDependsOn(apiProject.getPath());
if (!apiProject.getPlugins().hasPlugin(_thisPluginType)) {
apiProject = null;
}
}
if (apiProject == null) {
return;
}
Task untypedJarTask = project.getTasks().findByName(sourceSet.getJarTaskName());
if (!(untypedJarTask instanceof Jar)) {
return;
}
Jar jarTask = (Jar) untypedJarTask;
String snapshotCompatPropertyName = findProperty(FileCompatibilityType.SNAPSHOT);
if (project.hasProperty(snapshotCompatPropertyName) && "off".equalsIgnoreCase((String) project.property(snapshotCompatPropertyName))) {
project.getLogger().lifecycle("Project {} snapshot compatibility level \"OFF\" is deprecated. Default to \"IGNORE\".", project.getPath());
}
// generate the rest model
FileCollection restModelCodegenClasspath = project.getConfigurations().getByName(PEGASUS_PLUGIN_CONFIGURATION).plus(project.getConfigurations().getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME)).plus(sourceSet.getRuntimeClasspath());
String destinationDirPrefix = getGeneratedDirPath(project, sourceSet, REST_GEN_TYPE) + File.separatorChar;
FileCollection restModelResolverPath = apiProject.files(getDataSchemaPath(project, sourceSet)).plus(getDataModelConfig(apiProject, sourceSet));
Set<File> watchedRestModelInputDirs = buildWatchedRestModelInputDirs(project, sourceSet);
Set<File> restModelInputDirs = difference(sourceSet.getAllSource().getSrcDirs(), sourceSet.getResources().getSrcDirs());
Task generateRestModelTask = project.getTasks().create(sourceSet.getTaskName("generate", "restModel"), GenerateRestModelTask.class, task -> {
task.dependsOn(project.getTasks().getByName(sourceSet.getClassesTaskName()));
task.setCodegenClasspath(restModelCodegenClasspath);
task.setWatchedCodegenClasspath(restModelCodegenClasspath.filter(file -> !"main".equals(file.getName()) && !"classes".equals(file.getName())));
task.setInputDirs(restModelInputDirs);
task.setWatchedInputDirs(watchedRestModelInputDirs.isEmpty() ? restModelInputDirs : watchedRestModelInputDirs);
// we need all the artifacts from runtime for any private implementation classes the server code might need.
task.setSnapshotDestinationDir(project.file(destinationDirPrefix + "snapshot"));
task.setIdlDestinationDir(project.file(destinationDirPrefix + "idl"));
@SuppressWarnings("unchecked") Map<String, PegasusOptions> pegasusOptions = (Map<String, PegasusOptions>) project.getExtensions().getExtraProperties().get("pegasus");
task.setIdlOptions(pegasusOptions.get(sourceSet.getName()).idlOptions);
task.setResolverPath(restModelResolverPath);
if (isPropertyTrue(project, ENABLE_ARG_FILE)) {
task.setEnableArgFile(true);
}
task.onlyIf(t -> !isPropertyTrue(project, SKIP_GENERATE_REST_MODEL));
task.doFirst(new CacheableAction<>(t -> deleteGeneratedDir(project, sourceSet, REST_GEN_TYPE)));
});
File apiSnapshotDir = apiProject.file(getSnapshotPath(apiProject, sourceSet));
File apiIdlDir = apiProject.file(getIdlPath(apiProject, sourceSet));
apiSnapshotDir.mkdirs();
if (!isPropertyTrue(project, SKIP_IDL_CHECK)) {
apiIdlDir.mkdirs();
}
CheckRestModelTask checkRestModelTask = project.getTasks().create(sourceSet.getTaskName("check", "RestModel"), CheckRestModelTask.class, task -> {
task.dependsOn(generateRestModelTask);
task.setCurrentSnapshotFiles(SharedFileUtils.getSnapshotFiles(project, destinationDirPrefix));
task.setPreviousSnapshotDirectory(apiSnapshotDir);
task.setCurrentIdlFiles(SharedFileUtils.getIdlFiles(project, destinationDirPrefix));
task.setPreviousIdlDirectory(apiIdlDir);
task.setCodegenClasspath(project.getConfigurations().getByName(PEGASUS_PLUGIN_CONFIGURATION));
task.setModelCompatLevel(PropertyUtil.findCompatLevel(project, FileCompatibilityType.SNAPSHOT));
task.onlyIf(t -> !isPropertyTrue(project, SKIP_IDL_CHECK));
task.doLast(new CacheableAction<>(t -> {
if (!task.isEquivalent()) {
_restModelCompatMessage.append(task.getWholeMessage());
}
}));
});
CheckSnapshotTask checkSnapshotTask = project.getTasks().create(sourceSet.getTaskName("check", "Snapshot"), CheckSnapshotTask.class, task -> {
task.dependsOn(generateRestModelTask);
task.setCurrentSnapshotFiles(SharedFileUtils.getSnapshotFiles(project, destinationDirPrefix));
task.setPreviousSnapshotDirectory(apiSnapshotDir);
task.setCodegenClasspath(project.getConfigurations().getByName(PEGASUS_PLUGIN_CONFIGURATION));
task.setSnapshotCompatLevel(PropertyUtil.findCompatLevel(project, FileCompatibilityType.SNAPSHOT));
task.onlyIf(t -> isPropertyTrue(project, SKIP_IDL_CHECK));
});
CheckIdlTask checkIdlTask = project.getTasks().create(sourceSet.getTaskName("check", "Idl"), CheckIdlTask.class, task -> {
task.dependsOn(generateRestModelTask);
task.setCurrentIdlFiles(SharedFileUtils.getIdlFiles(project, destinationDirPrefix));
task.setPreviousIdlDirectory(apiIdlDir);
task.setResolverPath(restModelResolverPath);
task.setCodegenClasspath(project.getConfigurations().getByName(PEGASUS_PLUGIN_CONFIGURATION));
task.setIdlCompatLevel(PropertyUtil.findCompatLevel(project, FileCompatibilityType.IDL));
if (isPropertyTrue(project, ENABLE_ARG_FILE)) {
task.setEnableArgFile(true);
}
task.onlyIf(t -> !isPropertyTrue(project, SKIP_IDL_CHECK) && !"OFF".equals(PropertyUtil.findCompatLevel(project, FileCompatibilityType.IDL)));
});
// rest model publishing involves cross-project reference
// configure after all projects have been evaluated
// the file copy can be turned off by "rest.model.noPublish" flag
Task publishRestliSnapshotTask = project.getTasks().create(sourceSet.getTaskName("publish", "RestliSnapshot"), PublishRestModelTask.class, task -> {
task.dependsOn(checkRestModelTask, checkSnapshotTask, checkIdlTask);
task.from(SharedFileUtils.getSnapshotFiles(project, destinationDirPrefix));
task.into(apiSnapshotDir);
task.setSuffix(SNAPSHOT_FILE_SUFFIX);
task.onlyIf(t -> !isPropertyTrue(project, SNAPSHOT_NO_PUBLISH) && ((isPropertyTrue(project, SKIP_IDL_CHECK) && isTaskSuccessful(checkSnapshotTask) && checkSnapshotTask.getSummaryTarget().exists() && !isResultEquivalent(checkSnapshotTask.getSummaryTarget())) || (!isPropertyTrue(project, SKIP_IDL_CHECK) && isTaskSuccessful(checkRestModelTask) && checkRestModelTask.getSummaryTarget().exists() && !isResultEquivalent(checkRestModelTask.getSummaryTarget()))));
});
Task publishRestliIdlTask = project.getTasks().create(sourceSet.getTaskName("publish", "RestliIdl"), PublishRestModelTask.class, task -> {
task.dependsOn(checkRestModelTask, checkIdlTask, checkSnapshotTask);
task.from(SharedFileUtils.getIdlFiles(project, destinationDirPrefix));
task.into(apiIdlDir);
task.setSuffix(IDL_FILE_SUFFIX);
task.onlyIf(t -> !isPropertyTrue(project, IDL_NO_PUBLISH) && ((isPropertyTrue(project, SKIP_IDL_CHECK) && isTaskSuccessful(checkSnapshotTask) && checkSnapshotTask.getSummaryTarget().exists() && !isResultEquivalent(checkSnapshotTask.getSummaryTarget(), true)) || (!isPropertyTrue(project, SKIP_IDL_CHECK) && ((isTaskSuccessful(checkRestModelTask) && checkRestModelTask.getSummaryTarget().exists() && !isResultEquivalent(checkRestModelTask.getSummaryTarget(), true)) || (isTaskSuccessful(checkIdlTask) && checkIdlTask.getSummaryTarget().exists() && !isResultEquivalent(checkIdlTask.getSummaryTarget()))))));
});
project.getLogger().info("API project selected for {} is {}", publishRestliIdlTask.getPath(), apiProject.getPath());
jarTask.from(SharedFileUtils.getIdlFiles(project, destinationDirPrefix));
// add generated .restspec.json files as resources to the jar
jarTask.dependsOn(publishRestliSnapshotTask, publishRestliIdlTask);
ChangedFileReportTask changedFileReportTask = (ChangedFileReportTask) project.getTasks().getByName("changedFilesReport");
// Use the files from apiDir for generating the changed files report as we need to notify user only when
// source system files are modified.
changedFileReportTask.setIdlFiles(SharedFileUtils.getSuffixedFiles(project, apiIdlDir, IDL_FILE_SUFFIX));
changedFileReportTask.setSnapshotFiles(SharedFileUtils.getSuffixedFiles(project, apiSnapshotDir, SNAPSHOT_FILE_SUFFIX));
changedFileReportTask.mustRunAfter(publishRestliSnapshotTask, publishRestliIdlTask);
changedFileReportTask.doLast(new CacheableAction<>(t -> {
if (!changedFileReportTask.getNeedCheckinFiles().isEmpty()) {
project.getLogger().info("Adding modified files to need checkin list...");
_needCheckinFiles.addAll(changedFileReportTask.getNeedCheckinFiles());
_needBuildFolders.add(getCheckedApiProject(project).getPath());
}
}));
});
}
use of org.gradle.api.tasks.SourceSet in project rest.li by linkedin.
the class PegasusPlugin method configureRestClientGeneration.
// Generate rest client from idl files generated from java source files in the specified source set.
//
// This generates rest client source files from idl file generated from java source files
// in the source set. The generated rest client source files will be in a new source set.
// It also compiles the rest client source files into classes, and creates both the
// rest model and rest client jar files.
//
@SuppressWarnings("deprecation")
protected void configureRestClientGeneration(Project project, SourceSet sourceSet) {
// idl directory for api project
File idlDir = project.file(getIdlPath(project, sourceSet));
if (SharedFileUtils.getSuffixedFiles(project, idlDir, IDL_FILE_SUFFIX).isEmpty()) {
return;
}
File generatedRestClientDir = project.file(getGeneratedDirPath(project, sourceSet, REST_GEN_TYPE) + File.separatorChar + "java");
// always include imported data template jars in compileClasspath of rest client
FileCollection dataModelConfig = getDataModelConfig(project, sourceSet);
// if data templates generated from this source set, add the generated data template jar to compileClasspath
// of rest client.
String dataTemplateSourceSetName = getGeneratedSourceSetName(sourceSet, DATA_TEMPLATE_GEN_TYPE);
Jar dataTemplateJarTask = null;
SourceSetContainer sourceSets = project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets();
FileCollection dataModels;
if (sourceSets.findByName(dataTemplateSourceSetName) != null) {
if (debug) {
System.out.println("sourceSet " + sourceSet.getName() + " has generated sourceSet " + dataTemplateSourceSetName);
}
dataTemplateJarTask = (Jar) project.getTasks().getByName(sourceSet.getName() + "DataTemplateJar");
// FIXME change to #getArchiveFile(); breaks backwards-compatibility before 5.1
dataModels = dataModelConfig.plus(project.files(dataTemplateJarTask.getArchivePath()));
} else {
dataModels = dataModelConfig;
}
// create source set for generated rest model, rest client source and class files.
String targetSourceSetName = getGeneratedSourceSetName(sourceSet, REST_GEN_TYPE);
SourceSet targetSourceSet = sourceSets.create(targetSourceSetName, ss -> {
ss.java(sourceDirectorySet -> sourceDirectorySet.srcDir(generatedRestClientDir));
ss.setCompileClasspath(dataModels.plus(project.getConfigurations().getByName("restClientCompile")));
});
project.getPlugins().withType(EclipsePlugin.class, eclipsePlugin -> {
EclipseModel eclipseModel = (EclipseModel) project.getExtensions().findByName("eclipse");
eclipseModel.getClasspath().getPlusConfigurations().add(project.getConfigurations().getByName("restClientCompile"));
});
// idea plugin needs to know about new rest client source directory and its dependencies
addGeneratedDir(project, targetSourceSet, Arrays.asList(getDataModelConfig(project, sourceSet), project.getConfigurations().getByName("restClientCompile")));
// generate the rest client source files
GenerateRestClientTask generateRestClientTask = project.getTasks().create(targetSourceSet.getTaskName("generate", "restClient"), GenerateRestClientTask.class, task -> {
task.dependsOn(project.getConfigurations().getByName("dataTemplate"));
task.setInputDir(idlDir);
task.setResolverPath(dataModels.plus(project.getConfigurations().getByName("restClientCompile")));
task.setRuntimeClasspath(project.getConfigurations().getByName("dataModel").plus(project.getConfigurations().getByName("dataTemplate").getArtifacts().getFiles()));
task.setCodegenClasspath(project.getConfigurations().getByName(PEGASUS_PLUGIN_CONFIGURATION));
task.setDestinationDir(generatedRestClientDir);
task.setRestli2FormatSuppressed(project.hasProperty(SUPPRESS_REST_CLIENT_RESTLI_2));
task.setRestli1FormatSuppressed(project.hasProperty(SUPPRESS_REST_CLIENT_RESTLI_1));
if (isPropertyTrue(project, ENABLE_ARG_FILE)) {
task.setEnableArgFile(true);
}
if (isPropertyTrue(project, CODE_GEN_PATH_CASE_SENSITIVE)) {
task.setGenerateLowercasePath(false);
}
if (isPropertyTrue(project, ENABLE_FLUENT_API)) {
task.setGenerateFluentApi(true);
}
task.doFirst(new CacheableAction<>(t -> project.delete(generatedRestClientDir)));
});
if (dataTemplateJarTask != null) {
generateRestClientTask.dependsOn(dataTemplateJarTask);
}
// TODO: Tighten the types so that _generateSourcesJarTask must be of type Jar.
((Jar) _generateSourcesJarTask).from(generateRestClientTask.getDestinationDir());
_generateSourcesJarTask.dependsOn(generateRestClientTask);
_generateJavadocTask.source(generateRestClientTask.getDestinationDir());
_generateJavadocTask.setClasspath(_generateJavadocTask.getClasspath().plus(project.getConfigurations().getByName("restClientCompile")).plus(generateRestClientTask.getResolverPath()));
_generateJavadocTask.dependsOn(generateRestClientTask);
// make sure rest client source files have been generated before compiling them
JavaCompile compileGeneratedRestClientTask = (JavaCompile) project.getTasks().getByName(targetSourceSet.getCompileJavaTaskName());
compileGeneratedRestClientTask.dependsOn(generateRestClientTask);
compileGeneratedRestClientTask.getOptions().getCompilerArgs().add("-Xlint:-deprecation");
// create the rest model jar file
Task restModelJarTask = project.getTasks().create(sourceSet.getName() + "RestModelJar", Jar.class, task -> {
task.from(idlDir, copySpec -> {
copySpec.eachFile(fileCopyDetails -> project.getLogger().info("Add idl file: {}", fileCopyDetails));
copySpec.setIncludes(Collections.singletonList('*' + IDL_FILE_SUFFIX));
});
// FIXME change to #getArchiveAppendix().set(...); breaks backwards-compatibility before 5.1
task.setAppendix(getAppendix(sourceSet, "rest-model"));
task.setDescription("Generate rest model jar");
});
// create the rest client jar file
Task restClientJarTask = project.getTasks().create(sourceSet.getName() + "RestClientJar", Jar.class, task -> {
task.dependsOn(compileGeneratedRestClientTask);
task.from(idlDir, copySpec -> {
copySpec.eachFile(fileCopyDetails -> {
project.getLogger().info("Add interface file: {}", fileCopyDetails);
fileCopyDetails.setPath("idl" + File.separatorChar + fileCopyDetails.getPath());
});
copySpec.setIncludes(Collections.singletonList('*' + IDL_FILE_SUFFIX));
});
task.from(targetSourceSet.getOutput());
// FIXME change to #getArchiveAppendix().set(...); breaks backwards-compatibility before 5.1
task.setAppendix(getAppendix(sourceSet, "rest-client"));
task.setDescription("Generate rest client jar");
});
// add the rest model jar and the rest client jar to the list of project artifacts.
if (!isTestSourceSet(sourceSet)) {
project.getArtifacts().add("restModel", restModelJarTask);
project.getArtifacts().add("restClient", restClientJarTask);
} else {
project.getArtifacts().add("testRestModel", restModelJarTask);
project.getArtifacts().add("testRestClient", restClientJarTask);
}
}
Aggregations