Skip to content
Open
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
2 changes: 1 addition & 1 deletion src/main/java/at/zierler/gradle/YamlValidatorTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private boolean isYamlFile(Path file) {

String fileName = fileNameAsPath.toString();

return fileName.endsWith(".yaml") || fileName.endsWith(".yml");
return !Files.isDirectory(file) && (fileName.endsWith(".yaml") || fileName.endsWith(".yml"));
}

private void validateYamlFile(Path file) {
Expand Down
23 changes: 23 additions & 0 deletions src/test/java/at/zierler/gradle/YamlValidatorPluginIntTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,24 @@ public void shouldNotValidateFileWithNonYamlEnding() throws IOException {

expectBuildSuccessAndNoStartingMessageForNonYamlFile(nonYamlFile);
}

@Test
public void shouldNotValidateFolderWithYamlEnding() throws IOException {

File yamlFolder = createAndGetYamlFolderInDefaultYamlDirectory("org.yaml");
writeBuildFileWithNonYamlFileAsSearchPath(new File(DEFAULT_YAML_DIRECTORY_RELATIVE_PATH));

expectBuildSuccessAndNoStartingMessageForNonYamlFile(yamlFolder);
}

@Test
public void shouldNotValidateFolderWithYmlEnding() throws IOException {

File yamlFolder = createAndGetYamlFolderInDefaultYamlDirectory("org.yml");
writeBuildFileWithNonYamlFileAsSearchPath(new File(DEFAULT_YAML_DIRECTORY_RELATIVE_PATH));

expectBuildSuccessAndNoStartingMessageForNonYamlFile(yamlFolder);
}

@Test
public void shouldNotValidateFileWithNonYamlEndingButValidateYamlFileInSameDirectory() throws IOException {
Expand Down Expand Up @@ -423,6 +441,11 @@ private File createAndGetYamlFileInSubdirectoryOfDefaultYamlDirectory() throws I
testProjectDir.newFolder(subdirectoryInDefaultYamlDirectoryRelativePath.split("/"));
return testProjectDir.newFile(subdirectoryInDefaultYamlDirectoryRelativePath + "file.yaml");
}

private File createAndGetYamlFolderInDefaultYamlDirectory(String folderName) throws IOException {
String subdirectoryInDefaultYamlDirectoryRelativePath = DEFAULT_YAML_DIRECTORY_RELATIVE_PATH + folderName + "/";
return testProjectDir.newFolder(subdirectoryInDefaultYamlDirectoryRelativePath.split("/"));
}

private File createAndGetNonYamlFileInDefaultYamlDirectory() throws IOException {

Expand Down