mirror of
https://github.com/google/nomulus.git
synced 2025-08-16 06:24:07 +02:00
Clean up the Gradle JS distribution a bit
There's no reason not to always create the source mapping but we shouldn't distribute it in production. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=233984970
This commit is contained in:
parent
4241c7658f
commit
063197fd69
2 changed files with 33 additions and 23 deletions
|
@ -262,12 +262,10 @@ subprojects {
|
||||||
if (project.path == ":services:default") {
|
if (project.path == ":services:default") {
|
||||||
war {
|
war {
|
||||||
from("${coreResourcesDir}/google/registry/ui") {
|
from("${coreResourcesDir}/google/registry/ui") {
|
||||||
include "registrar_bin*"
|
include "registrar_bin.js"
|
||||||
into("assets/js")
|
if (environment != "production") {
|
||||||
rename { String filename -> filename.replace("bin", "dbg") }
|
include "registrar_bin.js.map"
|
||||||
}
|
}
|
||||||
from("${coreResourcesDir}/google/registry/ui") {
|
|
||||||
include "registrar_bin*"
|
|
||||||
into("assets/js")
|
into("assets/js")
|
||||||
}
|
}
|
||||||
from("${coreResourcesDir}/google/registry/ui/css") {
|
from("${coreResourcesDir}/google/registry/ui/css") {
|
||||||
|
|
|
@ -363,7 +363,6 @@ task soyToJava {
|
||||||
}
|
}
|
||||||
|
|
||||||
doLast {
|
doLast {
|
||||||
|
|
||||||
soyToJava('google.registry.tools.soy',
|
soyToJava('google.registry.tools.soy',
|
||||||
"${generatedDir}/${toolsSoyDir}",
|
"${generatedDir}/${toolsSoyDir}",
|
||||||
fileTree(
|
fileTree(
|
||||||
|
@ -393,6 +392,11 @@ task soyToJava {
|
||||||
}
|
}
|
||||||
|
|
||||||
task soyToJS {
|
task soyToJS {
|
||||||
|
def rootSoyDirectory = "${javaDir}/google/registry/ui/soy"
|
||||||
|
def outputSoyDirectory = "${generatedDir}/google/registry/ui/soy"
|
||||||
|
inputs.dir rootSoyDirectory
|
||||||
|
outputs.dir outputSoyDirectory
|
||||||
|
|
||||||
ext.soyToJS = { outputDirectory, soyFiles , deps->
|
ext.soyToJS = { outputDirectory, soyFiles , deps->
|
||||||
javaexec {
|
javaexec {
|
||||||
main = "com.google.template.soy.SoyToJsSrcCompiler"
|
main = "com.google.template.soy.SoyToJsSrcCompiler"
|
||||||
|
@ -410,13 +414,13 @@ task soyToJS {
|
||||||
doLast {
|
doLast {
|
||||||
def rootSoyFiles =
|
def rootSoyFiles =
|
||||||
fileTree(
|
fileTree(
|
||||||
dir: "${javaDir}/google/registry/ui/soy",
|
dir: "${rootSoyDirectory}",
|
||||||
include: ['*.soy'])
|
include: ['*.soy'])
|
||||||
|
|
||||||
soyToJS("${generatedDir}/google/registry/ui/soy", rootSoyFiles, "")
|
soyToJS("${outputSoyDirectory}", rootSoyFiles, "")
|
||||||
soyToJS("${generatedDir}/google/registry/ui/soy/registrar",
|
soyToJS("${outputSoyDirectory}/registrar",
|
||||||
files {
|
files {
|
||||||
file("${javaDir}/google/registry/ui/soy/registrar").listFiles()
|
file("${rootSoyDirectory}/registrar").listFiles()
|
||||||
}.filter {
|
}.filter {
|
||||||
it.name.endsWith(".soy")
|
it.name.endsWith(".soy")
|
||||||
}.filter{
|
}.filter{
|
||||||
|
@ -477,17 +481,25 @@ task stylesheetsToJavascript {
|
||||||
}
|
}
|
||||||
|
|
||||||
task compileProdJS(type: JavaExec) {
|
task compileProdJS(type: JavaExec) {
|
||||||
// TODO(b/123647609) clean this up in general
|
def outputDir = "${resourcesDir}/google/registry/ui"
|
||||||
// - have two separate tasks for dev/prod
|
def nodeModulesDir = "${rootDir}/node_modules"
|
||||||
// - the prod task uses the ADVANCED_OPTIMIZATION flag.
|
def cssSourceDir = "${resourcesDir}/google/registry/ui/css"
|
||||||
// - have this be a configurable task so we can change the inputs/outputs
|
def jsSourceDir = "${javaDir}/google/registry/ui/js"
|
||||||
|
def externsDir = "${javaDir}/google/registry/ui/externs"
|
||||||
|
def soySourceDir = "${generatedDir}/google/registry/ui/soy"
|
||||||
|
|
||||||
|
[nodeModulesDir, cssSourceDir, jsSourceDir, externsDir, soySourceDir].each {
|
||||||
|
inputs.dir "${it}"
|
||||||
|
}
|
||||||
|
outputs.dir outputDir
|
||||||
|
|
||||||
classpath configurations.closureCompiler
|
classpath configurations.closureCompiler
|
||||||
main = 'com.google.javascript.jscomp.CommandLineRunner'
|
main = 'com.google.javascript.jscomp.CommandLineRunner'
|
||||||
|
|
||||||
def closureArgs = []
|
def closureArgs = []
|
||||||
closureArgs << "--js_output_file=${resourcesDir}/google/registry/ui/registrar_bin.js"
|
closureArgs << "--js_output_file=${outputDir}/registrar_bin.js"
|
||||||
// sourcemap-related configuration
|
// sourcemap-related configuration
|
||||||
closureArgs << "--create_source_map=${resourcesDir}/google/registry/ui/registrar_bin.js.map"
|
closureArgs << "--create_source_map=${outputDir}/registrar_bin.js.map"
|
||||||
closureArgs << "--source_map_include_content=true"
|
closureArgs << "--source_map_include_content=true"
|
||||||
closureArgs << "--source_map_location_mapping=${rootDir}/|"
|
closureArgs << "--source_map_location_mapping=${rootDir}/|"
|
||||||
closureArgs << "--output_wrapper=\"%output% //# sourceMappingURL=registrar_bin.js.map\""
|
closureArgs << "--output_wrapper=\"%output% //# sourceMappingURL=registrar_bin.js.map\""
|
||||||
|
@ -498,13 +510,13 @@ task compileProdJS(type: JavaExec) {
|
||||||
closureArgs << "--generate_exports"
|
closureArgs << "--generate_exports"
|
||||||
|
|
||||||
// manually include all the required js files
|
// manually include all the required js files
|
||||||
closureArgs << "--js=${rootDir}/node_modules/google-closure-library/**.js"
|
closureArgs << "--js=${nodeModulesDir}/google-closure-library/**.js"
|
||||||
closureArgs << "--js=${rootDir}/node_modules/soyutils_usegoog.js"
|
closureArgs << "--js=${nodeModulesDir}/soyutils_usegoog.js"
|
||||||
closureArgs << "--js=${resourcesDir}/google/registry/ui/css/registrar_bin.css.js"
|
closureArgs << "--js=${cssSourceDir}/registrar_bin.css.js"
|
||||||
closureArgs << "--js=${javaDir}/google/registry/ui/js/**.js"
|
closureArgs << "--js=${jsSourceDir}/**.js"
|
||||||
// TODO(shicong) Verify the compiled JS file works in Alpha
|
// TODO(shicong) Verify the compiled JS file works in Alpha
|
||||||
closureArgs << "--js=${javaDir}/google/registry/ui/externs/json.js"
|
closureArgs << "--js=${externsDir}/json.js"
|
||||||
closureArgs << "--js=${generatedDir}/google/registry/ui/soy/**.js"
|
closureArgs << "--js=${soySourceDir}/**.js"
|
||||||
args closureArgs
|
args closureArgs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue