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.
pull/32224/head
Phillip Webb 2 years ago
parent 5470a6b349
commit d4ed2bd47a

@ -2,6 +2,7 @@ plugins {
id "java-gradle-plugin"
id "io.spring.javaformat" version "${javaFormatVersion}"
id "checkstyle"
id "eclipse"
}
repositories {
@ -110,3 +111,10 @@ gradlePlugin {
test {
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.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import javax.sql.DataSource;
@ -236,8 +237,7 @@ abstract class AbstractJpaAutoConfigurationTests {
this.contextRunner.run((context) -> {
assertThat(context).hasSingleBean(PersistenceManagedTypes.class);
EntityManager entityManager = context.getBean(EntityManagerFactory.class).createEntityManager();
assertThat(entityManager.getMetamodel().getManagedTypes().stream().map(ManagedType::getJavaType)
.toArray(Class<?>[]::new)).contains(City.class).doesNotContain(Country.class);
assertThat(getManagedJavaTypes(entityManager)).contains(City.class).doesNotContain(Country.class);
});
}
@ -248,8 +248,7 @@ abstract class AbstractJpaAutoConfigurationTests {
.run((context) -> {
assertThat(context).hasSingleBean(PersistenceManagedTypes.class);
EntityManager entityManager = context.getBean(EntityManagerFactory.class).createEntityManager();
assertThat(entityManager.getMetamodel().getManagedTypes().stream().map(ManagedType::getJavaType)
.toArray(Class<?>[]::new)).contains(Country.class).doesNotContain(City.class);
assertThat(getManagedJavaTypes(entityManager)).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)
static class TestTwoDataSourcesConfiguration {

@ -1,5 +1,6 @@
plugins {
id "java"
id "eclipse"
id "org.springframework.boot.deployed"
id "org.springframework.boot.conventions"
id "org.springframework.boot.integration-test"
@ -11,10 +12,12 @@ configurations {
dependenciesBom
loader
testRepository
compileOnlyProject
compileClasspath.extendsFrom(compileOnlyProject)
}
dependencies {
compileOnly(project(":spring-boot-project:spring-boot"))
compileOnlyProject(project(":spring-boot-project:spring-boot"))
compileOnly("jakarta.servlet:jakarta.servlet-api")
compileOnly("org.apache.groovy:groovy-templates")
compileOnly("org.springframework:spring-web")
@ -199,3 +202,6 @@ publishing {
}
}
eclipse.classpath { // https://github.com/eclipse/buildship/issues/939
plusConfigurations += [ configurations.compileOnlyProject ]
}

Loading…
Cancel
Save