Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update task ordering #103

Merged
merged 3 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,17 @@ private void configureSourceSetDefaults(Project project, SmithyExtension extensi
project.getExtensions().getByType(SourceSetContainer.class).all(sourceSet -> {
createConfigurations(sourceSet, project.getConfigurations());
SmithySourceDirectorySet sds = registerSourceSets(sourceSet, extension);

String cliVersion = CliDependencyResolver.resolve(project, sourceSet);
if (extension.getFormat().get() && cliVersionSupportsFormat(cliVersion)) {
addFormatTaskForSourceSet(sourceSet, sds, extension);
}

TaskProvider<SmithyBuildTask> buildTaskTaskProvider = addBuildTaskForSourceSet(sourceSet, sds, extension);
// Ensure smithy-build is executed as part of building the "main" feature
if (SourceSet.isMain(sourceSet)) {
project.getTasks().getByName("build").dependsOn(buildTaskTaskProvider);
}

// Add format task for source set if enabled and the CLI version supports it
String cliVersion = CliDependencyResolver.resolve(project, sourceSet);
if (extension.getFormat().get() && cliVersionSupportsFormat(cliVersion)) {
addFormatTaskForSourceSet(sourceSet, sds, extension);
}
});
}

Expand Down Expand Up @@ -155,8 +155,9 @@ private void addFormatTaskForSourceSet(SourceSet sourceSet, SmithySourceDirector
formatTask.setEnabled(extension.getFormat().get());
});

// Smithy files should be formatted before they are built
if (SourceSet.isMain(sourceSet)) {
project.getTasks().getByName("build").dependsOn(smithyFormat);
project.getTasks().getByName(SMITHY_BUILD_TASK_NAME).dependsOn(smithyFormat);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class SmithyJarPlugin implements Plugin<Project> {
"org.jetbrains.kotlin.jvm",
"org.jetbrains.kotlin.android"
);
private static final List<String> SUPPORTED_LANGUAGES = ListUtils.of("java", "kotlin", "scala");
private boolean wasApplied = false;
private SmithyExtension extension;

Expand Down Expand Up @@ -111,10 +112,18 @@ private void addJavaTasksForSourceSet(SourceSet sourceSet, SmithyBuildTask build
// resources that were found in each search location. This can cause conflicts
// between the META-INF/smithy files and staging directory, so we need to
// ignore duplicate conflicts.
ProcessResources task = project.getTasks().withType(ProcessResources.class).getByName("processResources");
task.setDuplicatesStrategy(DuplicatesStrategy.EXCLUDE);
task.dependsOn(jarStagingTaskProvider);

ProcessResources process = project.getTasks().withType(ProcessResources.class).getByName("processResources");
process.setDuplicatesStrategy(DuplicatesStrategy.EXCLUDE);
process.dependsOn(jarStagingTaskProvider);

// Ensure the smithy files generated for the Jar are available for any Compile tasks so smithy-generated
// data can be picked up by annotation processors and compile tasks
for (String lang : SUPPORTED_LANGUAGES) {
Task compileTask = project.getTasks().findByName(sourceSet.getCompileTaskName(lang));
if (compileTask != null) {
compileTask.dependsOn(process);
}
}

// Update manifest with smithy build info and source tags
jarTask.doFirst("updateJarManifest",
Expand Down
Loading