This is an automated email from the ASF dual-hosted git repository.
mikexue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/eventmesh.git
The following commit(s) were added to refs/heads/master by this push:
new 0be4c7696 [ISSUE #1054] Build caching optimizations (#4689)
0be4c7696 is described below
commit 0be4c7696be2b0b63b7c5da145d15c79dd282d14
Author: Tomas Leriche <[email protected]>
AuthorDate: Tue Jan 2 19:28:48 2024 -0800
[ISSUE #1054] Build caching optimizations (#4689)
* remove checkstyleMain dependency on spotlessApply
spotlessApply was reformatting files on every build causing cache misses.
* limit the target of spotlessJava to just src java files
* use a TempDir for testing the onChange method, changing file in place
caused cache miss
* enable gradle build cache
---
build.gradle | 3 +--
.../eventmesh/common/file/WatchFileManagerTest.java | 20 ++++++++++++++------
gradle.properties | 1 +
3 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/build.gradle b/build.gradle
index 6f56a7291..c8b371cf9 100644
--- a/build.gradle
+++ b/build.gradle
@@ -93,7 +93,6 @@ allprojects {
.exclude('**/org/apache/eventmesh/connector/openfunction/client/EventMeshGrpcService**')
.exclude('**/org/apache/eventmesh/connector/openfunction/client/CallbackServiceGrpc**')
.exclude('**/org/apache/eventmesh/connector/jdbc/antlr**')
- .dependsOn(spotlessApply)
dependencies {
repositories {
@@ -110,7 +109,7 @@ allprojects {
enforceCheck false
java {
target project.fileTree(project.projectDir) {
- include '**/*.java'
+ include 'src/*/java/**/*.java'
exclude '**/org/apache/eventmesh/**/protos**'
exclude
'**/org/apache/eventmesh/connector/openfunction/client/EventMeshGrpcService**'
exclude
'**/org/apache/eventmesh/connector/openfunction/client/CallbackServiceGrpc**'
diff --git
a/eventmesh-common/src/test/java/org/apache/eventmesh/common/file/WatchFileManagerTest.java
b/eventmesh-common/src/test/java/org/apache/eventmesh/common/file/WatchFileManagerTest.java
index 77f8baba6..8a3c024ab 100644
---
a/eventmesh-common/src/test/java/org/apache/eventmesh/common/file/WatchFileManagerTest.java
+++
b/eventmesh-common/src/test/java/org/apache/eventmesh/common/file/WatchFileManagerTest.java
@@ -24,37 +24,45 @@ import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
+import java.nio.file.Files;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
public class WatchFileManagerTest {
+ @TempDir
+ File tempConfigDir;
+
@Test
public void testWatchFile() throws IOException, InterruptedException {
String file =
WatchFileManagerTest.class.getResource("/configuration.properties").getFile();
File f = new File(file);
+ File tempConfigFile = new File(tempConfigDir,
"configuration.properties");
+ Files.copy(f.toPath(), tempConfigFile.toPath());
+
final FileChangeListener fileChangeListener = new FileChangeListener()
{
@Override
public void onChanged(FileChangeContext changeContext) {
- Assertions.assertEquals(f.getName(),
changeContext.getFileName());
- Assertions.assertEquals(f.getParent(),
changeContext.getDirectoryPath());
+ Assertions.assertEquals(tempConfigFile.getName(),
changeContext.getFileName());
+ Assertions.assertEquals(tempConfigFile.getParent(),
changeContext.getDirectoryPath());
}
@Override
public boolean support(FileChangeContext changeContext) {
- return
changeContext.getWatchEvent().context().toString().contains(f.getName());
+ return
changeContext.getWatchEvent().context().toString().contains(tempConfigFile.getName());
}
};
- WatchFileManager.registerFileChangeListener(f.getParent(),
fileChangeListener);
+
WatchFileManager.registerFileChangeListener(tempConfigFile.getParent(),
fileChangeListener);
Properties properties = new Properties();
- properties.load(new BufferedReader(new FileReader(file)));
+ properties.load(new BufferedReader(new FileReader(tempConfigFile)));
properties.setProperty("eventMesh.server.newAdd", "newAdd");
- FileWriter fw = new FileWriter(file);
+ FileWriter fw = new FileWriter(tempConfigFile);
properties.store(fw, "newAdd");
ThreadUtils.sleep(500, TimeUnit.MILLISECONDS);
diff --git a/gradle.properties b/gradle.properties
index 2298245ec..64cfbe2fa 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -33,3 +33,4 @@ signEnabled=false
org.gradle.warning.mode=none
org.gradle.jvmargs=-Xmx4096m -XX:MaxMetaspaceSize=512m
-XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
+org.gradle.caching=true
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]