aboutsummaryrefslogtreecommitdiffstats
path: root/build/export_generators/ide-gradle/build.gradle.kts.jinja
blob: a64bf204214e1d6980fc68ef55ef3829a8f13a27 (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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
{%- 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 %}


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

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

{%- 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.test2test %}
    testImplementation(project(path = ":{{ library.test2test | 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 -%}

{{ dump }}