|
@@ -1,8 +1,11 @@
|
|
|
-val baseBuildDir = "{{ export_root }}/gradle.build/"
|
|
|
-buildDir = file(baseBuildDir + project.path.replaceFirst(":", "/").replace(":", "."))
|
|
|
-subprojects {
|
|
|
- buildDir = file(baseBuildDir + project.path.replaceFirst(":", "/").replace(":", "."))
|
|
|
-}
|
|
|
+{%- set has_errorprone = target.consumer|selectattr('jar', 'startsWith', 'contrib/java/com/google/errorprone/error_prone_annotations')|length -%}
|
|
|
+{%- if has_errorprone -%}
|
|
|
+import net.ltgt.gradle.errorprone.CheckSeverity
|
|
|
+import net.ltgt.gradle.errorprone.errorprone
|
|
|
+
|
|
|
+{% endif -%}
|
|
|
+
|
|
|
+{%- include "[generator]/builddir.jinja" %}
|
|
|
|
|
|
{%- macro OutDirs(runs, prefix, suffix) -%}
|
|
|
{%- if run.args|length and run.out_dir|length -%}
|
|
@@ -31,179 +34,27 @@ subprojects {
|
|
|
{%- set required_jdk = target.required_jdk -%}
|
|
|
{%- endif %}
|
|
|
|
|
|
-plugins {
|
|
|
-{%- if mainClass %}
|
|
|
- `application`
|
|
|
-{%- else %}
|
|
|
- `java-library`
|
|
|
-{%- endif %}
|
|
|
-{%- if publish %}
|
|
|
- `maven-publish`
|
|
|
- `signing`
|
|
|
-{%- endif -%}
|
|
|
-{%- if with_kotlin and kotlin_version %}
|
|
|
- kotlin("jvm") version "{{ kotlin_version }}"
|
|
|
-{%- if target.with_kotlinc_plugin_allopen|length %}
|
|
|
- kotlin("plugin.allopen") version "{{ kotlin_version }}"
|
|
|
-{% endif -%}
|
|
|
-{%- if target.with_kotlinc_plugin_lombok|length %}
|
|
|
- kotlin("plugin.lombok") version "{{ kotlin_version }}"
|
|
|
-{% endif -%}
|
|
|
-{%- if target.with_kotlinc_plugin_noarg|length %}
|
|
|
- kotlin("plugin.noarg") version "{{ kotlin_version }}"
|
|
|
-{% endif -%}
|
|
|
-{%- if target.with_kotlinc_plugin_serialization|length %}
|
|
|
- kotlin("plugin.serialization") version "{{ kotlin_version }}"
|
|
|
-{% endif -%}
|
|
|
-{%- endif -%}
|
|
|
-
|
|
|
-{#- errorprone plugin configuration -#}
|
|
|
-{%- if errorprone -%}
|
|
|
-{%- set errorprone_plugin_version = "4.0.0" -%}
|
|
|
-{%- if target.consumer|selectattr('jar', 'startsWith', 'contrib/java/com/google/errorprone/error_prone_annotations')|length %}
|
|
|
- id("net.ltgt.errorprone") version "{{ errorprone_plugin_version }}"
|
|
|
-{%- endif -%}
|
|
|
-{%- endif -%}
|
|
|
-
|
|
|
-{#- lombok plugin configuration -#}
|
|
|
-{#- TODO remove usings annotation_processors semantic -#}
|
|
|
-{%- if ("lombok.launch.AnnotationProcessorHider$AnnotationProcessor" in target.annotation_processors) or (target.use_annotation_processor|length and target.use_annotation_processor|select('startsWith', 'contrib/java/org/projectlombok/lombok')|length) %}
|
|
|
- id("io.freefair.lombok") version "8.6"
|
|
|
-{%- endif %}
|
|
|
-}
|
|
|
-
|
|
|
-{#- language level -#}
|
|
|
-{%- if has_required_jdk %}
|
|
|
-
|
|
|
-java {
|
|
|
- toolchain {
|
|
|
- languageVersion = JavaLanguageVersion.of("{{ required_jdk }}")
|
|
|
- }
|
|
|
-}
|
|
|
-{% endif -%}
|
|
|
-
|
|
|
-{%- if target.with_kotlinc_plugin_allopen|length -%}
|
|
|
-{%- set allopen_annotations = [] -%}
|
|
|
-{%- if target.with_kotlinc_plugin_allopen|select('eq', 'preset=spring')|length -%}
|
|
|
-{%- set allopen_annotations = allopen_annotations + ['org.springframework.stereotype.Component', 'org.springframework.transaction.annotation.Transactional', 'org.springframework.scheduling.annotation.Async', 'org.springframework.cache.annotation.Cacheable', 'org.springframework.boot.test.context.SpringBootTest', 'org.springframework.validation.annotation.Validated'] -%}
|
|
|
-{%- endif -%}
|
|
|
-{%- if target.with_kotlinc_plugin_allopen|select('eq', 'preset=quarkus')|length -%}
|
|
|
-{%- set allopen_annotations = allopen_annotations + ['javax.enterprise.context.ApplicationScoped', 'javax.enterprise.context.RequestScoped'] -%}
|
|
|
-{%- endif -%}
|
|
|
-{%- if target.with_kotlinc_plugin_allopen|select('eq', 'preset=micronaut')|length -%}
|
|
|
-{%- set allopen_annotations = allopen_annotations + ['io.micronaut.aop.Around', 'io.micronaut.aop.Introduction', 'io.micronaut.aop.InterceptorBinding', 'io.micronaut.aop.InterceptorBindingDefinitions'] -%}
|
|
|
-{%- endif -%}
|
|
|
-{%- if target.with_kotlinc_plugin_allopen|select('startsWith', 'annotation=')|length -%}
|
|
|
-{%- set sannotations = target.with_kotlinc_plugin_allopen|select('startsWith', 'annotation=')|join('|')|replace('annotation=','') -%}
|
|
|
-{%- set annotations = split(sannotations, '|') -%}
|
|
|
-{%- set allopen_annotations = allopen_annotations + annotations -%}
|
|
|
-{%- endif -%}
|
|
|
-{%- set allopen_options = target.with_kotlinc_plugin_allopen|reject('startsWith', 'preset=')|reject('startsWith', 'annotation=')|reject('eq', 'default') %}
|
|
|
-
|
|
|
-allOpen {
|
|
|
-{%- if allopen_options|length -%}
|
|
|
-{%- for option in allopen_options|unique %}
|
|
|
- {{ option }}
|
|
|
-{%- endfor -%}
|
|
|
-{%- endif %}
|
|
|
-{%- if allopen_annotations|length -%}
|
|
|
-{%- for annotation in allopen_annotations|unique %}
|
|
|
- annotation("{{ annotation }}")
|
|
|
-{%- endfor -%}
|
|
|
-{%- endif %}
|
|
|
-}
|
|
|
-{% endif -%}
|
|
|
-
|
|
|
-{%- if target.with_kotlinc_plugin_noarg|length -%}
|
|
|
-{%- set noarg_annotations = [] -%}
|
|
|
-{%- if target.with_kotlinc_plugin_noarg|select('eq', 'preset=jpa')|length -%}
|
|
|
-{%- set noarg_annotations = noarg_annotations + ['javax.persistence.Entity', 'javax.persistence.Embeddable', 'javax.persistence.MappedSuperclass', 'jakarta.persistence.Entity', 'jakarta.persistence.Embeddable', 'jakarta.persistence.MappedSuperclass'] -%}
|
|
|
-{%- endif -%}
|
|
|
-{%- if target.with_kotlinc_plugin_noarg|select('startsWith', 'annotation=')|length -%}
|
|
|
-{%- set sannotations = target.with_kotlinc_plugin_noarg|select('startsWith', 'annotation=')|join('|')|replace('annotation=','') -%}
|
|
|
-{%- set annotations = split(sannotations, '|') -%}
|
|
|
-{%- set noarg_annotations = noarg_annotations + annotations -%}
|
|
|
-{%- endif -%}
|
|
|
-{%- set noarg_options = target.with_kotlinc_plugin_noarg|reject('startsWith', 'preset=')|reject('startsWith', 'annotation=')|reject('eq', 'default') %}
|
|
|
-
|
|
|
-noArg {
|
|
|
-{%- if noarg_options|length -%}
|
|
|
-{%- for option in noarg_options|unique %}
|
|
|
- {{ option }}
|
|
|
-{%- endfor -%}
|
|
|
-{%- endif %}
|
|
|
-{%- if noarg_annotations|length -%}
|
|
|
-{%- for annotation in noarg_annotations|unique %}
|
|
|
- annotation("{{ annotation }}")
|
|
|
-{%- endfor -%}
|
|
|
-{%- endif %}
|
|
|
-}
|
|
|
-{% endif -%}
|
|
|
-
|
|
|
-{%- if with_kotlin %}
|
|
|
-
|
|
|
-kotlin {
|
|
|
- jvmToolchain({{ required_jdk }})
|
|
|
-}
|
|
|
-{% endif -%}
|
|
|
-
|
|
|
-{%- if publish %}
|
|
|
-
|
|
|
-group = "{{ target.publish_group }}"
|
|
|
-version = {% if target.publish_version and target.publish_version != "no" -%}"{{ target.publish_version }}"{%- else -%}project.properties["version"]!!{%- endif %}
|
|
|
-{% endif -%}
|
|
|
-
|
|
|
-{%- if target.enable_preview %}
|
|
|
-
|
|
|
-tasks.withType<JavaCompile> {
|
|
|
- options.compilerArgs.add("--enable-preview")
|
|
|
- options.compilerArgs.add("-Xlint:preview")
|
|
|
- options.release.set({{ required_jdk }})
|
|
|
-}
|
|
|
-
|
|
|
-tasks.withType<JavaExec> {
|
|
|
- jvmArgs?.add("--enable-preview")
|
|
|
-}
|
|
|
-
|
|
|
-tasks.withType<Test> {
|
|
|
- jvmArgs?.add("--enable-preview")
|
|
|
- environment["JAVA_TOOL_OPTIONS"] = "--enable-preview"
|
|
|
-}
|
|
|
-
|
|
|
-tasks.withType<Javadoc> {
|
|
|
- val javadocOptions = options as CoreJavadocOptions
|
|
|
- javadocOptions.addStringOption("source", "{{ required_jdk }}")
|
|
|
- javadocOptions.addBooleanOption("-enable-preview", true)
|
|
|
-}
|
|
|
-{% endif -%}
|
|
|
+{% include "[generator]/plugins.jinja" -%}
|
|
|
+{%- include "[generator]/kotlin_plugins.jinja" -%}
|
|
|
+{%- include "[generator]/publish.jinja" -%}
|
|
|
+{%- include "[generator]/preview.jinja" -%}
|
|
|
|
|
|
{#- javac flags -#}
|
|
|
{%- if target.javac.flags|length -%}
|
|
|
-{%- set javac_flags = target.javac.flags|reject('startsWith', '-Xep:') -%}
|
|
|
-{%- if javac_flags|length %}
|
|
|
+{#- skip errorprone options -#}
|
|
|
+{%- set javac_flags = target.javac.flags|reject('startsWith', '-Xep:')|reject('startsWith', '-XepOpt:') -%}
|
|
|
+{%- if javac_flags|length and javac_flags != ['-parameters'] %}
|
|
|
|
|
|
tasks.withType<JavaCompile> {
|
|
|
{%- for javac_flag in javac_flags %}
|
|
|
options.compilerArgs.add("{{ javac_flag }}")
|
|
|
{%- endfor %}
|
|
|
}
|
|
|
-{%- endif -%}
|
|
|
-{%- endif %}
|
|
|
-
|
|
|
-val bucketUsername: String by project
|
|
|
-val bucketPassword: String by project
|
|
|
-repositories {
|
|
|
- repositories {
|
|
|
- maven {
|
|
|
- url = uri("https://bucket.yandex-team.ru/v1/maven/central")
|
|
|
- credentials {
|
|
|
- username = "$bucketUsername"
|
|
|
- password = "$bucketPassword"
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
+{% endif -%}
|
|
|
+{%- endif -%}
|
|
|
|
|
|
+{%- include "[generator]/errorprone.jinja" %}
|
|
|
+{% include "[generator]/bucket.jinja" %}
|
|
|
val project_root = "{{ arcadia_root }}"
|
|
|
|
|
|
{% if mainClass -%}
|
|
@@ -247,134 +98,9 @@ tasks.test {
|
|
|
}
|
|
|
{% endif -%}
|
|
|
|
|
|
-{%- if target.jar_source_set is defined %}
|
|
|
-
|
|
|
-{%- for source_set in target.jar_source_set -%}
|
|
|
-{%- set srcdir_glob = split(source_set, ':') %}
|
|
|
-sourceSets.main.java.srcDirs += "{{ srcdir_glob[0] }}"
|
|
|
-{%- endfor -%}
|
|
|
-{%- endif -%}
|
|
|
-
|
|
|
-{% for extra_target in extra_targets -%}
|
|
|
-{%- if extra_target.jar_source_set is defined -%}
|
|
|
-{%- for source_set in extra_target.jar_source_set -%}
|
|
|
-{%- set srcdir_glob = split(source_set, ':') %}
|
|
|
-sourceSets.main.java.srcDirs += "{{ srcdir_glob[0] }}"
|
|
|
-{%- endfor -%}
|
|
|
-{%- endif -%}
|
|
|
-{%- endfor -%}
|
|
|
-
|
|
|
-sourceSets {
|
|
|
-{%- if target.runs|length %}
|
|
|
- main {
|
|
|
- {#-
|
|
|
- Default by Gradle:
|
|
|
-
|
|
|
- java.srcDir("src/main/java")
|
|
|
- resources.srcDir("src/main/resources")
|
|
|
-
|
|
|
- #}
|
|
|
-{%- for run in target.runs -%}
|
|
|
-{{ OutDirs(run, ' java.srcDir("', '")') }}
|
|
|
-{%- endfor %}
|
|
|
- }
|
|
|
-{%- endif %}
|
|
|
- test {
|
|
|
- {#-
|
|
|
- Default by Gradle:
|
|
|
+{%- include "[generator]/source_sets.jinja" %}
|
|
|
|
|
|
- java.srcDir("src/test/java")
|
|
|
- resources.srcDir("src/test/resources")
|
|
|
-
|
|
|
- #}
|
|
|
- java.srcDir("ut/java")
|
|
|
- resources.srcDir("ut/resources")
|
|
|
- java.srcDir("src/test-integration/java")
|
|
|
- resources.srcDir("src/test-integration/resources")
|
|
|
- java.srcDir("src/testFixtures/java")
|
|
|
- resources.srcDir("src/testFixtures/resources")
|
|
|
- java.srcDir("src/intTest/java")
|
|
|
- resources.srcDir("src/intTest/resources")
|
|
|
-{%- for extra_target in extra_targets -%}
|
|
|
-{%- if extra_target|length -%}
|
|
|
-{%- for run in extra_target.runs -%}
|
|
|
-{{ OutDirs(run, ' java.srcDir("', '")') }}
|
|
|
-{%- endfor -%}
|
|
|
-{%- endif -%}
|
|
|
-{%- endfor %}
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-dependencies {
|
|
|
-{%- for library in target.consumer if library.classpath -%}
|
|
|
-{%- if errorprone -%}
|
|
|
-{%- if library.prebuilt and (library.type != "contrib" or build_contribs) and ("contrib/java/com/google/errorprone/error_prone_annotations" in library.jar) -%}
|
|
|
-{%- set errorprone_version = library.jar|replace("contrib/java/com/google/errorprone/error_prone_annotations/", "") -%}
|
|
|
-{%- set errorprone_parts = split(errorprone_version, '/', 2) %}
|
|
|
- errorprone("com.google.errorprone:error_prone_core:{{ errorprone_parts[0] }}")
|
|
|
-{%- endif -%}
|
|
|
-{%- endif -%}
|
|
|
-
|
|
|
-{%- if library.prebuilt and library.jar and (library.type != "contrib" or build_contribs) %}
|
|
|
- implementation(files("$project_root/{{ library.jar }}"))
|
|
|
-{%- else -%}
|
|
|
-{%- set classpath = library.classpath -%}
|
|
|
-{%- if classpath|replace('"','') == classpath -%}
|
|
|
-{%- set classpath = '"' + classpath + '"' -%}
|
|
|
-{%- endif -%}
|
|
|
-{%- if library.type != "contrib" %}
|
|
|
-{%- if library.testdep %}
|
|
|
- implementation(project(path = ":{{ library.testdep | replace("/", ":") }}", configuration = "testArtifacts"))
|
|
|
-{%- else %}
|
|
|
- implementation({{ classpath }})
|
|
|
-{%- endif -%}
|
|
|
-{%- else %}
|
|
|
- api({{ classpath }})
|
|
|
-{%- endif -%}
|
|
|
-{%- if library.excludes.consumer is defined %} {
|
|
|
-{% for exclude in library.excludes.consumer if exclude.classpath -%}
|
|
|
-{%- set classpath = exclude.classpath|replace('"','') -%}
|
|
|
-{%- set classpath_parts = split(classpath, ':') -%}
|
|
|
- exclude(group = "{{ classpath_parts[0] }}", module = "{{ classpath_parts[1] }}")
|
|
|
-{% endfor -%}
|
|
|
- }
|
|
|
-{%- endif -%}
|
|
|
-{%- endif -%}
|
|
|
-{%- endfor -%}
|
|
|
-
|
|
|
-{%- for annotation_processor in target.use_annotation_processor %}
|
|
|
- annotationProcessor(files("$project_root/{{ annotation_processor}}"))
|
|
|
-{%- endfor -%}
|
|
|
-
|
|
|
-{%- for extra_target in extra_targets -%}
|
|
|
-{%- for library in extra_target.consumer if library.classpath -%}
|
|
|
-{%- if library.prebuilt and library.jar and (library.type != "contrib" or build_contribs) %}
|
|
|
- testImplementation(files("$project_root/{{ library.jar }}"))
|
|
|
-{%- else -%}
|
|
|
-{%- set classpath = library.classpath -%}
|
|
|
-{%- if classpath|replace('"','') == classpath -%}
|
|
|
-{%- set classpath = '"' + classpath + '"' -%}
|
|
|
-{%- endif %}
|
|
|
-{%- if library.type != "contrib" and library.testdep %}
|
|
|
- testImplementation(project(path = ":{{ library.testdep | replace("/", ":") }}", configuration = "testArtifacts"))
|
|
|
-{%- else %}
|
|
|
- testImplementation({{ classpath }})
|
|
|
-{%- endif -%}
|
|
|
-{%- if library.excludes.consumer is defined %} {
|
|
|
-{% for exclude in library.excludes.consumer if exclude.classpath -%}
|
|
|
-{%- set classpath = exclude.classpath|replace('"','') -%}
|
|
|
-{%- set classpath_parts = split(classpath, ':') -%}
|
|
|
- exclude(group = "{{ classpath_parts[0] }}", module = "{{ classpath_parts[1] }}")
|
|
|
-{% endfor -%}
|
|
|
- }
|
|
|
-{%- endif -%}
|
|
|
-{%- endif -%}
|
|
|
-{%- endfor -%}
|
|
|
-{%- for annotation_processor in extra_target.use_annotation_processor %}
|
|
|
- testAnnotationProcessor(files("$project_root/{{ annotation_processor}}"))
|
|
|
-{%- endfor -%}
|
|
|
-{%- endfor %}
|
|
|
-}
|
|
|
+{% include "[generator]/dependencies.jinja" -%}
|
|
|
|
|
|
{%- if hasJunit5Test %}
|
|
|
|
|
@@ -383,63 +109,7 @@ tasks.named<Test>("test") {
|
|
|
}
|
|
|
{% endif -%}
|
|
|
|
|
|
-{#- run_java_program -#}
|
|
|
-{%- if target.runs|length -%}
|
|
|
-{%- for run in target.runs %}
|
|
|
-
|
|
|
-val runJav{{ loop.index }} = task<JavaExec>("runJavaProgram{{ loop.index }}") {
|
|
|
- group = "build"
|
|
|
- description = "Code generation by run java program"
|
|
|
-{%- if run.classpath|length %}
|
|
|
-{% for classpath in run.classpath -%}
|
|
|
-{%- set rel_file_classpath = classpath|replace('@', '')|replace(export_root, '')|replace(arcadia_root, '') %}
|
|
|
- val classpaths = "$project_root/" + File("$project_root{{ rel_file_classpath }}").readText().trim().replace(":", ":$project_root/")
|
|
|
- classpath = files(classpaths.split(":"))
|
|
|
-{%- endfor -%}
|
|
|
-{% else %}
|
|
|
- classpath = sourceSets.main.get().runtimeClasspath
|
|
|
-{%- endif %}
|
|
|
-
|
|
|
- mainClass.set("{{ run.args[0] }}")
|
|
|
-{%- if run.args|length > 1 %}
|
|
|
-
|
|
|
- args = listOf(
|
|
|
-{%- for arg in run.args -%}
|
|
|
-{%- if not loop.first %}
|
|
|
- "{{ arg }}",
|
|
|
-{%- endif -%}
|
|
|
-{%- endfor %}
|
|
|
- )
|
|
|
-{% endif -%}
|
|
|
-
|
|
|
-{%- if run.in_dir %}
|
|
|
-{% for in_dir in run.in_dir -%}
|
|
|
- inputs.files(fileTree("{{ in_dir }}"))
|
|
|
-{% endfor -%}
|
|
|
-{%- endif -%}
|
|
|
-{%- if run.in %}
|
|
|
-{% for in_file in run.in -%}
|
|
|
- inputs.files("{{ in_file }}")
|
|
|
-{% endfor -%}
|
|
|
-{%- endif -%}
|
|
|
-
|
|
|
-{{ OutDirs(run, ' outputs.dir("', '")') }}
|
|
|
-{#
|
|
|
- Не использованы аттрибуты
|
|
|
- run-cwd="str"
|
|
|
- run-in_dirs_inputs="list"
|
|
|
- run-in_noparse="list"
|
|
|
- run-tool="list"
|
|
|
--#}
|
|
|
-}
|
|
|
-
|
|
|
-tasks.getByName("sourcesJar").dependsOn(runJav{{ loop.index }})
|
|
|
-
|
|
|
-tasks.compileJava.configure {
|
|
|
- dependsOn(runJav{{ loop.index }})
|
|
|
-}
|
|
|
-{% endfor -%}
|
|
|
-{% endif -%}
|
|
|
+{%- include "[generator]/run_java_program.jinja" -%}
|
|
|
|
|
|
{% include "extra-tests.gradle.kts" ignore missing %}
|
|
|
{% if publish -%}
|