Skip to content

Commit

Permalink
Migrate plugin to 10.x Sonarqube version
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasz-strzelecki-vml committed Oct 18, 2024
1 parent 9547901 commit 22a13b8
Show file tree
Hide file tree
Showing 132 changed files with 23,111 additions and 1,709 deletions.
7 changes: 7 additions & 0 deletions .cirrus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
container:
image: maven:3.9.4-eclipse-temurin-11

build_task:
maven_cache:
folder: ~/.m2/repository
build_script: mvn clean package
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/.yarn/releases/** binary
/.yarn/plugins/** binary
2 changes: 1 addition & 1 deletion .github/actions/test-plugin-installation/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# #%L
# AEM Rules for SonarQube
# %%
# Copyright (C) 2015-2019 Wunderman Thompson Technology
# Copyright (C) 2015-2024 VML
# %%
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# #%L
# AEM Rules for SonarQube
# %%
# Copyright (C) 2015-2019 Wunderman Thompson Technology
# Copyright (C) 2015-2024 VML
# %%
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -20,15 +20,15 @@

name: build-and-analyse

on: [push]
on: [ push ]

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
java-version: [11]
java-version: [ 11 ]

steps:
- uses: actions/checkout@v3
Expand Down
25 changes: 18 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
.idea/
*.iml
*.ipr
*.iws
node_modules
.DS_Store
target/
atlassian-ide-plugin.xml
node/
.idea/
sonar-example-plugin.iml
.java-version
local-docker-image/extensions/plugins/*

# Eclipse
.classpath
.project
.settings/
.java-version
.DS_Store

# yarn
.yarn/*
!.yarn/cache
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
925 changes: 925 additions & 0 deletions .yarn/releases/yarn-4.5.0.cjs

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-4.5.0.cjs
35 changes: 35 additions & 0 deletions conf/env.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright (C) 2009-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
// Grab NODE_ENV and REACT_APP_* environment variables and prepare them to be
// injected into the application via DefinePlugin in Webpack configuration.

const REACT_APP = /^REACT_APP_/i;

function getClientEnvironment() {
return Object.keys(process.env).filter(key => REACT_APP.test(key)).reduce((env, key) => {
env['process.env.' + key] = JSON.stringify(process.env[key]);
return env;
}, {
// Useful for determining whether we’re running in production mode.
// Most importantly, it switches React into the correct mode.
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development')
});
}

module.exports = getClientEnvironment;
19 changes: 19 additions & 0 deletions conf/jest/CSSStub.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright (C) 2009-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
module.exports = {};
19 changes: 19 additions & 0 deletions conf/jest/FileStub.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright (C) 2009-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
module.exports = 'test-file-stub';
24 changes: 24 additions & 0 deletions conf/jest/SetupTestEnvironment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright (C) 2009-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
window.baseUrl = '';

window.t = (window.tp = function() {
const args = Array.prototype.slice.call(arguments, 0);
return args.join('.');
});
34 changes: 34 additions & 0 deletions conf/webpack/webpack.config.dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (C) 2009-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
const webpack = require('webpack');
const config = require('./webpack.config');

config.devtool = 'eval';

config.output.publicPath = '/static/example/';

config.output.pathinfo = true;

Object.keys(config.entry).forEach(key => {
config.entry[key].unshift(require.resolve('react-dev-utils/webpackHotDevClient'));
});

config.plugins = [new webpack.HotModuleReplacementPlugin()];

module.exports = config;
83 changes: 83 additions & 0 deletions conf/webpack/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* Copyright (C) 2009-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
const path = require("path");
const autoprefixer = require("autoprefixer");

module.exports = {
// Define the entry points here. They MUST have the same name as the page_id
// defined in src/main/java/org/sonarsource/plugins/example/web/MyPluginPageDefinition.java
entry: {
// Using Vanilla JS:
global_page: ["./src/main/js/global_page/index.js"],

// Using Backbone JS:
project_page: ["./src/main/js/project_page/index.js"],

// Using React:
portfolio_page: ["./src/main/js/portfolio_page/index.js"],
admin_page: ["./src/main/js/admin_page/index.js"]
},
output: {
// The entry point files MUST be shipped inside the final JAR's static/
// directory.
path: path.join(__dirname, "../../target/classes/static"),
filename: "[name].js"
},
resolve: {
root: path.join(__dirname, "src/main/js")
},
externals: {
// React 16.8 ships with SonarQube, and should be re-used to avoid
// collisions at runtime.
react: "React",
"react-dom": "ReactDOM",
// Register the Sonar* globals as packages, to simplify importing.
// See src/main/js/common/api.js for more information on what is exposed
// in SonarRequest.
"sonar-request": "SonarRequest",
},
module: {
// Our example uses Babel to transpile our code.
loaders: [
{
test: /\.js$/,
loader: "babel",
exclude: /(node_modules)/
},
{
test: /\.css/,
loader: "style-loader!css-loader!postcss-loader"
},
{ test: /\.json$/, loader: "json" }
]
},
postcss() {
return [
autoprefixer({
browsers: [
"last 3 Chrome versions",
"last 3 Firefox versions",
"last 3 Safari versions",
"last 3 Edge versions",
"IE 11"
]
})
];
}
};
69 changes: 69 additions & 0 deletions conf/webpack/webpack.config.prod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Copyright (C) 2009-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
const webpack = require('webpack');
const config = require('./webpack.config');
const getClientEnvironment = require('../env');

// Get environment variables to inject into our app.
const env = getClientEnvironment();

// Assert this just to be safe.
// Development builds of React are slow and not intended for production.
if (env['process.env.NODE_ENV'] !== '"production"') {
throw new Error('Production builds must have NODE_ENV=production.');
}

const noUglify = process.argv.some(arg => arg.indexOf('--no-uglify') > -1);

// Don't attempt to continue if there are any errors.
config.bail = true;

config.plugins = [
// Makes some environment variables available to the JS code, for example:
// if (process.env.NODE_ENV === 'production') { ... }. See `./env.js`.
// It is absolutely essential that NODE_ENV was set to production here.
// Otherwise React will be compiled in the very slow development mode.
new webpack.DefinePlugin(env),

// This helps ensure the builds are consistent if source hasn't changed:
new webpack.optimize.OccurrenceOrderPlugin(),

// Try to dedupe duplicated modules, if any:
new webpack.optimize.DedupePlugin()
];

if (!noUglify) {
config.plugins.push(
new webpack.optimize.UglifyJsPlugin({
compress: {
screw_ie8: true, // React doesn't support IE8
warnings: false
},
mangle: {
screw_ie8: true
},
output: {
comments: false,
screw_ie8: true
}
})
);
}

module.exports = config;
Loading

0 comments on commit 22a13b8

Please sign in to comment.