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

Fix building models in subdirs #1860

Merged
merged 1 commit into from
Jul 18, 2023
Merged
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 @@ -15,8 +15,6 @@

package software.amazon.smithy.build;

import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
Expand Down Expand Up @@ -199,23 +197,10 @@ public SmithyBuild config(SmithyBuildConfig config) {
//
// Ignores and logs when an unsupported model file is encountered.
private void addSource(Path path) {
try {
if (Files.isDirectory(path)) {
// Pre-emptively crawl the given models to filter them up front into a flat, file-only, list.
Files.list(path).filter(Files::isRegularFile).forEach(this::addSourceFile);
} else {
addSourceFile(path);
}
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}

private void addSourceFile(Path file) {
if (!VALID_MODELS.matches(file.getFileName())) {
LOGGER.warning("Omitting unsupported Smithy model file from model sources: " + file);
if (Files.isRegularFile(path) && !VALID_MODELS.matches(path.getFileName())) {
LOGGER.warning("Omitting unsupported Smithy model file from model sources: " + path);
} else {
sources.add(file.toAbsolutePath());
sources.add(path.toAbsolutePath());
}
}

Expand Down