Skip to content

Commit

Permalink
Import test apps on worker threads
Browse files Browse the repository at this point in the history
Signed-off-by: Scott Kurz <[email protected]>
  • Loading branch information
scottkurz committed Sep 14, 2023
1 parent fe956b1 commit 357f7dd
Showing 1 changed file with 23 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,29 +122,18 @@ protected static void cleanupProject(String projectPathStr) {
* @throws InterruptedException
* @throws CoreException
*/
public static void importMavenProjects(File workspaceRoot, List<String> folders) {

Display.getDefault().syncExec(new Runnable() {

@Override
public void run() {
try {
// Get the list of projects to install.
MavenModelManager modelManager = MavenPlugin.getMavenModelManager();
LocalProjectScanner lps = new LocalProjectScanner(folders, false, modelManager);
lps.run(new NullProgressMonitor());
List<MavenProjectInfo> projects = lps.getProjects();

// Import the projects.
ProjectImportConfiguration projectImportConfig = new ProjectImportConfiguration();
IProjectConfigurationManager projectConfigurationManager = MavenPlugin.getProjectConfigurationManager();
projectConfigurationManager.importProjects(projects, projectImportConfig, new NullProgressMonitor());
} catch (Exception e) {
e.printStackTrace();
}
}

});
public static void importMavenProjects(File workspaceRoot, List<String> folders) throws Exception {

// Get the list of projects to install.
MavenModelManager modelManager = MavenPlugin.getMavenModelManager();
LocalProjectScanner lps = new LocalProjectScanner(folders, false, modelManager);
lps.run(new NullProgressMonitor());
List<MavenProjectInfo> projects = lps.getProjects();

// Import the projects.
ProjectImportConfiguration projectImportConfig = new ProjectImportConfiguration();
IProjectConfigurationManager projectConfigurationManager = MavenPlugin.getProjectConfigurationManager();
projectConfigurationManager.importProjects(projects, projectImportConfig, new NullProgressMonitor());
}

/**
Expand All @@ -155,26 +144,16 @@ public void run() {
* @throws InterruptedException
* @throws CoreException
*/
public static void importGradleApplications(ArrayList<File> projectsToInstall) {
Display.getDefault().syncExec(new Runnable() {

@Override
public void run() {
try {
for (File projectFile : projectsToInstall) {
IPath projectLocation = org.eclipse.core.runtime.Path
.fromOSString(Paths.get(projectFile.getPath()).toAbsolutePath().toString());
BuildConfiguration configuration = BuildConfiguration.forRootProjectDirectory(projectLocation.toFile()).build();
GradleWorkspace workspace = GradleCore.getWorkspace();
GradleBuild newBuild = workspace.createBuild(configuration);
newBuild.synchronize(new NullProgressMonitor());
}
} catch (Exception e) {
e.printStackTrace();
}
}

});
public static void importGradleApplications(ArrayList<File> projectsToInstall) throws Exception {

for (File projectFile : projectsToInstall) {
IPath projectLocation = org.eclipse.core.runtime.Path
.fromOSString(Paths.get(projectFile.getPath()).toAbsolutePath().toString());
BuildConfiguration configuration = BuildConfiguration.forRootProjectDirectory(projectLocation.toFile()).build();
GradleWorkspace workspace = GradleCore.getWorkspace();
GradleBuild newBuild = workspace.createBuild(configuration);
newBuild.synchronize(new NullProgressMonitor());
}
}

/**
Expand All @@ -199,4 +178,4 @@ public void validateRemoteJavaAppCreation(String projectName) {

Assertions.fail("The remote java application configuration did not contain project name " + projectName);
}
}
}

0 comments on commit 357f7dd

Please sign in to comment.