Upgrade to Boot 3 for eclipse
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
class="org.springframework.ide.eclipse.boot.core.BootPropertyTester"
|
||||
id="org.springsource.ide.eclipse.boot.BootPropertyTester"
|
||||
namespace="org.springsource.ide.eclipse.boot"
|
||||
properties="isBootProject,isBootResource,hasBootDevTools"
|
||||
properties="isBootProject,isBootResource,hasBootDevTools,isBoot2Project,isBoot2Resource"
|
||||
type="org.eclipse.core.resources.IResource">
|
||||
<!-- type="java.lang.Object" -->
|
||||
</propertyTester>
|
||||
@@ -19,7 +19,7 @@
|
||||
class="org.springframework.ide.eclipse.boot.core.BootJavaElementPropertyTester"
|
||||
id="org.springframework.ide.eclipse.boot.core.BootJavaElementPropertyTester"
|
||||
namespace="org.springsource.ide.eclipse.boot.javaelement"
|
||||
properties="isInBootProject,isInBootProjectWithDevTools"
|
||||
properties="isInBootProject,isInBootProjectWithDevTools,isInBoot2Project"
|
||||
type="org.eclipse.jdt.core.IJavaElement">
|
||||
<!-- type="java.lang.Object" -->
|
||||
</propertyTester>
|
||||
|
||||
@@ -31,6 +31,19 @@ public class BootJavaElementPropertyTester extends PropertyTester {
|
||||
if (je instanceof IJavaElement && "isInBootProjectWithDevTools".equals(property)) {
|
||||
return hasBootDevTools((IJavaElement) je);
|
||||
}
|
||||
if (je instanceof IJavaElement && "isInBoot2Project".equals(property)) {
|
||||
return isInBoot2Project((IJavaElement) je);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isInBoot2Project(IJavaElement je) {
|
||||
if (je!=null) {
|
||||
IJavaProject jp = je.getJavaProject();
|
||||
if (jp!=null) {
|
||||
return BootPropertyTester.isBoot2Project(jp.getProject());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -70,6 +70,12 @@ public class BootPropertyTester extends PropertyTester {
|
||||
if (rsrc instanceof IResource && "hasBootDevTools".equals(property)) {
|
||||
return hasBootDevTools(((IResource) rsrc).getProject());
|
||||
}
|
||||
if (rsrc instanceof IProject && "isBoot2Project".equals(property)) {
|
||||
return expectedValue.equals(isBoot2Project((IProject)rsrc));
|
||||
}
|
||||
if (rsrc instanceof IResource && "isBoot2Resource".equals(property)) {
|
||||
return expectedValue.equals(isBoot2Resource((IResource) rsrc));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -128,6 +134,30 @@ public class BootPropertyTester extends PropertyTester {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isBoot2Project(IProject project) {
|
||||
if (project==null || ! project.isAccessible()) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
if (project.hasNature(JavaCore.NATURE_ID)) {
|
||||
if (!isExcludedProject(project)) {
|
||||
IJavaProject jp = JavaCore.create(project);
|
||||
IClasspathEntry[] classpath = jp.getResolvedClasspath(true);
|
||||
//Look for a 'spring-boot' jar or project entry
|
||||
|
||||
for (IClasspathEntry e : classpath) {
|
||||
if ((isBootJar(e) || isBootProject(e)) && isVersion(e, "2.")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
CorePlugin.log(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean hasBootDevTools(IProject project) {
|
||||
try {
|
||||
ISpringBootProject bootProject = SpringBootCore.getDefault().project(project);
|
||||
@@ -231,6 +261,14 @@ public class BootPropertyTester extends PropertyTester {
|
||||
return result;
|
||||
}
|
||||
|
||||
private Object isBoot2Resource(IResource rsrc) {
|
||||
if (rsrc==null || ! rsrc.isAccessible()) {
|
||||
return false;
|
||||
}
|
||||
boolean result = isBoot2Project(rsrc.getProject());
|
||||
return result;
|
||||
}
|
||||
|
||||
public static boolean isBootProject(IClasspathEntry e) {
|
||||
if (e.getEntryKind()==IClasspathEntry.CPE_PROJECT) {
|
||||
IPath path = e.getPath();
|
||||
@@ -240,6 +278,16 @@ public class BootPropertyTester extends PropertyTester {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isVersion(IClasspathEntry e, String v) {
|
||||
if (e.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
|
||||
IPath path = e.getPath();
|
||||
String name = path.lastSegment();
|
||||
String version = getVersionFromJarName(name);
|
||||
return version.startsWith(v);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isBootJar(IClasspathEntry e) {
|
||||
if (e.getEntryKind()==IClasspathEntry.CPE_LIBRARY) {
|
||||
IPath path = e.getPath();
|
||||
|
||||
Reference in New Issue
Block a user