Skip to content

Commit

Permalink
Update M2E to 2.0.0 (Vulnerability in Apache Lucene 8.9)
Browse files Browse the repository at this point in the history
Signed-off-by: Snjezana Peco <snjezana.peco@redhat.com>
  • Loading branch information
snjeza committed May 31, 2022
1 parent c7b80fc commit 269e58f
Show file tree
Hide file tree
Showing 25 changed files with 677 additions and 50 deletions.
2 changes: 1 addition & 1 deletion launch/jdt.ls.remote.server.launch
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
<setEntry value="org.eclipse.xtext.xbase.lib@default:default"/>
<setEntry value="org.gradle.toolingapi@default:default"/>
<setEntry value="org.hamcrest.core@default:default"/>
<setEntry value="org.jboss.tools.maven.apt.core@default:default"/>
<setEntry value="org.eclipse.m2e.apt.core@default:default"/>
<setEntry value="org.junit@default:default"/>
<setEntry value="org.slf4j.api@default:default"/>
</setAttribute>
Expand Down
2 changes: 1 addition & 1 deletion launch/jdt.ls.socket-stream.launch
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
<setEntry value="org.eclipse.xtext.xbase.lib@default:default"/>
<setEntry value="org.gradle.toolingapi@default:default"/>
<setEntry value="org.hamcrest.core@default:default"/>
<setEntry value="org.jboss.tools.maven.apt.core@default:default"/>
<setEntry value="org.eclipse.m2e.apt.core@default:default"/>
<setEntry value="org.junit@default:default"/>
<setEntry value="org.slf4j.api@default:default"/>
</setAttribute>
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.jdt.ls.core/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="3.12.0",
org.eclipse.xtext.xbase.lib,
org.eclipse.core.filesystem;bundle-version="1.7.0",
org.eclipse.jdt.apt.pluggable.core;bundle-version="1.2.0";resolution:=optional,
org.jboss.tools.maven.apt.core;bundle-version="1.3.0";resolution:=optional
org.eclipse.m2e.apt.core;bundle-version="1.3.0";resolution:=optional
Export-Package: org.eclipse.jdt.ls.core.internal;x-friends:="org.eclipse.jdt.ls.tests,org.eclipse.jdt.ls.tests.syntaxserver",
org.eclipse.jdt.ls.core.internal.codemanipulation;x-friends:="org.eclipse.jdt.ls.tests",
org.eclipse.jdt.ls.core.internal.commands;x-friends:="org.eclipse.jdt.ls.tests",
Expand Down
1 change: 0 additions & 1 deletion org.eclipse.jdt.ls.core/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ bin.includes = META-INF/,\
lib/jsoup-1.14.2.jar,\
lib/remark-1.2.0.jar,\
lifecycle-mapping-metadata.xml,\
logback.xml,\
plugin.properties,\
gradle/checksums/checksums.json,\
gradle/checksums/versions.json
Expand Down
10 changes: 0 additions & 10 deletions org.eclipse.jdt.ls.core/logback.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,6 @@ public class JavaLanguageServerPlugin extends Plugin {
public static final String HTTPS_PROXY_USER = "https.proxyUser";
public static final String HTTP_PROXY_USER = "http.proxyUser";

private static final String LOGBACK_CONFIG_FILE_PROPERTY = "logback.configurationFile";
private static final String LOGBACK_DEFAULT_FILENAME = "logback.xml";

/**
* Source string send to clients for messages such as diagnostics.
**/
Expand Down Expand Up @@ -176,25 +173,6 @@ public void start(BundleContext bundleContext) throws Exception {
JavaLanguageServerPlugin.pluginInstance = this;
setPreferenceNodeId();

// Override logback preferences *before* M2E plugin is activated below
if (isDebug && System.getProperty(LOGBACK_CONFIG_FILE_PROPERTY) == null) {
File stateDir = getStateLocation().toFile();
File configFile = new File(stateDir, LOGBACK_DEFAULT_FILENAME);
if (!configFile.isFile()) {
try (InputStream is = bundleContext.getBundle().getEntry(LOGBACK_DEFAULT_FILENAME).openStream(); FileOutputStream fos = new FileOutputStream(configFile)) {
for (byte[] buffer = new byte[1024 * 4];;) {
int n = is.read(buffer);
if (n < 0) {
break;
}
fos.write(buffer, 0, n);
}
}
}
// ContextInitializer.CONFIG_FILE_PROPERTY
System.setProperty(LOGBACK_CONFIG_FILE_PROPERTY, configFile.getAbsolutePath());
}

if (JDTEnvironmentUtils.isSyntaxServer()) {
disableServices();
preferenceManager = new PreferenceManager();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@
import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.embedder.MavenModelManager;
import org.eclipse.m2e.core.internal.IMavenConstants;
import org.eclipse.m2e.core.internal.MavenPluginActivator;
import org.eclipse.m2e.core.internal.preferences.MavenConfigurationImpl;
import org.eclipse.m2e.core.project.IMavenProjectImportResult;
import org.eclipse.m2e.core.project.IProjectConfigurationManager;
import org.eclipse.m2e.core.project.LocalProjectScanner;
import org.eclipse.m2e.core.project.MavenProjectInfo;
import org.eclipse.m2e.core.project.ProjectImportConfiguration;
import org.osgi.framework.Bundle;

@SuppressWarnings("restriction")
public class MavenProjectImporter extends AbstractProjectImporter {
Expand All @@ -68,6 +68,8 @@ public class MavenProjectImporter extends AbstractProjectImporter {

public static final String POM_FILE = "pom.xml";

private static final String STATE_FILENAME = "workspaceState.ser";

private Set<MavenProjectInfo> projectInfos = null;

private IProjectConfigurationManager configurationManager;
Expand Down Expand Up @@ -232,8 +234,14 @@ public void importToWorkspace(IProgressMonitor monitor) throws CoreException, Op
}

private long getLastWorkspaceStateModified() {
File workspaceStateFile = MavenPluginActivator.getDefault().getMavenProjectManager().getWorkspaceStateFile();
return workspaceStateFile.lastModified();
Bundle bundle = Platform.getBundle(IMavenConstants.PLUGIN_ID);
if (bundle != null) {
IPath result = Platform.getStateLocation(bundle);
File bundleStateLocation = result.toFile();
File workspaceStateFile = new File(bundleStateLocation, STATE_FILENAME);
return workspaceStateFile.lastModified();
}
return 0l;
}

private File getProjectDirectory() {
Expand Down Expand Up @@ -288,7 +296,7 @@ private Set<MavenProjectInfo> getMavenProjects(File directory, MavenModelManager
}
try {
List<String> folders = directories.stream().map(java.nio.file.Path::toAbsolutePath).map(Object::toString).collect(Collectors.toList());
LocalProjectScanner scanner = new LocalProjectScanner(directory.getParentFile(), folders, false, modelManager);
LocalProjectScanner scanner = new LocalProjectScanner(folders, false, modelManager);
scanner.run(monitor);
return collectProjects(scanner.getProjects());
} catch (InterruptedException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.ls.core.internal.JavaLanguageServerPlugin;
import org.eclipse.m2e.apt.MavenJdtAptPlugin;
import org.eclipse.m2e.apt.preferences.PreferencesConstants;
import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.embedder.IMavenConfiguration;
import org.eclipse.m2e.core.internal.IMavenConstants;
Expand All @@ -38,7 +40,7 @@
*
*/
public class StandardPreferenceManager extends PreferenceManager {
private static final String M2E_APT_ID = "org.jboss.tools.maven.apt";
private static final String M2E_APT_ID = MavenJdtAptPlugin.PLUGIN_ID;
private IMavenConfiguration mavenConfig;

public StandardPreferenceManager() {
Expand All @@ -55,7 +57,7 @@ public static void initializeMavenPreferences() {

IEclipsePreferences m2eAptPrefs = DefaultScope.INSTANCE.getNode(M2E_APT_ID);
if (m2eAptPrefs != null) {
m2eAptPrefs.put(M2E_APT_ID + ".mode", "jdt_apt");
m2eAptPrefs.put(PreferencesConstants.MODE, "jdt_apt");
}

IEclipsePreferences store = InstanceScope.INSTANCE.getNode(IMavenConstants.PLUGIN_ID);
Expand Down
5 changes: 3 additions & 2 deletions org.eclipse.jdt.ls.product/languageServer.product
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
<plugin id="org.eclipse.jdt.launching"/>
<plugin id="org.eclipse.jdt.launching.macosx"/>
<plugin id="org.eclipse.jdt.ls.core"/>
<plugin id="org.eclipse.jdt.ls.start"/>
<plugin id="org.eclipse.m2e.apt.core"/>
<plugin id="org.eclipse.m2e.core"/>
<plugin id="org.eclipse.m2e.jdt"/>
<plugin id="org.eclipse.m2e.lifecyclemapping.defaults"/>
Expand All @@ -63,7 +65,6 @@
<plugin id="org.eclipse.osgi.services"/>
<plugin id="org.eclipse.text"/>
<plugin id="org.eclipse.xtext.xbase.lib"/>
<plugin id="org.jboss.tools.maven.apt.core"/>
</plugins>

<configurations>
Expand All @@ -72,7 +73,7 @@
<plugin id="org.eclipse.equinox.common" autoStart="true" startLevel="2" />
<plugin id="org.eclipse.jdt.core" autoStart="false" startLevel="0" />
<plugin id="org.eclipse.jdt.launching" autoStart="false" startLevel="0" />
<plugin id="org.eclipse.jdt.ls.core" autoStart="true" startLevel="0" />
<plugin id="org.eclipse.jdt.ls.start" autoStart="true" startLevel="0" />
</configurations>

<preferencesInfo>
Expand Down
21 changes: 21 additions & 0 deletions org.eclipse.jdt.ls.start/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" output="target/classes" path="src">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
34 changes: 34 additions & 0 deletions org.eclipse.jdt.ls.start/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.jdt.ls.start</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8
Loading

0 comments on commit 269e58f

Please sign in to comment.