From 6430c811e2edd5ea44e91f2d3cbb38f910393d06 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Mon, 21 Dec 2020 16:19:56 +0100 Subject: [PATCH] Add scm-ui assets to scm-webapp war file --- scm-ui/build.gradle | 81 +++++++++++++++++++++++-- scm-ui/ui-scripts/src/webpack.config.js | 6 +- scm-webapp/build.gradle | 6 ++ 3 files changed, 84 insertions(+), 9 deletions(-) diff --git a/scm-ui/build.gradle b/scm-ui/build.gradle index b2c5b8ad54..9cb4606071 100644 --- a/scm-ui/build.gradle +++ b/scm-ui/build.gradle @@ -4,7 +4,7 @@ * Copyright (c) 2020-present Cloudogu GmbH and Contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal + * of this software and associated documentation files (the 'Software'), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is @@ -13,7 +13,7 @@ * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER @@ -30,31 +30,100 @@ node { download = true version = '14.15.1' yarnVersion = '1.22.5' - nodeModulesDir = file("${project.rootProject.projectDir}") + nodeModulesDir = file('${project.rootProject.projectDir}') } // TODO define inputs and outputs task typecheck(type: YarnTask) { args = ['run', 'typecheck'] + inputs.files(fileTree(project.projectDir) { + include 'ui-*/src/**' + include 'ui-*/**/*.js' + include 'ui-*/**/*.jsx' + include 'ui-*/**/*.ts' + include 'ui-*/**/*.tsx' + }) + .withPathSensitivity(PathSensitivity.RELATIVE) + outputs.file("build/tmp/typecheck/marker") dependsOn('yarn_install') + doLast { + File directory = new File(project.buildDir, 'tmp/typecheck') + directory.mkdirs() + File marker = new File(directory, "marker") + marker.createNewFile() + } } task test(type: YarnTask) { args = ['run', 'test'] + inputs.files(fileTree(project.projectDir) { + include 'ui-*/src/**' + include 'ui-*/**/*.js' + include 'ui-*/**/*.jsx' + include 'ui-*/**/*.ts' + include 'ui-*/**/*.tsx' + }) + .withPathSensitivity(PathSensitivity.RELATIVE) + outputs.dir('build/jest-reports') dependsOn('yarn_install') } - -task check(type: YarnTask) { +task check { dependsOn('typecheck', 'test') } -task build(type: YarnTask) { +yarn_install { + inputs.files(fileTree(project.projectDir) { + include 'ui-*/package.json' + }) + .withPathSensitivity(PathSensitivity.RELATIVE) + + inputs.file(new File(project.rootProject.projectDir, 'package.json')) + inputs.file(new File(project.rootProject.projectDir, 'yarn.lock')) + + outputs.dir(new File(project.rootProject.projectDir, 'node_modules')) +} + +task build { + dependsOn 'check', 'bundle' +} + +task bundle(type: YarnTask) { args = ['run', 'build'] + inputs.files(fileTree(project.projectDir) { + include 'ui-*/src/**' + include 'ui-*/**/*.js' + include 'ui-*/**/*.jsx' + include 'ui-*/**/*.ts' + include 'ui-*/**/*.tsx' + include 'ui-*/**/*.css' + include 'ui-*/**/*.sass' + include 'ui-*/**/*.scss' + + exclude '**/*.test.ts' + exclude '**/*.test.tsx' + }) + .withPathSensitivity(PathSensitivity.RELATIVE) + outputs.dir('build/assets') dependsOn('yarn_install') } +configurations { + assets { + canBeConsumed = true + canBeResolved = true + } +} + +artifacts { + assets(project.layout.buildDirectory) { + builtBy(build) + } +} + +// TODO + task deploy(type: YarnTask) { args = ['run', 'deploy', project.version] dependsOn('yarn_install') diff --git a/scm-ui/ui-scripts/src/webpack.config.js b/scm-ui/ui-scripts/src/webpack.config.js index bc20d91718..1e1e5cd292 100644 --- a/scm-ui/ui-scripts/src/webpack.config.js +++ b/scm-ui/ui-scripts/src/webpack.config.js @@ -114,7 +114,7 @@ module.exports = [ extensions: [".ts", ".tsx", ".js", ".jsx", ".css", ".scss", ".json"] }, output: { - path: path.join(root, "target", "assets"), + path: path.join(root, "build", "assets"), filename: "[name].bundle.js", chunkFilename: "[name].bundle.js" }, @@ -190,7 +190,7 @@ module.exports = [ minimizer: [new OptimizeCSSAssetsPlugin({})] }, output: { - path: path.join(root, "target", "assets"), + path: path.join(root, "build", "assets"), filename: "ui-styles.bundle.js" } }, @@ -200,7 +200,7 @@ module.exports = [ polyfills: "./ui-polyfill/src/index.js" }, output: { - path: path.resolve(root, "target", "assets"), + path: path.resolve(root, "build", "assets"), filename: "[name].bundle.js" } } diff --git a/scm-webapp/build.gradle b/scm-webapp/build.gradle index 203f1c549b..f20ebfb36b 100644 --- a/scm-webapp/build.gradle +++ b/scm-webapp/build.gradle @@ -28,12 +28,17 @@ plugins { id 'io.swagger.core.v3.swagger-gradle-plugin' version '2.1.6' } +configurations { + assets +} + dependencies { implementation platform(project(':')) corePlugin project(path: ':scm-plugins:scm-git-plugin', configuration: 'smp') corePlugin project(path: ':scm-plugins:scm-hg-plugin', configuration: 'smp') corePlugin project(path: ':scm-plugins:scm-svn-plugin', configuration: 'smp') + assets project(path: ':scm-ui', configuration: 'assets') implementation project(':scm-core') implementation project(':scm-dao-xml') @@ -136,6 +141,7 @@ dependencies { war { from 'build/war' + from project.configurations.assets dependsOn 'copy-core-plugins' } /**