forked from WorksApplications/elasticsearch-sudachi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
155 lines (135 loc) · 4.76 KB
/
build.gradle
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
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
plugins {
id 'java-library'
id 'org.jetbrains.kotlin.jvm' version '1.8.0'
id "org.jetbrains.kotlin.plugin.serialization" version "1.8.0"
id 'com.diffplug.spotless' version '6.16.0'
id 'org.sonarqube' version '4.0.0.2929'
id("org.jetbrains.kotlinx.kover") version "0.7.0"
id 'com.worksap.nlp.sudachi.esc'
id 'com.worksap.nlp.sudachi.es'
id 'io.github.gradle-nexus.publish-plugin' version "1.3.0"
}
group = 'com.worksap.nlp'
archivesBaseName = 'analysis-sudachi'
version = properties["pluginVersion"]
compileKotlin {
compilerOptions.jvmTarget.set(JvmTarget.JVM_11)
}
compileTestKotlin {
compilerOptions.jvmTarget.set(JvmTarget.JVM_11)
}
configurations {
spi
}
sourceSets {
test {
compileClasspath += configurations.spi
runtimeClasspath += configurations.spi
}
main {
compileClasspath += configurations.spi
}
}
dependencies {
spi(project(':spi'))
testImplementation(project(':testlib'))
testImplementation('org.apache.logging.log4j:log4j-core:2.17.2')
testImplementation('org.jetbrains.kotlin:kotlin-test-junit') {
exclude(group: 'org.hamcrest')
}
testImplementation('org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3')
kover(project(':integration'))
kover(project(':testlib'))
}
def embedVersion = tasks.register('embedVersion', Copy) {
var esKind = sudachiEs.kind.get()
from 'src/main/extras/plugin-descriptor.properties'
into "build/package/${version}/${esKind.engine.kind}-${esKind.version}"
expand([
version: version,
engineVersion: esKind.version,
engineKind: esKind.engine.kind
])
inputs.property("version", version)
inputs.property("elasticSearchVersion", esKind.version)
}
def packageJars = tasks.register('packageJars', Copy) {
from configurations.runtimeClasspath
from tasks.jar.outputs
var esKind = sudachiEs.kind.get()
into "build/package/${version}/${esKind.engine.kind}-${esKind.version}"
dependsOn tasks.jar
}
def packageSpiJars = tasks.register('packageSpiJars', Copy) {
from configurations.spi
var esKind = sudachiEs.kind.get()
if (sudachiEs.hasPluginSpiSupport()) {
into "build/package/${version}/${esKind.engine.kind}-${esKind.version}/spi"
} else {
into "build/package/${version}/${esKind.engine.kind}-${esKind.version}"
}
}
def distZip = tasks.register('distZip', Zip) {
var esKind = sudachiEs.kind.get()
dependsOn embedVersion, packageJars, packageSpiJars
archiveBaseName.set("${esKind.engine.kind}-${esKind.version}-$archivesBaseName")
from("build/package/${version}/${esKind.engine.kind}-${esKind.version}", 'LICENSE', 'README.md')
}
artifacts {
archives distZip
}
koverReport {
defaults {
xml {
setReportFile(layout.buildDirectory.file("reports/jacoco/test/jacocoTestReport.xml"))
}
}
}
// See https://github.com/diffplug/spotless/tree/main/plugin-gradle
spotless {
// watch for https://github.com/diffplug/spotless/issues/911 to be closed
ratchetFrom 'origin/develop'
encoding 'UTF-8' // all formats will be interpreted as UTF-8
format 'misc', {
target '*.gradle', '*.md', '.gitignore', '*.txt', '*.csv'
trimTrailingWhitespace()
indentWithSpaces(2)
endWithNewline()
}
java {
// don't need to set target, it is inferred from java
// version list: https://github.com/diffplug/spotless/tree/main/lib-extra/src/main/resources/com/diffplug/spotless/extra/eclipse_jdt_formatter
eclipse('4.21.0').configFile('.formatter/eclipse-formatter.xml')
licenseHeaderFile('.formatter/license-header')
}
kotlin {
// by default the target is every '.kt' and '.kts` file in the java sourcesets
ktfmt('0.39')
licenseHeaderFile('.formatter/license-header')
}
}
sonarqube {
properties {
property "sonar.projectKey", "WorksApplications_elasticsearch-sudachi"
property "sonar.organization", "worksapplications"
property "sonar.host.url", "https://sonarcloud.io"
}
}
tasks.register("printVersionForGithubActions") {
doLast {
// https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#environment-files
var esKind = sudachiEs.kind.get()
file(System.getenv("GITHUB_ENV")).write(
"PROJ_VERSION=${project.version}\nENGINE_VERSION=${esKind.version}\nENGINE_KIND=${esKind.engine.kind}"
)
}
}
nexusPublishing {
repositories {
sonatype {
username = project.findProperty("maven.user") ?: System.getenv("MAVEN_USERNAME")
password = project.findProperty("maven.password") ?: System.getenv("MAVEN_USER_PASSWORD")
}
}
}