wuchong commented on a change in pull request #12687:
URL: https://github.com/apache/flink/pull/12687#discussion_r441954996



##########
File path: 
flink-end-to-end-tests/flink-end-to-end-tests-common/src/main/java/org/apache/flink/tests/util/flink/LocalStandaloneFlinkResourceFactory.java
##########
@@ -80,6 +80,33 @@ public FlinkResource create(FlinkResourceSetup setup) {
                return new 
LocalStandaloneFlinkResource(distributionDirectory.get(), 
logBackupDirectory.orElse(null), setup);
        }
 
+       /**
+        * Utils to find the flink project root directory.
+        * @param currentDirectory
+        * @return The flink project root directory.
+        */
+       public static Path getProjectRootDirectory(Path currentDirectory) {

Review comment:
       We can use this method to replace the code block in 
`LocalStandaloneFlinkResourceFactory#create()`.

##########
File path: 
flink-end-to-end-tests/flink-end-to-end-tests-common/src/main/java/org/apache/flink/tests/util/flink/LocalStandaloneFlinkResourceFactory.java
##########
@@ -80,6 +80,33 @@ public FlinkResource create(FlinkResourceSetup setup) {
                return new 
LocalStandaloneFlinkResource(distributionDirectory.get(), 
logBackupDirectory.orElse(null), setup);
        }
 
+       /**
+        * Utils to find the flink project root directory.
+        * @param currentDirectory
+        * @return The flink project root directory.
+        */
+       public static Path getProjectRootDirectory(Path currentDirectory) {
+               Path projectRootPath;
+               Optional<Path> projectRoot = PROJECT_ROOT_DIRECTORY.get();
+               if (projectRoot.isPresent()) {
+                       // running with maven
+                       projectRootPath = projectRoot.get();
+               } else {
+                       // running in the IDE; working directory is test module
+                       Optional<Path> projectRootDirectory = 
findProjectRootDirectory(currentDirectory);
+                       // this distinction is required in case this class is 
used outside of Flink
+                       if (projectRootDirectory.isPresent()) {
+                               projectRootPath = projectRootDirectory.get();
+                       } else {
+                               throw new IllegalArgumentException(
+                                       "The 'rootDir' property was not set and 
the flink project root directory could not be found" +
+                                               " automatically. Please point 
the 'rootDir' property to the  flink project root directory;" +

Review comment:
       ```suggestion
                                                " automatically. Please point 
the 'rootDir' property to the flink project root directory;" +
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to