{%- 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 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 { 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 { jvmArgs?.add("--enable-preview") } tasks.withType { jvmArgs?.add("--enable-preview") environment["JAVA_TOOL_OPTIONS"] = "--enable-preview" } tasks.withType { 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") { useJUnitPlatform() } {% endif -%} {% set runs = targets|selectattr("runs") -%} {% if runs -%} {% for run in runs -%} tasks.build.dependsOn( task("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 -%} {{ dump }}