pabloem commented on a change in pull request #15803:
URL: https://github.com/apache/beam/pull/15803#discussion_r737769010



##########
File path: playground/backend/internal/fs_tool/java_fs.go
##########
@@ -45,6 +48,21 @@ func newJavaLifeCycle(pipelineId uuid.UUID, workingDir 
string) *LifeCycle {
                        ExecutableExtension: javaExecutableFileExtension,
                        CompiledExtension:   javaCompiledFileExtension,
                },
-               pipelineId: pipelineId,
+               ExecutableName: executableName,
+               pipelineId:     pipelineId,
        }
 }
+
+// executableName returns name that should be executed (HelloWorld for 
HelloWorld.class for java SDK)
+func executableName(pipelineId uuid.UUID, workingDir string) (string, error) {
+       baseFileFolder := filepath.Join(workingDir, javaBaseFileFolder, 
pipelineId.String())
+       binFileFolder := filepath.Join(baseFileFolder, javaCompiledFolderName)
+       dirEntries, err := os.ReadDir(binFileFolder)
+       if err != nil {
+               return "", err
+       }
+       if len(dirEntries) < 1 {
+               return "", errors.New("number of executable files should be 
more than one")
+       }
+       return strings.Split(dirEntries[len(dirEntries)-1].Name(), ".")[0], nil

Review comment:
       we need to find the class with `main` method, right? How do we do that? 
Will it always be the last one?

##########
File path: playground/backend/internal/fs_tool/java_fs.go
##########
@@ -45,6 +48,21 @@ func newJavaLifeCycle(pipelineId uuid.UUID, workingDir 
string) *LifeCycle {
                        ExecutableExtension: javaExecutableFileExtension,
                        CompiledExtension:   javaCompiledFileExtension,
                },
-               pipelineId: pipelineId,
+               ExecutableName: executableName,
+               pipelineId:     pipelineId,
        }
 }
+
+// executableName returns name that should be executed (HelloWorld for 
HelloWorld.class for java SDK)
+func executableName(pipelineId uuid.UUID, workingDir string) (string, error) {
+       baseFileFolder := filepath.Join(workingDir, javaBaseFileFolder, 
pipelineId.String())
+       binFileFolder := filepath.Join(baseFileFolder, javaCompiledFolderName)
+       dirEntries, err := os.ReadDir(binFileFolder)
+       if err != nil {
+               return "", err
+       }
+       if len(dirEntries) < 1 {
+               return "", errors.New("number of executable files should be 
more than one")

Review comment:
       ```suggestion
                return "", errors.New("number of executable files should be at 
least one")
   ```




-- 
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.

To unsubscribe, e-mail: [email protected]

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


Reply via email to