Build: Fix naming conventions task (#31681)

Move min compiler and runtime version to files so we can fix the source
and target comparability of the build script to those

Closes #31665
This commit is contained in:
Alpar Torok 2018-06-29 18:41:02 +00:00 committed by Nik Everett
parent 8c78fe7114
commit f702086df1
5 changed files with 19 additions and 12 deletions

View File

@ -16,8 +16,6 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
import java.nio.file.Files import java.nio.file.Files
plugins { plugins {
@ -41,6 +39,12 @@ if (project == rootProject) {
buildDir = 'build-bootstrap' buildDir = 'build-bootstrap'
} }
// Make sure :buildSrc: doesn't generate classes incompatible with RUNTIME_JAVA_HOME
// We can't use BuildPlugin here, so read from file
String minimumRuntimeVersion = file('src/main/resources/minimumRuntimeVersion').text.trim()
targetCompatibility = minimumRuntimeVersion
sourceCompatibility = minimumRuntimeVersion
/***************************************************************************** /*****************************************************************************
* Propagating version.properties to the rest of the build * * Propagating version.properties to the rest of the build *
*****************************************************************************/ *****************************************************************************/

View File

@ -19,7 +19,6 @@
package org.elasticsearch.gradle package org.elasticsearch.gradle
import com.carrotsearch.gradle.junit4.RandomizedTestingTask import com.carrotsearch.gradle.junit4.RandomizedTestingTask
import nebula.plugin.extraconfigurations.ProvidedBasePlugin
import org.apache.tools.ant.taskdefs.condition.Os import org.apache.tools.ant.taskdefs.condition.Os
import org.eclipse.jgit.lib.Constants import org.eclipse.jgit.lib.Constants
import org.eclipse.jgit.lib.RepositoryBuilder import org.eclipse.jgit.lib.RepositoryBuilder
@ -58,9 +57,6 @@ import java.time.ZonedDateTime
*/ */
class BuildPlugin implements Plugin<Project> { class BuildPlugin implements Plugin<Project> {
static final JavaVersion minimumRuntimeVersion = JavaVersion.VERSION_1_8
static final JavaVersion minimumCompilerVersion = JavaVersion.VERSION_1_10
@Override @Override
void apply(Project project) { void apply(Project project) {
if (project.pluginManager.hasPlugin('elasticsearch.standalone-rest-test')) { if (project.pluginManager.hasPlugin('elasticsearch.standalone-rest-test')) {
@ -95,6 +91,12 @@ class BuildPlugin implements Plugin<Project> {
/** Performs checks on the build environment and prints information about the build environment. */ /** Performs checks on the build environment and prints information about the build environment. */
static void globalBuildInfo(Project project) { static void globalBuildInfo(Project project) {
if (project.rootProject.ext.has('buildChecksDone') == false) { if (project.rootProject.ext.has('buildChecksDone') == false) {
JavaVersion minimumRuntimeVersion = JavaVersion.toVersion(
BuildPlugin.class.getClassLoader().getResourceAsStream("minimumRuntimeVersion").text.trim()
)
JavaVersion minimumCompilerVersion = JavaVersion.toVersion(
BuildPlugin.class.getClassLoader().getResourceAsStream("minimumCompilerVersion").text.trim()
)
String compilerJavaHome = findCompilerJavaHome() String compilerJavaHome = findCompilerJavaHome()
String runtimeJavaHome = findRuntimeJavaHome(compilerJavaHome) String runtimeJavaHome = findRuntimeJavaHome(compilerJavaHome)
File gradleJavaHome = Jvm.current().javaHome File gradleJavaHome = Jvm.current().javaHome
@ -192,10 +194,12 @@ class BuildPlugin implements Plugin<Project> {
project.rootProject.ext.runtimeJavaVersion = runtimeJavaVersionEnum project.rootProject.ext.runtimeJavaVersion = runtimeJavaVersionEnum
project.rootProject.ext.javaVersions = javaVersions project.rootProject.ext.javaVersions = javaVersions
project.rootProject.ext.buildChecksDone = true project.rootProject.ext.buildChecksDone = true
project.rootProject.ext.minimumCompilerVersion = minimumCompilerVersion
project.rootProject.ext.minimumRuntimeVersion = minimumRuntimeVersion
} }
project.targetCompatibility = minimumRuntimeVersion project.targetCompatibility = project.rootProject.ext.minimumRuntimeVersion
project.sourceCompatibility = minimumRuntimeVersion project.sourceCompatibility = project.rootProject.ext.minimumRuntimeVersion
// set java home for each project, so they dont have to find it in the root project // set java home for each project, so they dont have to find it in the root project
project.ext.compilerJavaHome = project.rootProject.ext.compilerJavaHome project.ext.compilerJavaHome = project.rootProject.ext.compilerJavaHome
@ -348,7 +352,7 @@ class BuildPlugin implements Plugin<Project> {
// just a self contained test-fixture configuration, likely transitive and hellacious // just a self contained test-fixture configuration, likely transitive and hellacious
return return
} }
configuration.resolutionStrategy { configuration.resolutionStrategy {
failOnVersionConflict() failOnVersionConflict()
} }
}) })

View File

@ -0,0 +1 @@
1.10

View File

@ -0,0 +1 @@
1.8

View File

@ -4,7 +4,6 @@ import org.elasticsearch.gradle.test.GradleIntegrationTestCase;
import org.gradle.testkit.runner.BuildResult; import org.gradle.testkit.runner.BuildResult;
import org.gradle.testkit.runner.GradleRunner; import org.gradle.testkit.runner.GradleRunner;
import org.gradle.testkit.runner.TaskOutcome; import org.gradle.testkit.runner.TaskOutcome;
import org.junit.Ignore;
import java.util.Arrays; import java.util.Arrays;
@ -22,7 +21,6 @@ public class NamingConventionsTaskIT extends GradleIntegrationTestCase {
assertTrue(output, output.contains("build plugin can be applied")); assertTrue(output, output.contains("build plugin can be applied"));
} }
@Ignore("AwaitsFix : https://github.com/elastic/elasticsearch/issues/31665")
public void testNameCheckFailsAsItShould() { public void testNameCheckFailsAsItShould() {
BuildResult result = GradleRunner.create() BuildResult result = GradleRunner.create()
.withProjectDir(getProjectDir("namingConventionsSelfTest")) .withProjectDir(getProjectDir("namingConventionsSelfTest"))
@ -48,7 +46,6 @@ public class NamingConventionsTaskIT extends GradleIntegrationTestCase {
} }
} }
@Ignore("AwaitsFix : https://github.com/elastic/elasticsearch/issues/31665")
public void testNameCheckFailsAsItShouldWithMain() { public void testNameCheckFailsAsItShouldWithMain() {
BuildResult result = GradleRunner.create() BuildResult result = GradleRunner.create()
.withProjectDir(getProjectDir("namingConventionsSelfTest")) .withProjectDir(getProjectDir("namingConventionsSelfTest"))