Support import into Eclipse 2022-06
Fix a few issues preventing clean project import into Eclipse 2022-06: - `buildSrc` need to limit module imports to prevent clashes with those in the gradle API jar. - The CLI app needs some classpath changes in order to allow compileOnly project dependencies to resolve. - `AbstractJpaAutoConfigurationTests` needs some minor refactoring in order for generic captures to work with the Eclipse compiler.
This commit is contained in:
parent
5470a6b349
commit
d4ed2bd47a
|
@ -2,6 +2,7 @@ plugins {
|
||||||
id "java-gradle-plugin"
|
id "java-gradle-plugin"
|
||||||
id "io.spring.javaformat" version "${javaFormatVersion}"
|
id "io.spring.javaformat" version "${javaFormatVersion}"
|
||||||
id "checkstyle"
|
id "checkstyle"
|
||||||
|
id "eclipse"
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
@ -110,3 +111,10 @@ gradlePlugin {
|
||||||
test {
|
test {
|
||||||
useJUnitPlatform()
|
useJUnitPlatform()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
eclipse.classpath.file.whenMerged {
|
||||||
|
def jreEntry = entries.find { it.path.contains("org.eclipse.jdt.launching.JRE_CONTAINER") }
|
||||||
|
jreEntry.entryAttributes['module'] = 'true'
|
||||||
|
jreEntry.entryAttributes['limit-modules'] = 'java.base'
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ package org.springframework.boot.autoconfigure.orm.jpa;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
|
@ -236,8 +237,7 @@ abstract class AbstractJpaAutoConfigurationTests {
|
||||||
this.contextRunner.run((context) -> {
|
this.contextRunner.run((context) -> {
|
||||||
assertThat(context).hasSingleBean(PersistenceManagedTypes.class);
|
assertThat(context).hasSingleBean(PersistenceManagedTypes.class);
|
||||||
EntityManager entityManager = context.getBean(EntityManagerFactory.class).createEntityManager();
|
EntityManager entityManager = context.getBean(EntityManagerFactory.class).createEntityManager();
|
||||||
assertThat(entityManager.getMetamodel().getManagedTypes().stream().map(ManagedType::getJavaType)
|
assertThat(getManagedJavaTypes(entityManager)).contains(City.class).doesNotContain(Country.class);
|
||||||
.toArray(Class<?>[]::new)).contains(City.class).doesNotContain(Country.class);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,8 +248,7 @@ abstract class AbstractJpaAutoConfigurationTests {
|
||||||
.run((context) -> {
|
.run((context) -> {
|
||||||
assertThat(context).hasSingleBean(PersistenceManagedTypes.class);
|
assertThat(context).hasSingleBean(PersistenceManagedTypes.class);
|
||||||
EntityManager entityManager = context.getBean(EntityManagerFactory.class).createEntityManager();
|
EntityManager entityManager = context.getBean(EntityManagerFactory.class).createEntityManager();
|
||||||
assertThat(entityManager.getMetamodel().getManagedTypes().stream().map(ManagedType::getJavaType)
|
assertThat(getManagedJavaTypes(entityManager)).contains(Country.class).doesNotContain(City.class);
|
||||||
.toArray(Class<?>[]::new)).contains(Country.class).doesNotContain(City.class);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,6 +276,11 @@ abstract class AbstractJpaAutoConfigurationTests {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Class<?>[] getManagedJavaTypes(EntityManager entityManager) {
|
||||||
|
Set<ManagedType<?>> managedTypes = entityManager.getMetamodel().getManagedTypes();
|
||||||
|
return managedTypes.stream().map(ManagedType::getJavaType).toArray(Class<?>[]::new);
|
||||||
|
}
|
||||||
|
|
||||||
@Configuration(proxyBeanMethods = false)
|
@Configuration(proxyBeanMethods = false)
|
||||||
static class TestTwoDataSourcesConfiguration {
|
static class TestTwoDataSourcesConfiguration {
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
plugins {
|
plugins {
|
||||||
id "java"
|
id "java"
|
||||||
|
id "eclipse"
|
||||||
id "org.springframework.boot.deployed"
|
id "org.springframework.boot.deployed"
|
||||||
id "org.springframework.boot.conventions"
|
id "org.springframework.boot.conventions"
|
||||||
id "org.springframework.boot.integration-test"
|
id "org.springframework.boot.integration-test"
|
||||||
|
@ -11,10 +12,12 @@ configurations {
|
||||||
dependenciesBom
|
dependenciesBom
|
||||||
loader
|
loader
|
||||||
testRepository
|
testRepository
|
||||||
|
compileOnlyProject
|
||||||
|
compileClasspath.extendsFrom(compileOnlyProject)
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(project(":spring-boot-project:spring-boot"))
|
compileOnlyProject(project(":spring-boot-project:spring-boot"))
|
||||||
compileOnly("jakarta.servlet:jakarta.servlet-api")
|
compileOnly("jakarta.servlet:jakarta.servlet-api")
|
||||||
compileOnly("org.apache.groovy:groovy-templates")
|
compileOnly("org.apache.groovy:groovy-templates")
|
||||||
compileOnly("org.springframework:spring-web")
|
compileOnly("org.springframework:spring-web")
|
||||||
|
@ -199,3 +202,6 @@ publishing {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
eclipse.classpath { // https://github.com/eclipse/buildship/issues/939
|
||||||
|
plusConfigurations += [ configurations.compileOnlyProject ]
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue