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

[7.x] Fix incremental build support copying REST api and tests #52896

Merged
merged 1 commit into from
Feb 27, 2020
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 @@ -84,16 +84,25 @@ public ListProperty<String> getIncludeXpack() {
@SkipWhenEmpty
@InputFiles
public FileTree getInputDir() {
xpackPatternSet.setIncludes(includeXpack.get().stream().map(prefix -> prefix + "*/**").collect(Collectors.toList()));
ConfigurableFileCollection fileCollection = getProject().files(xpackConfig.getAsFileTree().matching(xpackPatternSet));
if (BuildParams.isInternal()) {
corePatternSet.setIncludes(includeCore.get().stream().map(prefix -> prefix + "*/**").collect(Collectors.toList()));
fileCollection.plus(coreConfig.getAsFileTree().matching(corePatternSet));
} else {
fileCollection.plus(coreConfig);
FileTree coreFileTree = null;
FileTree xpackFileTree = null;
if (includeXpack.get().isEmpty() == false) {
xpackPatternSet.setIncludes(includeXpack.get().stream().map(prefix -> prefix + "*/**").collect(Collectors.toList()));
xpackFileTree = xpackConfig.getAsFileTree().matching(xpackPatternSet);
}
boolean projectHasYamlRestTests = projectHasYamlRestTests();
if (includeCore.get().isEmpty() == false || projectHasYamlRestTests) {
if (BuildParams.isInternal()) {
corePatternSet.setIncludes(includeCore.get().stream().map(prefix -> prefix + "*/**").collect(Collectors.toList()));
coreFileTree = coreConfig.getAsFileTree().matching(corePatternSet); // directory on disk
} else {
coreFileTree = coreConfig.getAsFileTree(); // jar file
}
}
ConfigurableFileCollection fileCollection = getProject().files(coreFileTree, xpackFileTree);

// if project has rest tests or the includes are explicitly configured execute the task, else NO-SOURCE due to the null input
return projectHasYamlRestTests() || includeCore.get().isEmpty() == false || includeXpack.get().isEmpty() == false
return projectHasYamlRestTests || includeCore.get().isEmpty() == false || includeXpack.get().isEmpty() == false
? fileCollection.getAsFileTree()
: null;
}
Expand Down Expand Up @@ -148,15 +157,13 @@ private boolean projectHasYamlRestTests() {
return false;
}
try {
if (testSourceResourceDir != null) {
return new File(testSourceResourceDir, "rest-api-spec/test").exists() == false
|| Files.walk(testSourceResourceDir.toPath().resolve("rest-api-spec/test"))
.anyMatch(p -> p.getFileName().toString().endsWith("yml"));
if (testSourceResourceDir != null && new File(testSourceResourceDir, "rest-api-spec/test").exists()) {
return Files.walk(testSourceResourceDir.toPath().resolve("rest-api-spec/test"))
.anyMatch(p -> p.getFileName().toString().endsWith("yml"));
}
if (testOutputResourceDir != null) {
return new File(testOutputResourceDir, "rest-api-spec/test").exists() == false
|| Files.walk(testOutputResourceDir.toPath().resolve("rest-api-spec/test"))
.anyMatch(p -> p.getFileName().toString().endsWith("yml"));
if (testOutputResourceDir != null && new File(testOutputResourceDir, "rest-api-spec/test").exists()) {
return Files.walk(testOutputResourceDir.toPath().resolve("rest-api-spec/test"))
.anyMatch(p -> p.getFileName().toString().endsWith("yml"));
}
} catch (IOException e) {
throw new IllegalStateException(String.format("Error determining if this project [%s] has rest tests.", getProject()), e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,22 @@ public ListProperty<String> getIncludeXpack() {
@SkipWhenEmpty
@InputFiles
public FileTree getInputDir() {
xpackPatternSet.setIncludes(includeXpack.get().stream().map(prefix -> prefix + "*/**").collect(Collectors.toList()));
ConfigurableFileCollection fileCollection = getProject().files(xpackConfig.getAsFileTree().matching(xpackPatternSet));
if (BuildParams.isInternal()) {
corePatternSet.setIncludes(includeCore.get().stream().map(prefix -> prefix + "*/**").collect(Collectors.toList()));
fileCollection.plus(coreConfig.getAsFileTree().matching(corePatternSet));
} else {
fileCollection.plus(coreConfig);
FileTree coreFileTree = null;
FileTree xpackFileTree = null;
if (includeXpack.get().isEmpty() == false) {
xpackPatternSet.setIncludes(includeXpack.get().stream().map(prefix -> prefix + "*/**").collect(Collectors.toList()));
xpackFileTree = xpackConfig.getAsFileTree().matching(xpackPatternSet);
}
if (includeCore.get().isEmpty() == false) {
if (BuildParams.isInternal()) {
corePatternSet.setIncludes(includeCore.get().stream().map(prefix -> prefix + "*/**").collect(Collectors.toList()));
coreFileTree = coreConfig.getAsFileTree().matching(corePatternSet); // directory on disk
} else {
coreFileTree = coreConfig.getAsFileTree(); // jar file
}
}
ConfigurableFileCollection fileCollection = getProject().files(coreFileTree, xpackFileTree);

// copy tests only if explicitly requested
return includeCore.get().isEmpty() == false || includeXpack.get().isEmpty() == false ? fileCollection.getAsFileTree() : null;
}
Expand Down