aboutsummaryrefslogtreecommitdiffstats
path: root/build/export_generators/ide-gradle/build.gradle.kts.jinja
blob: dd57a390f14a22911c62069ed2e93189aeb0313d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
plugins {
{% if targets|selectattr("app_main_class") -%}
    `application`
{% else -%}
    `java-library`
{% endif -%}
{% if targets|selectattr('publish') -%}
    `maven-publish`
    `signing`
{% endif -%}
    kotlin("jvm") version "1.8.22"
    kotlin("plugin.allopen") version "1.8.22"
}

allOpen {
    annotation("org.springframework.stereotype.Component")
}

kotlin {
    jvmToolchain(17)
}

{% if targets|selectattr('publish') -%}
group = "{{ targets[0].publish_group }}"
version = project.properties["version"]

{% endif -%}
repositories {
    mavenCentral()
}

configurations {
    all {
        exclude(group = "ch.qos.logback", module = "logback-classic")
        exclude(group = "org.apache.logging.log4j", module = "log4j-to-slf4j")
    }
}

{% if targets|selectattr("app_main_class") -%}
application {
{% for target in targets|selectattr("app_main_class") -%}
    mainClass.set("{{ target.app_main_class }}")
{% endfor -%}
}

{% endif -%}
java {
    withSourcesJar()
    withJavadocJar()
}

{% if target.jar_source_set is defined -%}
{%     for source_set in target.jar_source_set -%}
{%-        set srcdir, glob = source_set.split(':') -%}
sourceSets.main.java.srcDirs += '{{ srcdir }}'
{%     endfor -%}
{% endif -%}

dependencies {
{% for target in targets -%}
{%     if target.junit5_test -%}
    testImplementation("org.junit.jupiter:junit-jupiter:5.8.2")

    api("org.apache.commons:commons-math3:3.6.1")

    api("com.google.guava:guava:31.0.1-jre")
{%     endif -%}
{%     for library in target.consumer -%}
{%         set classpath = library.classpath -%}
{%         if targets|selectattr("app_main_class") -%}
{%             if library.excludes.consumer is defined %}
    implementation({{ classpath }}) {
{%                 for exclude in library.excludes.consumer -%}
{%                     set classpath_parts = exclude.classpath.split(':') -%}
        exclude group: '{{ classpath_parts[0] }}', module: '{{ classpath_parts[1] }}'
{%                 endfor -%}
    }
{%             else -%}
    implementation({{ classpath }})
{%             endif -%}
{%         elif target.isTest -%}
    testImplementation({{ classpath }})
{%         else -%}
    api({{ classpath }})
{%         endif -%}
{%     endfor -%}
{% endfor -%}
}

{% if targets|selectattr("junit5_test") -%}
tasks.named<Test>("test") {
    useJUnitPlatform()
}

{% endif -%}
tasks.test {
    testLogging {
        showStandardStreams = true
        events("passed", "skipped", "failed")
    }
}

{% 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 -%}

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("testOutput").name, testsJar)

{% include "extra-tests.gradle.kts" ignore missing %}
{% if targets|selectattr('publish') -%}
{% include 'publish.gradle.kts' -%}
{% endif -%}