Debian Codegraph @

lucene/luke/build.gradle

raw
1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17 import org.apache.tools.ant.filters.*
18
19 apply plugin: 'java-library'
20
21 description = 'Luke - Lucene Toolbox'
22
23 ext {
24 standaloneDistDir = file("$buildDir/${archivesBaseName}-${project.version}")
25 }
26
27 dependencies {
28 moduleApi project(':lucene:core')
29
30 moduleImplementation project(':lucene:codecs')
31 moduleImplementation project(':lucene:backward-codecs')
32 moduleImplementation project(':lucene:analysis:common')
33 moduleImplementation project(':lucene:queries')
34 moduleImplementation project(':lucene:queryparser')
35 moduleImplementation project(':lucene:misc')
36
37 moduleImplementation project(":lucene:highlighter")
38 moduleImplementation project(':lucene:analysis:icu')
39 moduleImplementation project(':lucene:analysis:kuromoji')
40 moduleImplementation project(':lucene:analysis:morfologik')
41 moduleImplementation project(':lucene:analysis:nori')
42 moduleImplementation project(':lucene:analysis:opennlp')
43 moduleImplementation project(':lucene:analysis:phonetic')
44 moduleImplementation project(':lucene:analysis:smartcn')
45 moduleImplementation project(':lucene:analysis:stempel')
46 moduleImplementation project(':lucene:suggest')
47
48 moduleTestImplementation project(':lucene:test-framework')
49 }
50
51 // Configure main class name for all JARs.
52 tasks.withType(Jar) {
53 manifest {
54 attributes("Main-Class": "org.apache.lucene.luke.app.desktop.LukeMain")
55 }
56 }
57
58 // Configure the main class and version attribute for the module system.
59 tasks.compileJava.configure {
60 options.javaModuleMainClass.set("org.apache.lucene.luke.app.desktop.LukeMain")
61 }
62
63 // Process UTF8 property files to unicode escapes.
64 tasks.withType(ProcessResources).configureEach { task ->
65 task.filesMatching("**/messages*.properties", {
66 filteringCharset = 'UTF-8'
67 filter(EscapeUnicode)
68 })
69 }
70
71 // Configure "stand-alone" JAR with proper dependency classpath links.
72 task standaloneJar(type: Jar) {
73 dependsOn classes
74
75 archiveFileName = "${archivesBaseName}-${project.version}-standalone.jar"
76
77 from(sourceSets.main.output)
78
79 // manifest attributes are resolved eagerly and we can't access runtimeClasspath
80 // at configuration time so push it until execution.
81 doFirst {
82 manifest {
83 attributes("Class-Path": configurations.runtimeClasspath.collect {
84 "${it.getName()}"
85 }.join(' '))
86 }
87 }
88 }
89
90 task standaloneAssemble(type: Sync) {
91 def antHelper = new org.apache.tools.ant.Project()
92 afterEvaluate {
93 def substituteProperties = [
94 "required.java.version": project.java.targetCompatibility,
95 "luke.cmd": "${standaloneJar.archiveFileName.get()}"
96 ]
97 substituteProperties.each { k, v -> antHelper.setProperty(k.toString(), v.toString()) }
98 }
99
100 from standaloneJar
101 from configurations.runtimeClasspath
102
103 from(file("src/distribution"), {
104 filesMatching("README.md", {
105 filteringCharset = 'UTF-8'
106 filter(ExpandProperties, project: antHelper)
107 })
108 })
109
110 into standaloneDistDir
111
112 doLast {
113 logger.lifecycle(
114 """
115 Standalone Luke distribution assembled. You can run it with:
116 java -jar "${standaloneDistDir}/${standaloneJar.archiveFileName.get()}"
117 java --module-path "${standaloneDistDir}" -m org.apache.lucene.luke
118 """
119 )
120 }
121 }
122
123 // Attach standalone distribution assembly to main assembly.
124 assemble.dependsOn standaloneAssemble
125
126 // Create a standalone package bundle.
127 task standalonePackage(type: Tar) {
128 from standaloneAssemble
129
130 into "${archivesBaseName}-${project.version}/"
131
132 compression = Compression.GZIP
133 archiveFileName = "${archivesBaseName}-${project.version}-standalone.tgz"
134 }
135
136 // Utility to launch Luke (and fork it from the build).
137 task run() {
138 dependsOn standaloneAssemble
139 description "Launches (spawns) Luke directly from the build process."
140 group "Utility launchers"
141
142 doFirst {
143 logger.lifecycle("Launching Luke ${project.version} right now...")
144 ant.exec(
145 executable: rootProject.ext.runtimeJavaExecutable,
146 spawn: true,
147 vmlauncher: true
148 ) {
149 arg(value: '-jar')
150 arg(value: file("${standaloneDistDir}/${standaloneJar.archiveFileName.get()}").absolutePath)
151 }
152 }
153 }
154