123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- {%- set mainClassTargets = targets|selectattr("app_main_class") -%}
- {%- set publish = targets|selectattr('publish') -%}
- {%- set hasJunit5Test = targets|selectattr('junit5_test') -%}
- {%- set target0 = targets[0] -%}
- {%- set with_kotlin = target0.with_kotlin -%}
- {%- set kotlin_version = target0.kotlin_version -%}
- plugins {
- {%- if mainClassTargets %}
- `application`
- {%- else %}
- `java-library`
- {%- endif %}
- {%- if publish %}
- `maven-publish`
- `signing`
- {%- endif -%}
- {%- if with_kotlin and kotlin_version %}
- kotlin("jvm") version "{{ kotlin_version }}"
- {%- if target0.with_kotlinc_plugin_allopen %}
- kotlin("plugin.allopen") version "{{ kotlin_version }}"
- {% endif -%}
- {%- if target0.with_kotlinc_plugin_lombok %}
- kotlin("plugin.lombok") version "{{ kotlin_version }}"
- {% endif -%}
- {%- if target0.with_kotlinc_plugin_noarg %}
- kotlin("plugin.noarg") version "{{ kotlin_version }}"
- {% endif -%}
- {%- if target0.with_kotlinc_plugin_serialization %}
- kotlin("plugin.serialization") version "{{ kotlin_version }}"
- {% endif -%}
- {%- endif %}
- }
- {%- if target0.with_kotlinc_plugin_allopen %}
- allOpen {
- annotation("org.springframework.stereotype.Component")
- }
- {% endif -%}
- {%- if with_kotlin %}
- kotlin {
- jvmToolchain({%- if target0.required_jdk -%}{{ target0.required_jdk }}{%- else -%}17{%- endif -%})
- }
- {% endif -%}
- {%- if publish %}
- group = "{{ target0.publish_group }}"
- version = {% if target0.publish_version and target0.publish_version != "no" -%}"{{ target0.publish_version }}"{%- else -%}project.properties["version"]{%- endif %}
- {% endif %}
- repositories {
- mavenCentral()
- }
- val project_root="{%- if exportRoot.startswith(arcadiaRoot + '/') -%}{{ arcadiaRoot }}{%- else -%}{{ exportRoot }}{%- endif -%}"
- {% if mainClassTargets -%}
- application {
- {%- for target in mainClassTargets %}
- mainClass.set("{{ target.app_main_class }}")
- {% endfor -%}
- }
- {% 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 -%}
- {% for target in targets -%}
- {%- 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 -%}
- {%- endfor -%}
- dependencies {
- {%- for target in targets -%}
- {%- for library in target.consumer if library.classpath -%}
- {%- if library.prebuilt and library.jar and (library.type != "contrib" or build_contribs) -%}
- {%- if target.isTest %}
- testImplementation
- {%- else %}
- implementation
- {%- endif -%}(files("$project_root/{{ library.jar }}"))
- {%- else -%}
- {%- if target.isTest %}
- {%- if library.type != "contrib" and library.test2test %}
- testImplementation(project(path = ":{{ library.test2test | replace("/", ":") }}", configuration = "testArtifacts"))
- {%- else %}
- testImplementation({{ library.classpath }})
- {%- endif %}
- {%- elif library.type != "contrib" %}
- implementation({{ library.classpath }})
- {%- 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 -%}
- {%- 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 -%}
- {{ dump }}
|