Skip to content

Commit

Permalink
Merge pull request #409 from scottkurz/fine-tune-exploded-loose-app-u…
Browse files Browse the repository at this point in the history
…pdate

Avoid unnecessary war:exploded calls for mere recompilation of Java c…
  • Loading branch information
scottkurz committed Aug 18, 2023
2 parents 09c8274 + 1a4e80c commit b08c49b
Showing 1 changed file with 9 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,9 @@ private enum FileTrackMode {
private File configDirectory;
private File projectDirectory;
private File multiModuleProjectDirectory;
private List<File> resourceDirs;
private List<Path> webResourceDirs;
protected List<File> resourceDirs;
// Not all webResource dirs need to be monitored, but those for which a Maven filtering will be applied do, since they can't be added to the loose app as source
protected List<Path> monitoredWebResourceDirs;
private boolean hotTests;
private Path tempConfigPath;
private boolean skipTests;
Expand Down Expand Up @@ -443,7 +444,7 @@ public DevUtil(File buildDirectory, File serverDirectory, File sourceDirectory,
boolean skipDefaultPorts, JavaCompilerOptions compilerOptions, boolean keepTempDockerfile,
String mavenCacheLocation, List<ProjectModule> upstreamProjects, boolean recompileDependencies,
String packagingType, File buildFile, Map<String, List<String>> parentBuildFiles, boolean generateFeatures,
Set<String> compileArtifactPaths, Set<String> testArtifactPaths, List<Path> webResourceDirs) {
Set<String> compileArtifactPaths, Set<String> testArtifactPaths, List<Path> monitoredWebResourceDirs) {
this.buildDirectory = buildDirectory;
this.serverDirectory = serverDirectory;
this.sourceDirectory = sourceDirectory;
Expand Down Expand Up @@ -509,7 +510,7 @@ public DevUtil(File buildDirectory, File serverDirectory, File sourceDirectory,
this.generateFeatures = generateFeatures;
this.compileArtifactPaths = compileArtifactPaths;
this.testArtifactPaths = testArtifactPaths;
this.webResourceDirs = webResourceDirs;
this.monitoredWebResourceDirs = monitoredWebResourceDirs;
this.generatedFeaturesFile = new File(configDirectory, BinaryScannerUtil.GENERATED_FEATURES_FILE_PATH);
this.generatedFeaturesModified = false;
if (this.generateFeatures) {
Expand Down Expand Up @@ -2835,7 +2836,7 @@ public void watchFiles(File outputDirectory, File testOutputDirectory, final Thr
}

HashMap<Path, Boolean> webResourceMap = new HashMap<Path, Boolean>();
for (Path webResourceDir : webResourceDirs) {
for (Path webResourceDir : monitoredWebResourceDirs) {
webResourceMap.put(webResourceDir, false);
if (Files.exists(webResourceDir)) {
registerAll(webResourceDir, executor);
Expand Down Expand Up @@ -3033,7 +3034,7 @@ public void watchFiles(File outputDirectory, File testOutputDirectory, final Thr
}

// Check if webResourceDirectory has been added or deleted
for (Path webResourceDir : webResourceDirs) {
for (Path webResourceDir : monitoredWebResourceDirs) {
if (!webResourceMap.get(webResourceDir) && Files.exists(webResourceDir)) {
updateLooseApp();
registerAll(webResourceDir, executor);
Expand Down Expand Up @@ -3893,7 +3894,7 @@ private void processFileChanges(
Path configPath = this.configDirectory.getCanonicalFile().toPath();
Path outputPath = this.outputDirectory.getCanonicalFile().toPath();

Path directory = fileChanged.getParentFile().toPath();
Path directory = fileChanged.getParentFile().getCanonicalFile().toPath();

// resource file check
File resourceParent = null;
Expand All @@ -3906,7 +3907,7 @@ private void processFileChanges(

// webResource file check
Path webResourceParent = null;
for (Path webResourceDir : webResourceDirs) {
for (Path webResourceDir : monitoredWebResourceDirs) {
if (directory.startsWith(webResourceDir)) {
webResourceParent = webResourceDir;
break;
Expand Down Expand Up @@ -4082,9 +4083,6 @@ private void processFileChanges(
}
}
}
// Update the loose app in case something changed
updateLooseApp();

} else if (upstreamResourceParent != null
&& directory.startsWith(upstreamResourceParent.getCanonicalFile().toPath())) { // resources
debug("Resource dir: " + upstreamResourceParent.toString());
Expand Down Expand Up @@ -4233,8 +4231,6 @@ private void processFileChanges(
triggerJavaTestRecompile = true;
}
}
// Update the loose app in case something changed
updateLooseApp();
runTestThread(true, executor, numApplicationUpdatedMessages, skipUTs, false, buildFile);
}
} else if (fileChanged.equals(dockerfileUsed)
Expand Down Expand Up @@ -4998,8 +4994,6 @@ protected boolean recompileJava(Collection<File> javaFilesChanged, Set<String> a
// redeploy app after compilation if not loose application
if (!isLooseApplication()) {
redeployApp();
} else {
updateLooseApp();
}
if (projectName != null) {
info(projectName + " source compilation was successful.");
Expand Down

0 comments on commit b08c49b

Please sign in to comment.