3131/**
3232 * By registering bwc tasks via this extension we can support declaring custom bwc tasks from the build script
3333 * without relying on groovy closures and sharing common logic for tasks created by the BwcSetup plugin already.
34- * * /
34+ */
3535public class BwcSetupExtension {
3636
37- private static final String MINIMUM_COMPILER_VERSION_PATH = "buildSrc/ src/main/resources/minimumCompilerVersion" ;
37+ private static final String MINIMUM_COMPILER_VERSION_PATH = "src/main/resources/minimumCompilerVersion" ;
3838 private final Project project ;
3939 private final Provider <BwcVersions .UnreleasedVersionInfo > unreleasedVersionInfo ;
4040 private final Provider <InternalDistributionBwcSetupPlugin .BwcTaskThrottle > bwcTaskThrottleProvider ;
4141
4242 private Provider <File > checkoutDir ;
4343
4444 public BwcSetupExtension (
45- Project project ,
46- Provider <BwcVersions .UnreleasedVersionInfo > unreleasedVersionInfo ,
47- Provider <InternalDistributionBwcSetupPlugin .BwcTaskThrottle > bwcTaskThrottleProvider ,
48- Provider <File > checkoutDir
45+ Project project ,
46+ Provider <BwcVersions .UnreleasedVersionInfo > unreleasedVersionInfo ,
47+ Provider <InternalDistributionBwcSetupPlugin .BwcTaskThrottle > bwcTaskThrottleProvider ,
48+ Provider <File > checkoutDir
4949 ) {
5050 this .project = project ;
5151 this .unreleasedVersionInfo = unreleasedVersionInfo ;
@@ -65,7 +65,8 @@ private TaskProvider<LoggedExec> createRunBwcGradleTask(Project project, String
6565 loggedExec .setWorkingDir (checkoutDir .get ());
6666 loggedExec .doFirst (t -> {
6767 // Execution time so that the checkouts are available
68- String minimumCompilerVersion = readFromFile (new File (checkoutDir .get (), MINIMUM_COMPILER_VERSION_PATH ));
68+ String compilerVersionInfoPath = minimumCompilerVersionPath (project , checkoutDir );
69+ String minimumCompilerVersion = readFromFile (new File (checkoutDir .get (), compilerVersionInfoPath ));
6970 loggedExec .environment ("JAVA_HOME" , getJavaHome (Integer .parseInt (minimumCompilerVersion )));
7071 });
7172
@@ -107,6 +108,13 @@ private TaskProvider<LoggedExec> createRunBwcGradleTask(Project project, String
107108 });
108109 }
109110
111+ // TODO provide a long term reliable solution here.
112+ private String minimumCompilerVersionPath (Project project , Provider <File > checkoutDir ) {
113+ return (checkoutDir .get ().getName ().endsWith ("7.x" )) ?
114+ "build-tools-internal/" + MINIMUM_COMPILER_VERSION_PATH :
115+ "buildSrc/" + MINIMUM_COMPILER_VERSION_PATH ;
116+ }
117+
110118 private static class IndentingOutputStream extends OutputStream {
111119
112120 public final byte [] indent ;
@@ -119,7 +127,7 @@ private static class IndentingOutputStream extends OutputStream {
119127
120128 @ Override
121129 public void write (int b ) throws IOException {
122- int [] arr = { b };
130+ int [] arr = {b };
123131 write (arr , 0 , 1 );
124132 }
125133
0 commit comments