123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276 |
- {%- set mainClass = target.app_main_class -%}
- {%- set publish = target.publish -%}
- {%- set with_kotlin = target.with_kotlin -%}
- {%- set kotlin_version = target.kotlin_version -%}
- {%- set hasJunit5Test = extra_targets|selectattr('junit5_test') -%}
- plugins {
- {%- if "lombok.launch.AnnotationProcessorHider$AnnotationProcessor" in target.annotation_processors %}
- id("io.freefair.lombok") version "8.6"
- {%- endif -%}
- {%- 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 %}
- kotlin("plugin.allopen") version "{{ kotlin_version }}"
- {% endif -%}
- {%- if target.with_kotlinc_plugin_lombok %}
- kotlin("plugin.lombok") version "{{ kotlin_version }}"
- {% endif -%}
- {%- if target.with_kotlinc_plugin_noarg %}
- kotlin("plugin.noarg") version "{{ kotlin_version }}"
- {% endif -%}
- {%- if target.with_kotlinc_plugin_serialization %}
- kotlin("plugin.serialization") version "{{ kotlin_version }}"
- {% endif -%}
- {%- endif %}
- }
- {%- if target.with_kotlinc_plugin_allopen %}
- allOpen {
- annotation("org.springframework.stereotype.Component")
- }
- {% endif -%}
- {%- if with_kotlin %}
- kotlin {
- jvmToolchain({%- if target.required_jdk -%}{{ target.required_jdk }}{%- else -%}17{%- endif -%})
- }
- {% 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({%- if target.required_jdk -%}{{ target.required_jdk }}{%- else -%}17{%- endif -%})
- }
- 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", "{%- if target.required_jdk -%}{{ target.required_jdk }}{%- else -%}17{%- endif -%}")
- javadocOptions.addBooleanOption("-enable-preview", true)
- }
- {% 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"
- }
- }
- }
- }
- val project_root="{%- if exportRoot.startswith(arcadiaRoot + '/') -%}{{ arcadiaRoot }}{%- else -%}{{ exportRoot }}{%- endif -%}"
- {% if mainClass -%}
- application {
- mainClass.set("{{ mainClass }}")
- }
- {% endif -%}
- java {
- withSourcesJar()
- withJavadocJar()
- }
- configurations.api {
- isTransitive = false
- }
- configurations.implementation {
- isTransitive = false
- }
- configurations.testImplementation {
- isTransitive = false
- }
- {% if hasTest -%}
- val testsJar by tasks.registering(Jar::class) {
- dependsOn(JavaPlugin.COMPILE_TEST_JAVA_TASK_NAME)
- archiveClassifier.set("tests")
- from(sourceSets["test"].output)
- }
- artifacts.add(configurations.create("testArtifacts").name, testsJar)
- tasks.test {
- testLogging {
- showStandardStreams = true
- events("passed", "skipped", "failed")
- }
- }
- {% 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 {
- val test by getting {
- 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")
- }
- }
- dependencies {
- {%- for library in target.consumer if library.classpath -%}
- {%- if library.prebuilt and library.jar and (library.type != "contrib" or build_contribs) %}
- implementation(files("$project_root/{{ library.jar }}"))
- {%- else -%}
- {%- if library.type != "contrib" %}
- {%- if library.testdep %}
- implementation(project(path = ":{{ library.testdep | replace("/", ":") }}", configuration = "testArtifacts"))
- {%- else %}
- implementation({{ library.classpath }})
- {%- endif -%}
- {%- else %}
- api({{ library.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 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 -%}
- {%- if library.type != "contrib" and library.testdep %}
- testImplementation(project(path = ":{{ library.testdep | replace("/", ":") }}", configuration = "testArtifacts"))
- {%- else %}
- testImplementation({{ library.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 -%}
- {%- endfor %}
- }
- {% if hasJunit5Test -%}
- tasks.named<Test>("test") {
- useJUnitPlatform()
- }
- {% endif -%}
- {% set runs = targets|selectattr("runs") -%}
- {% if runs -%}
- {% for run in runs -%}
- tasks.build.dependsOn(
- task<JavaExec>("runJavaProgram") {
- group = "build"
- description = "Code generation by rub java program"
- mainClass.set(mainClass)
- {% if run.classpath -%}
- classpath = "{{ run.classpath }}"
- {% else -%}
- classpath = sourceSets.main.get().runtimeClasspath
- {% endif -%}
- {% if run.args -%}
- {# for arg in run.args #}
- args = "{{ run.args }}"
- {% endif -%}
- {% if run.in_dir -%}
- {% for dir in run.in_dir -%}
- inputs.files(fileTree("{{ dir }}"))
- {% endfor -%}
- {% endif -%}
- {% if run.in -%}
- {% for file in run.in -%}
- inputs.files("{{ file }}")
- {% endfor -%}
- {% endif -%}
- {% if run.out_dir -%}
- {% for dir in run.out_dir -%}
- outputs.dir("{{ dir }}")
- {% endfor -%}
- {#
- Не использованы аттрибуты
- run-cwd="str"
- run-in_dirs_inputs="list"
- run-in_noparse="list"
- run-out_dir="list"
- run-tool="list"
- #}
- {% endif -%}
- }
- )
- {% endfor -%}
- {% endif -%}
- {% include "extra-tests.gradle.kts" ignore missing %}
- {% if publish -%}
- {% include 'publish.gradle.kts' ignore missing -%}
- {% endif -%}
- {# To disable redundant javadoc (it may fail the build) #}
- tasks.withType<Javadoc>().configureEach {
- isEnabled = false
- }
- {%- include "[generator]/debug.jinja" ignore missing -%}
|