use of org.eclipse.che.plugin.maven.server.core.classpath.ClasspathHelper in project che by eclipse.
the class MavenWorkspace method addSourcesFromBuildHelperPlugin.
private void addSourcesFromBuildHelperPlugin(MavenProject project) {
IJavaProject javaProject = JavaCore.create(project.getProject());
try {
ClasspathHelper helper = new ClasspathHelper(javaProject);
Element pluginConfigurationSource = project.getPluginConfiguration("org.codehaus.mojo", "build-helper-maven-plugin", "add-source");
Element pluginConfigurationTestSource = project.getPluginConfiguration("org.codehaus.mojo", "build-helper-maven-plugin", "add-test-source");
IPath projectPath = project.getProject().getFullPath();
RegisteredProject registeredProject = projectRegistryProvider.get().getProject(projectPath.toOSString());
if (registeredProject == null) {
throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.CORE_EXCEPTION, "Project " + projectPath.toOSString() + " doesn't exist"));
}
List<String> sourceFolders = registeredProject.getAttributes().get(Constants.SOURCE_FOLDER);
List<String> testSourceFolders = registeredProject.getAttributes().get(MavenAttributes.TEST_SOURCE_FOLDER);
addSourcePathFromConfiguration(helper, project, pluginConfigurationSource, sourceFolders);
addSourcePathFromConfiguration(helper, project, pluginConfigurationTestSource, testSourceFolders);
javaProject.setRawClasspath(helper.getEntries(), null);
} catch (JavaModelException e) {
LOG.error("Can't update Java project classpath with Maven build helper plugin configuration", e);
}
}
use of org.eclipse.che.plugin.maven.server.core.classpath.ClasspathHelper in project che by eclipse.
the class MavenWorkspace method updateJavaProject.
private void updateJavaProject(MavenProject project) {
IJavaProject javaProject = JavaCore.create(project.getProject());
try {
ClasspathHelper helper = new ClasspathHelper(javaProject);
project.getSources().stream().map(s -> project.getProject().getFullPath().append(s)).forEach(helper::addSourceEntry);
project.getTestSources().stream().map(s -> project.getProject().getFullPath().append(s)).forEach(helper::addSourceEntry);
//add maven classpath container
helper.addContainerEntry(new Path(MavenClasspathContainer.CONTAINER_ID));
//add JRE classpath container
helper.addContainerEntry(new Path(JREContainerInitializer.JRE_CONTAINER));
javaProject.setRawClasspath(helper.getEntries(), null);
} catch (JavaModelException e) {
LOG.error("Can't update Java project classpath", e);
}
}
Aggregations