From 45c649736110f3b5751e7071962ae473855a8dd7 Mon Sep 17 00:00:00 2001 From: Tagir Valeev Date: Fri, 19 Mar 2021 18:10:24 +0700 Subject: [PATCH] Move project-specific settings to the corresponding build.gradle files --- build.gradle | 78 ---------------------------------------- java5/build.gradle | 45 ++++++++++++++++++++++- java8/build.gradle | 16 ++++++++- module-info/build.gradle | 12 +++++++ 4 files changed, 71 insertions(+), 80 deletions(-) diff --git a/build.gradle b/build.gradle index 9116b63..b8232f8 100644 --- a/build.gradle +++ b/build.gradle @@ -47,29 +47,6 @@ subprojects { project(':java5').archivesBaseName = 'annotations-java5' project(':java8').archivesBaseName = 'annotations' -def jdk5Home = System.getenv("JDK_5") -if (hasProperty("JDK_5")) { - jdk5Home = JDK_5 -} -if (jdk5Home == null) { - throw new GradleException('JDK_5 environment variable is not defined. It must point to any JDK that ' + - 'is capable to compile with Java 5 target (Any JDK version from 1.5 to 1.8)') -} - -configure(project(':module-info')) { - dependencies { - compile project(':common') - } - - compileJava { - // Without common sources, compiler complains that exported packages don't exist - source = [sourceSets.main.java, project(':common').sourceSets.main.java] - } - - task mainJar(type: Jar) { - } -} - configure([project(':java5'), project(':java8')]) { dependencies { compile project(':module-info') @@ -161,59 +138,4 @@ configure([project(':java5'), project(':java8')]) { } } } - } - -configure(project(':java5')) { - def generatedSourcesDir = "${buildDir}/generated/" - - sourceSets { - generated { - java.srcDir generatedSourcesDir - } - } - - task generateSrc(type: Copy) { - from project(':common').sourceSets.main.java - into generatedSourcesDir - filter { line -> line.replaceAll(", ElementType.TYPE_USE", "")} - } - - compileJava { - options.fork = true - options.forkOptions.executable = "$jdk5Home/bin/javac" - dependsOn(generateSrc) - source sourceSets.generated.java - } - - mainJar { - from sourceSets.main.output - } - - sourceJar { - dependsOn(generateSrc) - from sourceSets.generated.java - } - - javadoc { - source = [sourceSets.generated.java] - } -} - -configure(project(':java8')) { - - mainJar { - from sourceSets.main.output - from project(':common').sourceSets.main.output - } - - sourceJar { - from sourceSets.main.java - from project(':common').sourceSets.main.java - } - - javadoc { - source = [sourceSets.main.java, project(':common').sourceSets.main.java] - } -} - diff --git a/java5/build.gradle b/java5/build.gradle index bde2dea..dc57369 100644 --- a/java5/build.gradle +++ b/java5/build.gradle @@ -1,5 +1,5 @@ /* - * Copyright 2000-2020 JetBrains s.r.o. + * Copyright 2000-2021 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,3 +16,46 @@ sourceCompatibility = 1.5 +def jdk5Home = System.getenv("JDK_5") +if (hasProperty("JDK_5")) { + jdk5Home = JDK_5 +} +if (jdk5Home == null) { + throw new GradleException('JDK_5 environment variable is not defined. It must point to any JDK that ' + + 'is capable to compile with Java 5 target (Any JDK version from 1.5 to 1.8)') +} + +def generatedSourcesDir = "${buildDir}/generated/" + +sourceSets { + generated { + java.srcDir generatedSourcesDir + } +} + +task generateSrc(type: Copy) { + from project(':common').sourceSets.main.java + into generatedSourcesDir + filter { line -> line.replaceAll(", ElementType.TYPE_USE", "")} +} + +compileJava { + options.fork = true + options.forkOptions.executable = "$jdk5Home/bin/javac" + dependsOn(generateSrc) + source sourceSets.generated.java +} + +mainJar { + from sourceSets.main.output +} + +sourceJar { + dependsOn(generateSrc) + from sourceSets.generated.java +} + +javadoc { + source = [sourceSets.generated.java] +} + diff --git a/java8/build.gradle b/java8/build.gradle index b995a55..9394239 100644 --- a/java8/build.gradle +++ b/java8/build.gradle @@ -1,5 +1,5 @@ /* - * Copyright 2000-2020 JetBrains s.r.o. + * Copyright 2000-2021 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,3 +15,17 @@ */ sourceCompatibility = 1.8 + +mainJar { + from sourceSets.main.output + from project(':common').sourceSets.main.output +} + +sourceJar { + from sourceSets.main.java + from project(':common').sourceSets.main.java +} + +javadoc { + source = [sourceSets.main.java, project(':common').sourceSets.main.java] +} diff --git a/module-info/build.gradle b/module-info/build.gradle index 46444b6..afce0a0 100644 --- a/module-info/build.gradle +++ b/module-info/build.gradle @@ -15,3 +15,15 @@ */ sourceCompatibility = 1.9 + +dependencies { + compile project(':common') +} + +compileJava { + // Without common sources, compiler complains that exported packages don't exist + source = [sourceSets.main.java, project(':common').sourceSets.main.java] +} + +task mainJar(type: Jar) { +}