blob: f2b830f544f63e74b79ad888f24942655020f58e [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
plugins {
id 'java'
id 'war'
}
description = 'Solr webapp'
configurations {
war {}
serverLib
solrCore
generatedJSClient
generatedJSClientBundle
}
ext {
jsClientWorkspace = layout.buildDirectory.dir("jsClientWorkspace").get()
jsClientBuildDir = layout.buildDirectory.dir("jsClientBuild").get()
jsClientBundleDir = layout.buildDirectory.dir("jsClientBundle").get()
browserifyVersion = "17.0.0"
}
dependencies {
permitUnusedDeclared project(":solr:core")
serverLib project(path: ":solr:server", configuration: "libExt")
serverLib project(path: ":solr:server", configuration: "serverLib")
solrCore project(":solr:core")
implementation(configurations.solrCore - configurations.serverLib)
generatedJSClient project(path: ":solr:api", configuration: "jsClient")
generatedJSClientBundle files(jsClientBundleDir) {
builtBy "finalizeJsBundleDir"
}
}
task syncJSClientSourceCode(type: Sync) {
group = 'Solr JS Client'
from configurations.generatedJSClient
into jsClientWorkspace
// Keep the node modules, so that they don't need to be re-downloaded
preserve {
include "node_modules/**"
}
}
task jsClientDownloadDeps(type: NpmTask) {
group = 'Solr JS Client'
dependsOn tasks.syncJSClientSourceCode
args = ["install"]
workingDir = file(jsClientWorkspace)
inputs.dir("${jsClientWorkspace}/src")
inputs.file("${jsClientWorkspace}/package.json")
outputs.dir("${jsClientWorkspace}/node_modules")
}
task jsClientBuild(type: NpmTask) {
group = 'Solr JS Client'
dependsOn tasks.jsClientDownloadDeps
args = ["run", "build"]
workingDir = file(jsClientWorkspace)
inputs.dir("${jsClientWorkspace}/src")
inputs.file("${jsClientWorkspace}/package.json")
inputs.dir("${jsClientWorkspace}/node_modules")
outputs.dir("${jsClientWorkspace}/dist")
}
task downloadBrowserify(type: NpmTask) {
group = 'Build Dependency Download'
args = ["install", "browserify@${browserifyVersion}"]
inputs.property("browserify version", browserifyVersion)
outputs.dir("${nodeProjectDir}/node_modules/browserify")
}
task generateJsClientBundle(type: NpxTask) {
group = 'Solr JS Client'
dependsOn tasks.downloadBrowserify
dependsOn tasks.jsClientBuild
command = 'browserify'
args = ['dist/index.js', '-s', 'solrApi', '-o', "${jsClientBuildDir}/index.js"]
workingDir = file(jsClientWorkspace)
inputs.dir(jsClientWorkspace)
inputs.property("browserify version", browserifyVersion)
outputs.file("${jsClientBuildDir}/index.js")
}
task finalizeJsBundleDir(type: Sync) {
group = 'Solr JS Client'
from configurations.generatedJSClient {
include "README.md"
include "docs/**"
}
from tasks.generateJsClientBundle {
include "index.js"
}
into jsClientBundleDir
}
war {
// Why are they in the source code at all if they're excluded from the distribution?
exclude "libs/angular-cookies.js"
exclude "libs/angular-route.js"
exclude "libs/angular-sanitize.js"
exclude "libs/angular-utf8-base.js"
exclude "libs/angular.js"
exclude "libs/chosen.jquery.js"
from (configurations.generatedJSClientBundle, {
into "libs/solr"
})
}
// Expose 'war' archive as an artifact so that it can be packaged in the distribution.
artifacts {
war tasks.war
}