Update boot version validation

This commit is contained in:
Nieraj Singh
2022-11-07 07:43:32 -08:00
33 changed files with 255 additions and 421 deletions

View File

@@ -138,7 +138,6 @@
<bundle id="javax.xml.stream"/>
<bundle id="org.aopalliance"/>
<bundle id="org.apache.log4j"/>
<bundle id="org.dadacoalition.yedit"/>
<bundle id="org.yaml.snakeyaml"/>
<bundle id="org.eclipse.lsp4e"/>
<bundle id="org.eclipse.lsp4e.jdt"/>

View File

@@ -138,7 +138,6 @@
<bundle id="javax.xml.stream"/>
<bundle id="org.aopalliance"/>
<bundle id="org.apache.log4j"/>
<bundle id="org.dadacoalition.yedit"/>
<bundle id="org.yaml.snakeyaml"/>
<bundle id="org.eclipse.lsp4e"/>
<bundle id="org.eclipse.lsp4e.jdt"/>

View File

@@ -138,7 +138,6 @@
<bundle id="javax.xml.stream"/>
<bundle id="org.aopalliance"/>
<bundle id="org.apache.log4j"/>
<bundle id="org.dadacoalition.yedit"/>
<bundle id="org.yaml.snakeyaml"/>
<bundle id="org.eclipse.lsp4e"/>
<bundle id="org.eclipse.lsp4e.jdt"/>

View File

@@ -138,7 +138,6 @@
<bundle id="javax.xml.stream"/>
<bundle id="org.aopalliance"/>
<bundle id="org.apache.log4j"/>
<bundle id="org.dadacoalition.yedit"/>
<bundle id="org.yaml.snakeyaml"/>
<bundle id="org.eclipse.lsp4e"/>
<bundle id="org.eclipse.lsp4e.jdt"/>

View File

@@ -101,7 +101,7 @@
<tycho-version>2.7.5</tycho-version>
<encoding>UTF-8</encoding>
<misc.p2.repo.version>3.9.4.202003091750</misc.p2.repo.version>
<misc.p2.repo.version>3.9.4.202211021051</misc.p2.repo.version>
</properties>
<profiles>
@@ -767,11 +767,6 @@
<layout>p2</layout>
<url>${sts4-language-servers-p2-repo}</url>
</repository>
<repository>
<id>yedit</id>
<layout>p2</layout>
<url>https://dist.springsource.com/release/TOOLS/third-party/yedit</url>
</repository>
<repository>
<id>p2-thirdparty-bundles</id>
<layout>p2</layout>

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018,2020 Pivotal, Inc.
* Copyright (c) 2018, 2022 Pivotal, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,15 +10,11 @@
*******************************************************************************/
package org.springframework.ide.eclipse.boot.dash.docker.jmx;
import java.util.EnumSet;
import java.util.Map;
import org.springframework.ide.eclipse.boot.launch.livebean.JmxBeanSupport;
import org.springframework.ide.eclipse.boot.launch.util.PortFinder;
import org.springsource.ide.eclipse.commons.livexp.util.Log;
import static org.springframework.ide.eclipse.boot.launch.livebean.JmxBeanSupport.Feature.*;
/**
* Helper class providing functionality to connect to JMX on a remote spring boot app
* running on CF, using ssh tunneling.
@@ -45,7 +41,8 @@ public class JmxSupport {
"-Djava.rmi.server.hostname=localhost " +
"-Dcom.sun.management.jmxremote.local.only=false "+
"-Dspring.jmx.enabled=true " +
"-Dspring.application.admin.enabled=true";
"-Dspring.application.admin.enabled=true " +
"-Dmanagement.endpoints.jmx.exposure.include=*";
}
int port;

View File

@@ -50,7 +50,8 @@ public class JmxSupportTest {
+ "-Dcom.sun.management.jmxremote.rmi.port=1234 "
+ "-Djava.rmi.server.hostname=localhost "
+ "-Dcom.sun.management.jmxremote.local.only=false "
+ "-Dspring.jmx.enabled=true",
+ "-Dspring.jmx.enabled=true"
+ "-Dmanagement.endpoints.jmx.exposure.include=*",
env.get("JAVA_OPTS"));
jmx.setupEnvVars(env); // should erase old and recreate
@@ -61,7 +62,8 @@ public class JmxSupportTest {
+ "-Dcom.sun.management.jmxremote.rmi.port=1234 "
+ "-Djava.rmi.server.hostname=localhost "
+ "-Dcom.sun.management.jmxremote.local.only=false "
+ "-Dspring.jmx.enabled=true",
+ "-Dspring.jmx.enabled=true"
+ "-Dmanagement.endpoints.jmx.exposure.include=*",
env.get("JAVA_OPTS"));
}
@@ -84,7 +86,8 @@ public class JmxSupportTest {
+ "-Dcom.sun.management.jmxremote.rmi.port=1234 "
+ "-Djava.rmi.server.hostname=localhost "
+ "-Dcom.sun.management.jmxremote.local.only=false "
+ "-Dspring.jmx.enabled=true",
+ "-Dspring.jmx.enabled=true"
+ "-Dmanagement.endpoints.jmx.exposure.include=*",
env.get("JAVA_OPTS"));
jmx.setupEnvVars(env); // should erase old and recreate
@@ -95,7 +98,8 @@ public class JmxSupportTest {
+ "-Dcom.sun.management.jmxremote.rmi.port=1234 "
+ "-Djava.rmi.server.hostname=localhost "
+ "-Dcom.sun.management.jmxremote.local.only=false "
+ "-Dspring.jmx.enabled=true",
+ "-Dspring.jmx.enabled=true"
+ "-Dmanagement.endpoints.jmx.exposure.include=*",
env.get("JAVA_OPTS"));
}

View File

@@ -28,7 +28,6 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.ui.views.properties.tabbed,
org.eclipse.ui.editors,
org.eclipse.jface.text,
org.dadacoalition.yedit,
org.eclipse.ui.workbench,
org.yaml.snakeyaml,
org.eclipse.compare,

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2014, 2019 Pivotal Software, Inc.
* Copyright (c) 2014, 2022 Pivotal Software, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -66,10 +66,17 @@ public class JmxBeanSupport {
"-Dcom.sun.management.jmxremote.authenticate=false",
"-Dcom.sun.management.jmxremote.ssl=false",
"-Djava.rmi.server.hostname=localhost",
//
// PT 164402781 - For Boot 2.2 and above, jmx is no longer enabled by default.
// We explicitly enable it here. Adding this doesn't seem to affect older boot versions
// and we get live information from JMX for those too.
"-Dspring.jmx.enabled=true"
//
"-Dspring.jmx.enabled=true",
//
// GH-862: Spring Boot 3 doesn't expose all actuators over JMX anymore by default
// therefore we need to set this for live hovers here
//
"-Dmanagement.endpoints.jmx.exposure.include=*"
};
}

View File

@@ -15,7 +15,6 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.ui.ide,
org.eclipse.jdt.ui,
org.eclipse.jdt.core,
org.dadacoalition.yedit,
org.eclipse.ui.editors,
org.springsource.ide.eclipse.commons.livexp;bundle-version="3.8.4",
org.springsource.ide.eclipse.commons.frameworks.core,

View File

@@ -1,40 +0,0 @@
/*******************************************************************************
* Copyright (c) 2015, 2016 Pivotal, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Pivotal, Inc. - initial API and implementation
*******************************************************************************/
package org.springframework.ide.eclipse.editor.support.yaml;
import org.dadacoalition.yedit.editor.YEdit;
import org.eclipse.core.resources.IFile;
import org.eclipse.ui.IEditorInput;
import com.google.common.collect.ImmutableSet;
public abstract class AbstractYamlEditor extends YEdit {
private static final ImmutableSet<String> YAML_EXTENSIONS = ImmutableSet.of("yml", "yaml");
protected ImmutableSet<String> getSupportedFileExtensions() {
return YAML_EXTENSIONS;
}
@Override
protected boolean canHandleMove(IEditorInput originalElement, IEditorInput movedElement) {
//See https://issuetracker.springsource.com/browse/STS-4299
IFile file = (IFile)movedElement.getAdapter(IFile.class);
if (file!=null) {
String extension = file.getFileExtension();
if (extension!=null) {
extension = extension.toLowerCase();
return getSupportedFileExtensions().contains(extension);
}
}
return false;
}
}

View File

@@ -1,244 +0,0 @@
/*******************************************************************************
* Copyright (c) 2015, 2017 Pivotal, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Pivotal, Inc. - initial API and implementation
*******************************************************************************/
package org.springframework.ide.eclipse.editor.support.yaml;
import java.lang.reflect.Constructor;
import java.util.HashSet;
import java.util.Set;
import javax.inject.Provider;
import org.dadacoalition.yedit.editor.YEditSourceViewerConfiguration;
import org.dadacoalition.yedit.template.YEditCompletionProcessor;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextHover;
import org.eclipse.jface.text.ITextViewerExtension2;
import org.eclipse.jface.text.contentassist.ContentAssistant;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
import org.eclipse.jface.text.contentassist.IContentAssistant;
import org.eclipse.jface.text.reconciler.IReconciler;
import org.eclipse.jface.text.reconciler.IReconcilingStrategy;
import org.eclipse.jface.text.source.Annotation;
import org.eclipse.jface.text.source.DefaultAnnotationHover;
import org.eclipse.jface.text.source.IAnnotationHover;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Shell;
import org.springframework.ide.eclipse.editor.support.EditorSupportActivator;
import org.springframework.ide.eclipse.editor.support.ForceableReconciler;
import org.springframework.ide.eclipse.editor.support.completions.CompletionFactory;
import org.springframework.ide.eclipse.editor.support.completions.ICompletionEngine;
import org.springframework.ide.eclipse.editor.support.completions.ProposalProcessor;
import org.springframework.ide.eclipse.editor.support.hover.HoverInfoProvider;
import org.springframework.ide.eclipse.editor.support.hover.HoverInfoTextHover;
import org.springframework.ide.eclipse.editor.support.reconcile.DefaultQuickfixContext;
import org.springframework.ide.eclipse.editor.support.reconcile.QuickfixContext;
import org.springframework.ide.eclipse.editor.support.reconcile.ReconcileProblemAnnotationHover;
import org.springframework.ide.eclipse.editor.support.util.DefaultUserInteractions;
import org.springframework.ide.eclipse.editor.support.yaml.ast.YamlASTProvider;
import org.springframework.ide.eclipse.editor.support.yaml.hover.YamlHoverInfoProvider;
import org.springframework.ide.eclipse.editor.support.yaml.structure.YamlStructureProvider;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.SafeConstructor;
/**
* @author Kris De Volder
*/
public abstract class AbstractYamlSourceViewerConfiguration extends YEditSourceViewerConfiguration {
private static final Set<String> ANNOTIONS_SHOWN_IN_TEXT = new HashSet<>();
static {
ANNOTIONS_SHOWN_IN_TEXT.add("org.eclipse.jdt.ui.warning");
ANNOTIONS_SHOWN_IN_TEXT.add("org.eclipse.jdt.ui.error");
}
private static final Set<String> ANNOTIONS_SHOWN_IN_OVERVIEW_BAR = ANNOTIONS_SHOWN_IN_TEXT;
//TODO: the ANNOTIONS_SHOWN_IN_TEXT and ANNOTIONS_SHOWN_IN_OVERVIEW_BAR should be replaced with
// properly using preferences. An example of how to set this up can be found in the code
// of the Java properties file editor. Roughly these things need to happen:
// 1) use methods like 'isShownIntext' and 'isShownInOverviewRuler' which are defined in
// our super class.
// 2) initialize the super class with a preference store (simialr to how java properties file does it)
// 3) To be able to do 2) it is necessary to add a constructor to YEditSourceViewerConfiguration which
// accepts preference store and passes it to its super class. So this requires a patch to
// YEdit source code.
private Provider<Shell> shellProvider;
private final String DIALOG_SETTINGS_KEY = this.getClass().getName();
private final YamlASTProvider astProvider = new YamlASTProvider(new Yaml(new SafeConstructor()));
private YamlCompletionEngine completionEngine;
protected ForceableReconciler fReconciler;
public AbstractYamlSourceViewerConfiguration(Provider<Shell> shellProvider) {
this.shellProvider = shellProvider;
}
protected final IDialogSettings getDialogSettings() {
IDialogSettings dialogSettings = getPluginDialogSettings();
IDialogSettings existing = dialogSettings.getSection(DIALOG_SETTINGS_KEY);
if (existing!=null) {
return existing;
}
IDialogSettings created = dialogSettings.addNewSection(DIALOG_SETTINGS_KEY);
Point defaultPopupSize = getDefaultPopupSize();
if (defaultPopupSize!=null) {
int suggestW = defaultPopupSize.x;
int suggestH = defaultPopupSize.y;
created.put(ContentAssistant.STORE_SIZE_X, suggestW);
created.put(ContentAssistant.STORE_SIZE_Y, suggestH);
}
return created;
}
protected Point getDefaultPopupSize() {
return null;
}
protected abstract IDialogSettings getPluginDialogSettings();
@Override
public final IContentAssistant getContentAssistant(ISourceViewer viewer) {
IContentAssistant _a = super_getContentAssistant(viewer);
if (_a instanceof ContentAssistant) {
ContentAssistant a = (ContentAssistant)_a;
//IContentAssistProcessor processor = assistant.getContentAssistProcessor(IDocument.DEFAULT_CONTENT_TYPE);
//if (processor!=null) {
//TODO: don't overwrite existing processor but wrap it so
// we combine our proposals with existing propopals
//}
a.setInformationControlCreator(getInformationControlCreator(viewer));
a.enableColoredLabels(true);
a.enablePrefixCompletion(false);
a.enableAutoInsert(true);
a.enableAutoActivation(true);
a.setRestoreCompletionProposalSize(getDialogSettings());
ProposalProcessor processor = new ProposalProcessor(getCompletionEngine(viewer));
a.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE);
a.setSorter(CompletionFactory.SORTER);
}
return _a;
}
private IContentAssistant super_getContentAssistant(ISourceViewer sourceViewer) {
//Copied from superclass's getContentAssistant... then modifed to make ContentAssistant
// asynchronous.
ContentAssistant ca;
try {
//Use reflection to call the constructor because it only exists in Eclipse 4.7.
Constructor<ContentAssistant> constructor = ContentAssistant.class.getConstructor(boolean.class);
ca = constructor.newInstance(true);
} catch (Exception e) {
ca = new ContentAssistant();
}
IContentAssistProcessor cap = new YEditCompletionProcessor();
ca.setContentAssistProcessor(cap, IDocument.DEFAULT_CONTENT_TYPE);
ca.setInformationControlCreator(getInformationControlCreator(sourceViewer));
ca.enableAutoInsert(true);
return ca;
}
@Override
public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType, int stateMask) {
if (contentType.equals(IDocument.DEFAULT_CONTENT_TYPE) && ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK==stateMask) {
ITextHover delegate = getTextAnnotationHover(sourceViewer);
try {
HoverInfoProvider hoverProvider = getHoverProvider(sourceViewer);
if (hoverProvider!=null) {
return new HoverInfoTextHover(sourceViewer, getHoverProvider(sourceViewer), delegate);
}
} catch (Exception e) {
EditorSupportActivator.log(e);
}
return delegate;
} else {
return super.getTextHover(sourceViewer, contentType, stateMask);
}
}
public ICompletionEngine getCompletionEngine(ISourceViewer viewer) {
if (completionEngine==null) {
completionEngine = new YamlCompletionEngine(getStructureProvider(), getAssistContextProvider(viewer));
}
return completionEngine;
}
protected HoverInfoProvider getHoverProvider(ISourceViewer viewer) {
return new YamlHoverInfoProvider(getAstProvider(), getStructureProvider(), getAssistContextProvider(viewer));
}
protected final YamlASTProvider getAstProvider() {
return astProvider;
}
@Override
public final IReconciler getReconciler(ISourceViewer sourceViewer) {
if (fReconciler==null) {
fReconciler = createReconciler(sourceViewer);
}
return fReconciler;
}
@Override
public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {
return new DefaultAnnotationHover() {
@Override
protected boolean isIncluded(Annotation annotation) {
return ANNOTIONS_SHOWN_IN_OVERVIEW_BAR.contains(annotation.getType());
}
};
}
protected ITextHover getTextAnnotationHover(ISourceViewer sourceViewer) {
return new ReconcileProblemAnnotationHover(sourceViewer, getQuickfixContext(sourceViewer));
}
protected Shell getShell() {
return shellProvider.get();
}
protected final QuickfixContext getQuickfixContext(ISourceViewer sourceViewer) {
return new DefaultQuickfixContext(
getPluginId(),
getPreferencesStore(),
sourceViewer,
new DefaultUserInteractions(getShell())
);
}
protected abstract String getPluginId();
protected abstract IPreferenceStore getPreferencesStore();
protected abstract YamlStructureProvider getStructureProvider();
protected abstract YamlAssistContextProvider getAssistContextProvider(ISourceViewer viewer);
protected IReconcilingStrategy createReconcilerStrategy(ISourceViewer sourceViewer) {
return null;
}
protected ForceableReconciler createReconciler(ISourceViewer sourceViewer) {
//TODO: aplication.properties|yaml editors are overriding this. That should not be necessary.
IReconcilingStrategy strategy = createReconcilerStrategy(sourceViewer);
if (strategy!=null) {
ForceableReconciler reconciler = new ForceableReconciler(strategy);
reconciler.setDelay(500);
return reconciler;
}
return null;
}
}

View File

@@ -97,7 +97,7 @@
<dist.key>TOOLS</dist.key>
<dist.path>${dist.type}/${dist.key}/${dist.project}/${dist.version}</dist.path>
<misc.p2.repo.version>3.9.4.202003091750</misc.p2.repo.version>
<misc.p2.repo.version>3.9.4.202211021051</misc.p2.repo.version>
</properties>
<profiles>
@@ -349,11 +349,6 @@
<layout>p2</layout>
<url>https://dist.springsource.com/release/TOOLS/third-party/misc-p2-repo/${misc.p2.repo.version}</url>
</repository>
<repository>
<id>yedit</id>
<layout>p2</layout>
<url>https://dist.springsource.com/release/TOOLS/third-party/yedit</url>
</repository>
</repositories>
<pluginRepositories>

View File

@@ -14,7 +14,7 @@
</parent>
<properties>
<gradle-tooling.version>6.7</gradle-tooling.version>
<gradle-tooling.version>7.3</gradle-tooling.version>
</properties>
<repositories>

View File

@@ -27,13 +27,21 @@
<artifactId>commons-java</artifactId>
<version>${project.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.github.classgraph/classgraph -->
<!-- ObjectDiff object becomes unresolved all of a sudden for JDT compiler as of rewrite 7.32.1. The dependency should come from rewrite -->
<!-- Try to remove in the future as it only seems to be required by Eclipse JDT. Maven build is happy without it -->
<dependency>
<groupId>io.github.classgraph</groupId>
<artifactId>classgraph</artifactId>
<version>4.8.149</version>
<groupId>de.danielbechler</groupId>
<artifactId>java-object-diff</artifactId>
<version>0.95</version>
</dependency>
<dependency>
<groupId>io.github.classgraph</groupId>
<artifactId>classgraph</artifactId>
<version>4.8.149</version>
</dependency>
<dependency>
<groupId>org.openrewrite</groupId>
<artifactId>rewrite-properties</artifactId>

View File

@@ -10,6 +10,7 @@
*******************************************************************************/
package org.springframework.ide.vscode.commons.rewrite.config;
import static java.util.Collections.emptyList;
import static org.openrewrite.internal.RecipeIntrospectionUtils.constructRecipe;
import static org.openrewrite.internal.RecipeIntrospectionUtils.recipeDescriptorFromRecipe;
@@ -48,7 +49,7 @@ public class StsClasspathScanningLoader implements ResourceLoader, StsResourceLo
private final List<CodeActionRepository> codeActionRepos = new ArrayList<>();
public StsClasspathScanningLoader(Path p, Properties properties, ClassLoader classLoader) {
public StsClasspathScanningLoader(Path p, Properties properties, Collection<? extends ResourceLoader> dependencyResourceLoaders, ClassLoader classLoader) {
if (Files.isDirectory(p)) {
String dir = p.toString();
@@ -61,7 +62,7 @@ public class StsClasspathScanningLoader implements ResourceLoader, StsResourceLo
.acceptPaths(dir)
.ignoreParentClassLoaders()
.overrideClassLoaders(classLoader)
.acceptPaths("META-INF/rewrite"), properties, classLoader);
.acceptPaths("META-INF/rewrite"), properties, dependencyResourceLoaders, classLoader);
} else {
String jarName = p.toFile().getName();
@@ -75,14 +76,14 @@ public class StsClasspathScanningLoader implements ResourceLoader, StsResourceLo
.acceptJars(jarName)
.ignoreParentClassLoaders()
.overrideClassLoaders(classLoader)
.acceptPaths("META-INF/rewrite"), properties, classLoader);
.acceptPaths("META-INF/rewrite"), properties, dependencyResourceLoaders, classLoader);
}
}
public StsClasspathScanningLoader(Properties properties, String[] acceptPackages) {
scanClasses(new ClassGraph().acceptPackages(acceptPackages), getClass().getClassLoader());
scanYaml(new ClassGraph().acceptPaths("META-INF/rewrite"), properties, null);
scanYaml(new ClassGraph().acceptPaths("META-INF/rewrite"), properties, emptyList(), null);
}
/**
@@ -99,19 +100,19 @@ public class StsClasspathScanningLoader implements ResourceLoader, StsResourceLo
scanYaml(new ClassGraph()
.ignoreParentClassLoaders()
.overrideClassLoaders(classLoader)
.acceptPaths("META-INF/rewrite"), properties, classLoader);
.acceptPaths("META-INF/rewrite"), properties, emptyList(), classLoader);
}
/**
* This must be called _after_ scanClasses or the descriptors of declarative recipes will be missing any
* non-declarative recipes they depend on that would be discovered by scanClasses
*/
private void scanYaml(ClassGraph classGraph, Properties properties, @Nullable ClassLoader classLoader) {
private void scanYaml(ClassGraph classGraph, Properties properties, Collection<? extends ResourceLoader> dependencyResourceLoaders, @Nullable ClassLoader classLoader) {
try (ScanResult scanResult = classGraph.enableMemoryMapping().scan()) {
List<YamlResourceLoader> yamlResourceLoaders = new ArrayList<>();
scanResult.getResourcesWithExtension("yml").forEachInputStreamIgnoringIOException((res, input) -> {
yamlResourceLoaders.add(new YamlResourceLoader(input, res.getURI(), properties, classLoader));
yamlResourceLoaders.add(new YamlResourceLoader(input, res.getURI(), properties, classLoader, dependencyResourceLoaders));
});
// Extract in two passes so that the full list of recipes from all sources are known when computing recipe descriptors
// Otherwise recipes which include recipes from other sources in their recipeList will have incomplete descriptors

View File

@@ -12,6 +12,7 @@ package org.springframework.ide.vscode.commons.rewrite.config;
import java.lang.reflect.Field;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Properties;
@@ -19,9 +20,12 @@ import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.openrewrite.config.ClasspathScanningLoader;
import org.openrewrite.config.Environment;
import org.openrewrite.config.ResourceLoader;
import static java.util.Collections.emptyList;
public class StsEnvironment extends Environment {
final private Supplier<Stream<CodeActionRepository>> codeActionRepos;
@@ -51,12 +55,22 @@ public class StsEnvironment extends Environment {
}
@Override
public org.openrewrite.config.Environment.Builder scanJar(Path jar, ClassLoader classLoader) {
return load(new StsClasspathScanningLoader(jar, props, classLoader));
public Environment.Builder scanJar(Path jar, Collection<Path> dependencies, ClassLoader classLoader) {
List<ClasspathScanningLoader> list = new ArrayList<>();
for (Path dep : dependencies) {
ClasspathScanningLoader classpathScanningLoader = new ClasspathScanningLoader(dep, props, emptyList(), classLoader);
list.add(classpathScanningLoader);
}
return load(new StsClasspathScanningLoader(jar, props, list, classLoader), list);
}
public org.openrewrite.config.Environment.Builder scanPath(Path dir, ClassLoader classLoader) {
return load(new StsClasspathScanningLoader(dir, props, classLoader));
public org.openrewrite.config.Environment.Builder scanPath(Path dir, Collection<Path> dependencies, ClassLoader classLoader) {
List<ClasspathScanningLoader> list = new ArrayList<>();
for (Path dep : dependencies) {
ClasspathScanningLoader classpathScanningLoader = new ClasspathScanningLoader(dep, props, emptyList(), classLoader);
list.add(classpathScanningLoader);
}
return load(new StsClasspathScanningLoader(dir, props, list, classLoader));
}
@SuppressWarnings("unchecked")

View File

@@ -109,9 +109,9 @@
<commons-codec-version>1.13</commons-codec-version>
<!-- Rewrite specific properties -->
<rewrite-version>7.30.0</rewrite-version>
<rewrite-spring-version>4.27.0</rewrite-spring-version>
<rewrite-java-migration.version>1.11.0</rewrite-java-migration.version>
<rewrite-version>7.32.1</rewrite-version>
<rewrite-spring-version>4.29.0</rewrite-spring-version>
<rewrite-java-migration.version>1.13.0</rewrite-java-migration.version>
<signing.skip>true</signing.skip>
<signing.alias>vmware</signing.alias>

View File

@@ -20,14 +20,8 @@
<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>

View File

@@ -50,7 +50,7 @@
<!-- Signing -->
<signing.skip>true</signing.skip>
<signing.alias>vmware</signing.alias>
<misc.p2.repo.version>3.9.4.201902271843</misc.p2.repo.version>
<misc.p2.repo.version>3.9.4.202211021051</misc.p2.repo.version>
</properties>
<profiles>

View File

@@ -25,6 +25,9 @@ public class SpringProblemCategories {
public static final ProblemCategory BOOT_3 = new ProblemCategory("boot3", "Boot 3.x Validation",
new Toggle("Enablement", EnumSet.allOf(Toggle.Option.class), AUTO, "boot-java.validation.java.boot3"));
public static final ProblemCategory SPRING_AOT = new ProblemCategory("spring-aot", "Spring AOT Validation",
new Toggle("Enablement", EnumSet.of(OFF, ON), OFF, "boot-java.validation.java.spring-aot"));
public static final ProblemCategory PROPERTIES = new ProblemCategory("application-properties", "Properties Validation", null);
public static final ProblemCategory YAML = new ProblemCategory("application-yaml", "YAML Properties Validation", null);

View File

@@ -11,7 +11,6 @@
package org.springframework.ide.vscode.boot.java;
import static org.springframework.ide.vscode.commons.languageserver.reconcile.ProblemSeverity.ERROR;
import static org.springframework.ide.vscode.commons.languageserver.reconcile.ProblemSeverity.WARNING;
import org.springframework.ide.vscode.boot.common.SpringProblemCategories;
import org.springframework.ide.vscode.commons.languageserver.reconcile.ProblemCategory;
@@ -24,12 +23,6 @@ import org.springframework.ide.vscode.commons.languageserver.reconcile.ProblemTy
*/
public enum Boot3JavaProblemType implements ProblemType {
JAVA_CONCRETE_BEAN_TYPE(WARNING, "Bean definition should have precise type for Spring 6 AOT", "Not precise bean defintion type"),
JAVA_BEAN_POST_PROCESSOR_IGNORED_IN_AOT(WARNING, "'BeanPostProcessor' behaviour is ignored in Spring 6 AOT", "'BeanPostProcessor' behaviour is ignored in AOT"),
JAVA_BEAN_NOT_REGISTERED_IN_AOT(WARNING, "Not registered as Bean", "Not registered as a Bean"),
JAVA_TYPE_NOT_SUPPORTED(ERROR, "Type no supported as of Spring Boot 3", "Type not supported as of Spring Boot 3"),
FACTORIES_KEY_NOT_SUPPORTED(ERROR, "Spring factories key not supported", "Spring factories key not supported");

View File

@@ -0,0 +1,64 @@
package org.springframework.ide.vscode.boot.java;
import static org.springframework.ide.vscode.commons.languageserver.reconcile.ProblemSeverity.WARNING;
import org.springframework.ide.vscode.boot.common.SpringProblemCategories;
import org.springframework.ide.vscode.commons.languageserver.reconcile.ProblemCategory;
import org.springframework.ide.vscode.commons.languageserver.reconcile.ProblemSeverity;
import org.springframework.ide.vscode.commons.languageserver.reconcile.ProblemType;
public enum SpringAotJavaProblemType implements ProblemType {
JAVA_CONCRETE_BEAN_TYPE(WARNING, "Bean definition should have precise type", "Not precise bean defintion type"),
JAVA_BEAN_POST_PROCESSOR_IGNORED_IN_AOT(WARNING, "'BeanPostProcessor' behaviour is ignored", "'BeanPostProcessor' behaviour is ignored in AOT"),
JAVA_BEAN_NOT_REGISTERED_IN_AOT(WARNING, "Not registered as Bean", "Not registered as a Bean");
private final ProblemSeverity defaultSeverity;
private String description;
private String label;
private SpringAotJavaProblemType(ProblemSeverity defaultSeverity, String description) {
this(defaultSeverity, description, null);
}
private SpringAotJavaProblemType(ProblemSeverity defaultSeverity, String description, String label) {
this.description = description;
this.defaultSeverity = defaultSeverity;
this.label = label;
}
@Override
public ProblemSeverity getDefaultSeverity() {
return defaultSeverity;
}
public String getLabel() {
if (label==null) {
label = createDefaultLabel();
}
return label;
}
@Override
public String getDescription() {
return description;
}
private String createDefaultLabel() {
String label = this.toString().substring(5).toLowerCase().replace('_', ' ');
return Character.toUpperCase(label.charAt(0)) + label.substring(1);
}
@Override
public String getCode() {
return name();
}
@Override
public ProblemCategory getCategory() {
return SpringProblemCategories.SPRING_AOT;
}
}

View File

@@ -1,3 +1,13 @@
/*******************************************************************************
* Copyright (c) 2022 VMware, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Pivotal, Inc. - initial API and implementation
*******************************************************************************/
package org.springframework.ide.vscode.boot.java.livehover.v2;
public class SpringProcessConnectorOverHttp implements SpringProcessConnector {

View File

@@ -232,7 +232,7 @@ public class RewriteRecipeRepository implements ApplicationContextAware {
if (pathStr.endsWith(".jar")) {
URLClassLoader classLoader = new URLClassLoader(new URL[] { f.toUri().toURL() },
getClass().getClassLoader());
builder.scanJar(f, classLoader);
builder.scanJar(f, Collections.emptyList(), classLoader);
} else if (pathStr.endsWith(".yml") || pathStr.endsWith(".yaml")) {
builder.load(new YamlResourceLoader(new FileInputStream(f.toFile()), f.toUri(), new Properties()));
}
@@ -245,7 +245,7 @@ public class RewriteRecipeRepository implements ApplicationContextAware {
Path d = Path.of(p);
if (Files.isDirectory(d)) {
URLClassLoader classLoader = new URLClassLoader(new URL[] { d.toUri().toURL()}, getClass().getClassLoader());
builder.scanPath(d, classLoader);
builder.scanPath(d, Collections.emptyList(), classLoader);
}
} catch (Exception e) {
log.error("Skipping folder " + p, e);

View File

@@ -24,7 +24,7 @@ import org.openrewrite.java.tree.J.ClassDeclaration;
import org.openrewrite.java.tree.J.MethodDeclaration;
import org.openrewrite.marker.Range;
import org.springframework.context.ApplicationContext;
import org.springframework.ide.vscode.boot.java.Boot3JavaProblemType;
import org.springframework.ide.vscode.boot.java.SpringAotJavaProblemType;
import org.springframework.ide.vscode.commons.java.IJavaProject;
import org.springframework.ide.vscode.commons.languageserver.reconcile.ProblemType;
import org.springframework.ide.vscode.commons.rewrite.config.RecipeCodeActionDescriptor;
@@ -81,7 +81,7 @@ public class BeanPostProcessingIgnoreInAotProblem implements RecipeCodeActionDes
@Override
public ProblemType getProblemType() {
return Boot3JavaProblemType.JAVA_BEAN_POST_PROCESSOR_IGNORED_IN_AOT;
return SpringAotJavaProblemType.JAVA_BEAN_POST_PROCESSOR_IGNORED_IN_AOT;
}
}

View File

@@ -31,7 +31,7 @@ import org.openrewrite.java.tree.JavaType.FullyQualified;
import org.openrewrite.java.tree.TypeUtils;
import org.springframework.context.ApplicationContext;
import org.springframework.ide.vscode.boot.app.SpringSymbolIndex;
import org.springframework.ide.vscode.boot.java.Boot3JavaProblemType;
import org.springframework.ide.vscode.boot.java.SpringAotJavaProblemType;
import org.springframework.ide.vscode.boot.java.beans.BeansSymbolAddOnInformation;
import org.springframework.ide.vscode.boot.java.beans.ConfigBeanSymbolAddOnInformation;
import org.springframework.ide.vscode.boot.java.handlers.EnhancedSymbolInformation;
@@ -169,7 +169,7 @@ public class NotRegisteredBeansProblem implements RecipeCodeActionDescriptor {
@Override
public ProblemType getProblemType() {
return Boot3JavaProblemType.JAVA_BEAN_NOT_REGISTERED_IN_AOT;
return SpringAotJavaProblemType.JAVA_BEAN_NOT_REGISTERED_IN_AOT;
}
private static String typePattern(JavaType type) {

View File

@@ -26,7 +26,7 @@ import org.openrewrite.java.tree.JavaType;
import org.openrewrite.java.tree.TypeUtils;
import org.openrewrite.marker.Range;
import org.springframework.context.ApplicationContext;
import org.springframework.ide.vscode.boot.java.Boot3JavaProblemType;
import org.springframework.ide.vscode.boot.java.SpringAotJavaProblemType;
import org.springframework.ide.vscode.commons.java.IJavaProject;
import org.springframework.ide.vscode.commons.rewrite.config.RecipeCodeActionDescriptor;
import org.springframework.ide.vscode.commons.rewrite.config.RecipeScope;
@@ -95,8 +95,8 @@ public class PreciseBeanTypeProblem implements RecipeCodeActionDescriptor {
}
@Override
public Boot3JavaProblemType getProblemType() {
return Boot3JavaProblemType.JAVA_CONCRETE_BEAN_TYPE;
public SpringAotJavaProblemType getProblemType() {
return SpringAotJavaProblemType.JAVA_CONCRETE_BEAN_TYPE;
}
}

View File

@@ -61,24 +61,6 @@
},
"order": 2,
"problemTypes": [
{
"code": "JAVA_CONCRETE_BEAN_TYPE",
"label": "Not precise bean defintion type",
"description": "Bean definition should have precise type for Spring 6 AOT",
"defaultSeverity": "WARNING"
},
{
"code": "JAVA_BEAN_POST_PROCESSOR_IGNORED_IN_AOT",
"label": "'BeanPostProcessor' behaviour is ignored in AOT",
"description": "'BeanPostProcessor' behaviour is ignored in Spring 6 AOT",
"defaultSeverity": "WARNING"
},
{
"code": "JAVA_BEAN_NOT_REGISTERED_IN_AOT",
"label": "Not registered as a Bean",
"description": "Not registered as Bean",
"defaultSeverity": "WARNING"
},
{
"code": "JAVA_TYPE_NOT_SUPPORTED",
"label": "Type not supported as of Spring Boot 3",
@@ -93,10 +75,44 @@
}
]
},
{
"id": "spring-aot",
"label": "Spring AOT Validation",
"toggle": {
"label": "Enablement",
"values": [
"OFF",
"ON"
],
"preferenceKey": "boot-java.validation.java.spring-aot",
"defaultValue": "OFF"
},
"order": 3,
"problemTypes": [
{
"code": "JAVA_CONCRETE_BEAN_TYPE",
"label": "Not precise bean defintion type",
"description": "Bean definition should have precise type",
"defaultSeverity": "WARNING"
},
{
"code": "JAVA_BEAN_POST_PROCESSOR_IGNORED_IN_AOT",
"label": "'BeanPostProcessor' behaviour is ignored in AOT",
"description": "'BeanPostProcessor' behaviour is ignored",
"defaultSeverity": "WARNING"
},
{
"code": "JAVA_BEAN_NOT_REGISTERED_IN_AOT",
"label": "Not registered as a Bean",
"description": "Not registered as Bean",
"defaultSeverity": "WARNING"
}
]
},
{
"id": "application-properties",
"label": "Properties Validation",
"order": 3,
"order": 4,
"problemTypes": [
{
"code": "PROP_INVALID_BEAN_NAVIGATION",
@@ -169,7 +185,7 @@
{
"id": "application-yaml",
"label": "YAML Properties Validation",
"order": 4,
"order": 5,
"problemTypes": [
{
"code": "YAML_SYNTAX_ERROR",
@@ -263,7 +279,7 @@
"preferenceKey": "boot-java.validation.spel.on",
"defaultValue": "ON"
},
"order": 5,
"order": 6,
"problemTypes": [
{
"code": "JAVA_SPEL_EXPRESSION_SYNTAX",

View File

@@ -12,6 +12,7 @@ package org.springframework.ide.vscode.boot.test;
import org.junit.jupiter.api.Test;
import org.springframework.ide.vscode.boot.java.Boot2JavaProblemType;
import org.springframework.ide.vscode.boot.java.SpringAotJavaProblemType;
import org.springframework.ide.vscode.boot.java.Boot3JavaProblemType;
import org.springframework.ide.vscode.boot.java.SpelProblemType;
import org.springframework.ide.vscode.boot.properties.reconcile.ApplicationPropertiesProblemType;
@@ -29,6 +30,7 @@ public class ProblemTypesMetadataTest {
reader.validate("application-yaml", ApplicationYamlProblemType.values());
reader.validate("boot2", Boot2JavaProblemType.values());
reader.validate("boot3", Boot3JavaProblemType.values());
reader.validate("spring-aot", SpringAotJavaProblemType.values());
reader.validate("spel", SpelProblemType.values());
}

View File

@@ -20,7 +20,6 @@ import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
@@ -28,6 +27,7 @@ import java.util.stream.Stream;
import org.apache.commons.io.FileUtils;
import org.springframework.ide.vscode.boot.java.Boot2JavaProblemType;
import org.springframework.ide.vscode.boot.java.SpringAotJavaProblemType;
import org.springframework.ide.vscode.boot.java.Boot3JavaProblemType;
import org.springframework.ide.vscode.boot.java.SpelProblemType;
import org.springframework.ide.vscode.boot.properties.reconcile.ApplicationPropertiesProblemType;
@@ -174,6 +174,7 @@ public class ProblemTypesToJson {
writer.collectProblemTypeData(Boot2JavaProblemType.values());
writer.collectProblemTypeData(ApplicationPropertiesProblemType.values());
writer.collectProblemTypeData(Boot3JavaProblemType.values());
writer.collectProblemTypeData(SpringAotJavaProblemType.values());
Collections.sort(writer.problemCategories);

View File

@@ -6,6 +6,7 @@ import psList from 'ps-list';
import { ListenablePreferenceSetting } from "@pivotal-tools/commons-vscode/lib/launch-util";
const JMX_VM_ARG = '-Dspring.jmx.enabled='
const ACTUATOR_JMX_EXPOSURE_ARG = '-Dmanagement.endpoints.jmx.exposure.include='
const ADMIN_VM_ARG = '-Dspring.application.admin.enabled='
const BOOT_PROJECT_ARG = '-Dspring.boot.project.name=';
const RMI_HOSTNAME = '-Djava.rmi.server.hostname=localhost';
@@ -23,6 +24,9 @@ class SpringBootDebugConfigProvider implements DebugConfigurationProvider {
if (debugConfiguration.vmArgs.indexOf(JMX_VM_ARG) < 0) {
debugConfiguration.vmArgs += ` ${JMX_VM_ARG}true`;
}
if (debugConfiguration.vmArgs.indexOf(ACTUATOR_JMX_EXPOSURE_ARG) < 0) {
debugConfiguration.vmArgs += ` ${ACTUATOR_JMX_EXPOSURE_ARG}*`;
}
if (debugConfiguration.vmArgs.indexOf(ADMIN_VM_ARG) < 0) {
debugConfiguration.vmArgs += ` ${ADMIN_VM_ARG}true`;
}
@@ -33,7 +37,7 @@ class SpringBootDebugConfigProvider implements DebugConfigurationProvider {
debugConfiguration.vmArgs += ` ${RMI_HOSTNAME}`;
}
} else {
debugConfiguration.vmArgs = `${JMX_VM_ARG}true ${ADMIN_VM_ARG}true ${BOOT_PROJECT_ARG}${debugConfiguration.projectName} ${RMI_HOSTNAME}`;
debugConfiguration.vmArgs = `${JMX_VM_ARG}true ${ACTUATOR_JMX_EXPOSURE_ARG}* ${ADMIN_VM_ARG}true ${BOOT_PROJECT_ARG}${debugConfiguration.projectName} ${RMI_HOSTNAME}`;
}
}
return debugConfiguration;

View File

@@ -378,42 +378,6 @@
"ON"
]
},
"spring-boot.ls.problem.boot3.JAVA_CONCRETE_BEAN_TYPE": {
"type": "string",
"default": "WARNING",
"description": "Bean definition should have precise type for Spring 6 AOT",
"enum": [
"IGNORE",
"INFO",
"WARNING",
"HINT",
"ERROR"
]
},
"spring-boot.ls.problem.boot3.JAVA_BEAN_POST_PROCESSOR_IGNORED_IN_AOT": {
"type": "string",
"default": "WARNING",
"description": "'BeanPostProcessor' behaviour is ignored in Spring 6 AOT",
"enum": [
"IGNORE",
"INFO",
"WARNING",
"HINT",
"ERROR"
]
},
"spring-boot.ls.problem.boot3.JAVA_BEAN_NOT_REGISTERED_IN_AOT": {
"type": "string",
"default": "WARNING",
"description": "Not registered as Bean",
"enum": [
"IGNORE",
"INFO",
"WARNING",
"HINT",
"ERROR"
]
},
"spring-boot.ls.problem.boot3.JAVA_TYPE_NOT_SUPPORTED": {
"type": "string",
"default": "ERROR",
@@ -440,10 +404,62 @@
}
}
},
{
"id": "spring-aot",
"title": "Spring AOT Validation",
"order": 403,
"properties": {
"boot-java.validation.java.spring-aot": {
"type": "string",
"default": "OFF",
"description": "Enablement",
"enum": [
"OFF",
"ON"
]
},
"spring-boot.ls.problem.spring-aot.JAVA_CONCRETE_BEAN_TYPE": {
"type": "string",
"default": "WARNING",
"description": "Bean definition should have precise type",
"enum": [
"IGNORE",
"INFO",
"WARNING",
"HINT",
"ERROR"
]
},
"spring-boot.ls.problem.spring-aot.JAVA_BEAN_POST_PROCESSOR_IGNORED_IN_AOT": {
"type": "string",
"default": "WARNING",
"description": "'BeanPostProcessor' behaviour is ignored",
"enum": [
"IGNORE",
"INFO",
"WARNING",
"HINT",
"ERROR"
]
},
"spring-boot.ls.problem.spring-aot.JAVA_BEAN_NOT_REGISTERED_IN_AOT": {
"type": "string",
"default": "WARNING",
"description": "Not registered as Bean",
"enum": [
"IGNORE",
"INFO",
"WARNING",
"HINT",
"ERROR"
]
}
}
},
{
"id": "application-properties",
"title": "Properties Validation",
"order": 403,
"order": 404,
"properties": {
"spring-boot.ls.problem.application-properties.PROP_INVALID_BEAN_NAVIGATION": {
"type": "string",
@@ -582,7 +598,7 @@
{
"id": "application-yaml",
"title": "YAML Properties Validation",
"order": 404,
"order": 405,
"properties": {
"spring-boot.ls.problem.application-yaml.YAML_SYNTAX_ERROR": {
"type": "string",
@@ -745,7 +761,7 @@
{
"id": "spel",
"title": "SPEL Validation",
"order": 405,
"order": 406,
"properties": {
"boot-java.validation.spel.on": {
"type": "string",
@@ -811,4 +827,4 @@
"extensionDependencies": [
"redhat.java"
]
}
}