From 9240dd9a15b317d94c1db5c94281398a16b2b36a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gr=C3=A9goire=20Aubert?= Date: Thu, 16 May 2019 14:54:03 +0200 Subject: [PATCH] Fix dependencies (order) between Gradle tasks that execute yarn And add declarations of input files for "yarn_validate-ci" tasks, which were forgotten when caching was enabled for them. --- server/sonar-docs/build.gradle | 2 ++ server/sonar-vsts/build.gradle | 18 ++++++++++++++++-- server/sonar-vsts/config/webpack.config.js | 7 ++++++- server/sonar-vsts/package.json | 5 ++++- .../src/main/js/components/Configuration.tsx | 4 ++-- .../src/main/js/components/LoginForm.tsx | 6 +++--- .../src/main/js/components/LoginLink.tsx | 2 +- .../src/main/js/components/ProjectSelector.tsx | 2 +- .../main/js/components/ProjectSelectorItem.tsx | 2 +- .../src/main/js/components/QGWidget.tsx | 7 ++----- .../src/main/js/components/SonarCloudIcon.tsx | 2 +- .../src/main/js/components/Widget.tsx | 2 +- server/sonar-vsts/tsconfig.json | 5 ++++- server/sonar-web/build.gradle | 2 ++ 14 files changed, 46 insertions(+), 20 deletions(-) diff --git a/server/sonar-docs/build.gradle b/server/sonar-docs/build.gradle index 868a0e61348..727f164f10f 100644 --- a/server/sonar-docs/build.gradle +++ b/server/sonar-docs/build.gradle @@ -35,6 +35,8 @@ yarn_run { outputs.file('eslint-report.json') outputs.dir('coverage') outputs.cacheIf { true } + + dependsOn(yarn) } task zip(type: Zip) { diff --git a/server/sonar-vsts/build.gradle b/server/sonar-vsts/build.gradle index d6ecf126fc1..62cd909ea53 100644 --- a/server/sonar-vsts/build.gradle +++ b/server/sonar-vsts/build.gradle @@ -19,11 +19,18 @@ yarn_run { ].each { inputs.dir(it).withPathSensitivity(PathSensitivity.RELATIVE) } - ['babel.config.js', 'package.json', 'tsconfig.json', 'yarn.lock'].each { + ['babel.config.js', 'package.json', 'tsconfig.json', 'yarn.lock', + '../sonar-web/package.json', + '../sonar-web/yarn.lock' + ].each { inputs.file(it).withPathSensitivity(PathSensitivity.RELATIVE) } outputs.dir('build/webapp') outputs.cacheIf { true } + + // sonar-web dependencies needs to be installed before we build sonar-vsts otherwise the sonar-web components + // that sonar-vsts depends uppon won't find their node_modules + dependsOn(':server:sonar-web:yarn') args = ['build'] } build.dependsOn(yarn_run) @@ -38,12 +45,19 @@ build.dependsOn(yarn_run) ].each { inputs.dir(it) } - ['package.json', 'yarn.lock', 'tsconfig.json', '.eslintrc', '.eslintignore'].each { + ['package.json', 'yarn.lock', 'tsconfig.json', '.eslintrc', '.eslintignore', + '../sonar-web/package.json', + '../sonar-web/yarn.lock' + ].each { inputs.file(it) } outputs.file('eslint-report.json') outputs.dir('coverage') outputs.cacheIf { true } + + // sonar-web dependencies needs to be installed before we build sonar-vsts otherwise the sonar-web components + // that sonar-vsts depends uppon won't find their node_modules + dependsOn(yarn, ':server:sonar-web:yarn') } def sources = fileTree(dir: "src") + fileTree(dir: "scripts") + fileTree(dir: "config") diff --git a/server/sonar-vsts/config/webpack.config.js b/server/sonar-vsts/config/webpack.config.js index f34c0d55420..a650793501e 100644 --- a/server/sonar-vsts/config/webpack.config.js +++ b/server/sonar-vsts/config/webpack.config.js @@ -32,7 +32,12 @@ module.exports = ({ production = true }) => ({ devtool: production ? 'source-map' : 'cheap-module-source-map', resolve: { // Add '.ts' and '.tsx' as resolvable extensions. - extensions: ['.ts', '.tsx', '.js', '.json'] + extensions: ['.ts', '.tsx', '.js', '.json'], + alias: { + '@sqapi': path.resolve(__dirname, '../../sonar-web/src/main/js/api'), + '@sqcomponents': path.resolve(__dirname, '../../sonar-web/src/main/js/components'), + '@sqhelpers': path.resolve(__dirname, '../../sonar-web/src/main/js/helpers') + } }, entry: [ !production && require.resolve('react-dev-utils/webpackHotDevClient'), diff --git a/server/sonar-vsts/package.json b/server/sonar-vsts/package.json index 0e1bf9d4fec..ea40f80df72 100644 --- a/server/sonar-vsts/package.json +++ b/server/sonar-vsts/package.json @@ -117,7 +117,10 @@ ], "moduleNameMapper": { "^.+\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "/config/jest/FileStub.js", - "^.+\\.css$": "/config/jest/CSSStub.js" + "^.+\\.css$": "/config/jest/CSSStub.js", + "^@sqapi(.*)$": "/../sonar-web/src/main/js/api$1", + "^@sqcomponents(.*)$": "/../sonar-web/src/main/js/components$1", + "^@sqhelpers(.*)$": "/../sonar-web/src/main/js/helpers$1" }, "setupFiles": [ "/config/polyfills.js", diff --git a/server/sonar-vsts/src/main/js/components/Configuration.tsx b/server/sonar-vsts/src/main/js/components/Configuration.tsx index 5b659ed8b3c..e622cf20f03 100644 --- a/server/sonar-vsts/src/main/js/components/Configuration.tsx +++ b/server/sonar-vsts/src/main/js/components/Configuration.tsx @@ -18,9 +18,10 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { Component, searchProjects } from '@sqapi/components'; +import { getCurrentUser } from '@sqapi/users'; import LoginForm from './LoginForm'; import ProjectSelector from './ProjectSelector'; -import { Component, searchProjects } from '../../../../../sonar-web/src/main/js/api/components'; import { Settings, VSTSWidgetSettings, @@ -28,7 +29,6 @@ import { serializeWidgetSettings, parseWidgetSettings } from '../utils'; -import { getCurrentUser } from '../../../../../sonar-web/src/main/js/api/users'; interface Props { contribution: string; diff --git a/server/sonar-vsts/src/main/js/components/LoginForm.tsx b/server/sonar-vsts/src/main/js/components/LoginForm.tsx index 84845a31e42..7141de30d4f 100644 --- a/server/sonar-vsts/src/main/js/components/LoginForm.tsx +++ b/server/sonar-vsts/src/main/js/components/LoginForm.tsx @@ -18,12 +18,12 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { getTextColor } from '@sqhelpers/colors'; +import { getBaseUrl } from '@sqhelpers/urls'; +import { getIdentityProviders } from '@sqapi/users'; import LoginLink from './LoginLink'; import SonarCloudIcon from './SonarCloudIcon'; import * as theme from '../../../../../sonar-web/src/main/js/app/theme'; -import { getIdentityProviders } from '../../../../../sonar-web/src/main/js/api/users'; -import { getTextColor } from '../../../../../sonar-web/src/main/js/helpers/colors'; -import { getBaseUrl } from '../../../../../sonar-web/src/main/js/helpers/urls'; interface Props { onReload: () => void; diff --git a/server/sonar-vsts/src/main/js/components/LoginLink.tsx b/server/sonar-vsts/src/main/js/components/LoginLink.tsx index 642fd354cb4..3f068f7f876 100644 --- a/server/sonar-vsts/src/main/js/components/LoginLink.tsx +++ b/server/sonar-vsts/src/main/js/components/LoginLink.tsx @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import { getBaseUrl } from '../../../../../sonar-web/src/main/js/helpers/urls'; +import { getBaseUrl } from '@sqhelpers/urls'; interface Props { className?: string; diff --git a/server/sonar-vsts/src/main/js/components/ProjectSelector.tsx b/server/sonar-vsts/src/main/js/components/ProjectSelector.tsx index 8203b8f57f6..92a719c7bdb 100644 --- a/server/sonar-vsts/src/main/js/components/ProjectSelector.tsx +++ b/server/sonar-vsts/src/main/js/components/ProjectSelector.tsx @@ -20,8 +20,8 @@ import * as React from 'react'; import * as classNames from 'classnames'; import { debounce } from 'lodash'; +import { Component } from '@sqapi/components'; import ProjectSelectorItem from './ProjectSelectorItem'; -import { Component } from '../../../../../sonar-web/src/main/js/api/components'; interface Props { isLoggedIn: boolean; diff --git a/server/sonar-vsts/src/main/js/components/ProjectSelectorItem.tsx b/server/sonar-vsts/src/main/js/components/ProjectSelectorItem.tsx index e1dfe927522..4f63ceb327c 100644 --- a/server/sonar-vsts/src/main/js/components/ProjectSelectorItem.tsx +++ b/server/sonar-vsts/src/main/js/components/ProjectSelectorItem.tsx @@ -19,7 +19,7 @@ */ import * as React from 'react'; import * as classNames from 'classnames'; -import { Component } from '../../../../../sonar-web/src/main/js/api/components'; +import { Component } from '@sqapi/components'; interface Props { isActive: boolean; diff --git a/server/sonar-vsts/src/main/js/components/QGWidget.tsx b/server/sonar-vsts/src/main/js/components/QGWidget.tsx index e20a0c0d23a..ce3fb4b67d1 100644 --- a/server/sonar-vsts/src/main/js/components/QGWidget.tsx +++ b/server/sonar-vsts/src/main/js/components/QGWidget.tsx @@ -19,12 +19,9 @@ */ import * as React from 'react'; import * as classNames from 'classnames'; +import { getPathUrlAsString, getProjectUrl } from '@sqhelpers/urls'; +import Tooltip from '@sqcomponents/controls/Tooltip'; import SonarCloudIcon from './SonarCloudIcon'; -import Tooltip from '../../../../../sonar-web/src/main/js/components/controls/Tooltip'; -import { - getPathUrlAsString, - getProjectUrl -} from '../../../../../sonar-web/src/main/js/helpers/urls'; interface Props { component: T.ComponentMeasure; diff --git a/server/sonar-vsts/src/main/js/components/SonarCloudIcon.tsx b/server/sonar-vsts/src/main/js/components/SonarCloudIcon.tsx index f57cb379f79..b1f80052ae0 100644 --- a/server/sonar-vsts/src/main/js/components/SonarCloudIcon.tsx +++ b/server/sonar-vsts/src/main/js/components/SonarCloudIcon.tsx @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import { IconProps } from '../../../../../sonar-web/src/main/js/components/icons-components/Icon'; +import { IconProps } from '@sqcomponents/icons-components/Icon'; export default function SonarCloudIcon({ className, fill = '#f3702a', size = 18 }: IconProps) { return ( diff --git a/server/sonar-vsts/src/main/js/components/Widget.tsx b/server/sonar-vsts/src/main/js/components/Widget.tsx index 9cd912fb4e8..8720b6a9317 100644 --- a/server/sonar-vsts/src/main/js/components/Widget.tsx +++ b/server/sonar-vsts/src/main/js/components/Widget.tsx @@ -18,9 +18,9 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { getMeasuresAndMeta } from '@sqapi/measures'; import QGWidget from './QGWidget'; import LoginForm from './LoginForm'; -import { getMeasuresAndMeta } from '../../../../../sonar-web/src/main/js/api/measures'; import { Settings } from '../utils'; interface Props { diff --git a/server/sonar-vsts/tsconfig.json b/server/sonar-vsts/tsconfig.json index bbab74e1bbb..4713fd26cff 100644 --- a/server/sonar-vsts/tsconfig.json +++ b/server/sonar-vsts/tsconfig.json @@ -14,7 +14,10 @@ "moduleResolution": "node", "baseUrl": "./", "paths": { - "*": ["../sonar-web/node_modules/@types/*", "./node_modules/@types/*", "*"] + "@sqapi/*": ["../sonar-web/src/main/js/api/*"], + "@sqcomponents/*": ["../sonar-web/src/main/js/components/*"], + "@sqhelpers/*": ["../sonar-web/src/main/js/helpers/*"], + "*": ["./node_modules/@types/*", "../sonar-web/node_modules/@types/*", "*"] }, "sourceMap": true }, diff --git a/server/sonar-web/build.gradle b/server/sonar-web/build.gradle index 44405d227d8..17ceecbd5dc 100644 --- a/server/sonar-web/build.gradle +++ b/server/sonar-web/build.gradle @@ -51,6 +51,8 @@ build.dependsOn(yarn_run) outputs.file('eslint-report.json') outputs.dir('coverage') outputs.cacheIf { true } + + dependsOn(yarn) } def sources = fileTree(dir: "src") + fileTree(dir: "scripts") + fileTree(dir: "config") -- 2.39.5