Skip to content

Commit

Permalink
Build: Fix naming conventions task (#31681)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
alpar-t authored and nik9000 committed Jun 29, 2018
1 parent 8c78fe7 commit f702086
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
8 changes: 6 additions & 2 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/


import java.nio.file.Files

plugins {
Expand All @@ -41,6 +39,12 @@ if (project == rootProject) {
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 *
*****************************************************************************/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package org.elasticsearch.gradle

import com.carrotsearch.gradle.junit4.RandomizedTestingTask
import nebula.plugin.extraconfigurations.ProvidedBasePlugin
import org.apache.tools.ant.taskdefs.condition.Os
import org.eclipse.jgit.lib.Constants
import org.eclipse.jgit.lib.RepositoryBuilder
Expand Down Expand Up @@ -58,9 +57,6 @@ import java.time.ZonedDateTime
*/
class BuildPlugin implements Plugin<Project> {

static final JavaVersion minimumRuntimeVersion = JavaVersion.VERSION_1_8
static final JavaVersion minimumCompilerVersion = JavaVersion.VERSION_1_10

@Override
void apply(Project project) {
if (project.pluginManager.hasPlugin('elasticsearch.standalone-rest-test')) {
Expand Down Expand Up @@ -95,6 +91,12 @@ class BuildPlugin implements Plugin<Project> {
/** Performs checks on the build environment and prints information about the build environment. */
static void globalBuildInfo(Project project) {
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 runtimeJavaHome = findRuntimeJavaHome(compilerJavaHome)
File gradleJavaHome = Jvm.current().javaHome
Expand Down Expand Up @@ -192,10 +194,12 @@ class BuildPlugin implements Plugin<Project> {
project.rootProject.ext.runtimeJavaVersion = runtimeJavaVersionEnum
project.rootProject.ext.javaVersions = javaVersions
project.rootProject.ext.buildChecksDone = true
project.rootProject.ext.minimumCompilerVersion = minimumCompilerVersion
project.rootProject.ext.minimumRuntimeVersion = minimumRuntimeVersion
}

project.targetCompatibility = minimumRuntimeVersion
project.sourceCompatibility = minimumRuntimeVersion
project.targetCompatibility = project.rootProject.ext.minimumRuntimeVersion
project.sourceCompatibility = project.rootProject.ext.minimumRuntimeVersion

// set java home for each project, so they dont have to find it in the root project
project.ext.compilerJavaHome = project.rootProject.ext.compilerJavaHome
Expand Down Expand Up @@ -348,7 +352,7 @@ class BuildPlugin implements Plugin<Project> {
// just a self contained test-fixture configuration, likely transitive and hellacious
return
}
configuration.resolutionStrategy {
configuration.resolutionStrategy {
failOnVersionConflict()
}
})
Expand Down
1 change: 1 addition & 0 deletions buildSrc/src/main/resources/minimumCompilerVersion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.10
1 change: 1 addition & 0 deletions buildSrc/src/main/resources/minimumRuntimeVersion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.8
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import org.gradle.testkit.runner.BuildResult;
import org.gradle.testkit.runner.GradleRunner;
import org.gradle.testkit.runner.TaskOutcome;
import org.junit.Ignore;

import java.util.Arrays;

Expand All @@ -22,7 +21,6 @@ public void testPluginCanBeApplied() {
assertTrue(output, output.contains("build plugin can be applied"));
}

@Ignore("AwaitsFix : https://github.com/elastic/elasticsearch/issues/31665")
public void testNameCheckFailsAsItShould() {
BuildResult result = GradleRunner.create()
.withProjectDir(getProjectDir("namingConventionsSelfTest"))
Expand All @@ -48,7 +46,6 @@ public void testNameCheckFailsAsItShould() {
}
}

@Ignore("AwaitsFix : https://github.com/elastic/elasticsearch/issues/31665")
public void testNameCheckFailsAsItShouldWithMain() {
BuildResult result = GradleRunner.create()
.withProjectDir(getProjectDir("namingConventionsSelfTest"))
Expand Down

0 comments on commit f702086

Please sign in to comment.