diff --git a/{{cookiecutter.directory_name}}/.circleci/config.yml b/{{cookiecutter.directory_name}}/.circleci/config.yml index 29286c4..a7e85e8 100644 --- a/{{cookiecutter.directory_name}}/.circleci/config.yml +++ b/{{cookiecutter.directory_name}}/.circleci/config.yml @@ -40,6 +40,14 @@ jobs: sh gradlew ./gradlew -v ./gradlew setup + - run: + name: Run Inspection + command: | + ./gradlew codenarcMain --info || true + - run: + name: Collect Inspection Report + command: | + cp build/reports/codenarc/main.html ci-artifacts/codenarc.html - run: name: build command: | diff --git a/{{cookiecutter.directory_name}}/DEV.md b/{{cookiecutter.directory_name}}/DEV.md deleted file mode 100644 index b84090a..0000000 --- a/{{cookiecutter.directory_name}}/DEV.md +++ /dev/null @@ -1,59 +0,0 @@ -# {{cookiecutter.name}} - -### Installation -[![CircleCI](https://circleci.com/gh/egis/{{cookiecutter.name}}.svg?style=svg&circle-token=d88417ff93c9732d08a7ac9a1b6964d1259e516a)](https://circleci.com/gh/egis/{{cookiecutter.name}}) - -[![DEV](https://img.shields.io/badge/Environment-DEV-green.svg)](https:///{{cookiecutter.name}}-dev.papertrail.co.za) - -## Switching to PT 8.8.9-based build env after updating via cookiecutter -If you use Node version lower than 10.13 run this to update NPM dependencies: -``` -yarn --ignore-engines -``` -Then (with any Node version) add yarn.lock to code repository. - -Then run these steps to make sure the building works: -``` -gradle setup -gradle jar -gradle upgrade -gradle install -``` - -## Dev env & UAT - -### Deployment -First install node 8.10.0+, yarn 1.5.1+ and gradle 2.7. -Then use these steps to deploy to your PT instance: -``` -yarn -gradle setup -gradle jar -gradle upgrade -gradle install -pt deploy build/distributions/*-install.zip -pt deploy build/distributions/*-upgrade.zip -``` - -### Dev mode -The most convenient dev env for plugins is via [Browsersync](https://github.com/egis/build-tools/#browsersync). -To set this up, -* in one terminal window run `cd {{cookiecutter.name}} && yarn dev` -* in another terminal window run `cd build-tools && yarn browsersync -- --plugin={{cookiecutter.name}}` - -Normal standalone `npm run dev` dev env works too. - -#### Windows development env -* download and install nvm in c:\app\nvm (better not default Program Files dirs to avoid spaces in its path) -* download and install Python 2.7, add it to PATH -* if you're on windows 7 or Vista, install .net framework 4.5.1 -* install Node 6 (because it's easier to make work with gyp & fibers) -* `nvm install 6.0.0` # or `nvm install 6.0.0 32` if you're on 32bit windows -* `nvm use 6.0.0` # or `nvm use 6.0.0 32` if you're on 32bit windows -* git clone the project # I couldn't make cookiecutter work on Windows yet -* put this instead of existing `setup` script of the project's package.json: -``` - "setup": "npm install", -``` -* `cd {{cookiecutter.name}}` -Then you can use usual dev commands like `gradle setup` and `npm run dev`, including browsersync support. diff --git a/{{cookiecutter.directory_name}}/README.md b/{{cookiecutter.directory_name}}/README.md deleted file mode 100644 index df71d87..0000000 --- a/{{cookiecutter.directory_name}}/README.md +++ /dev/null @@ -1,5 +0,0 @@ -###Deployment Instructions: - - - -###Changelog: diff --git a/{{cookiecutter.directory_name}}/build.gradle b/{{cookiecutter.directory_name}}/build.gradle index 5e925fc..a0c31d1 100644 --- a/{{cookiecutter.directory_name}}/build.gradle +++ b/{{cookiecutter.directory_name}}/build.gradle @@ -7,9 +7,10 @@ buildscript { } dependencies { - classpath "com.egis:gradle-build:4.0.65" + classpath "com.egis:gradle-build:4.0.73" classpath 'org.ajoberstar:grgit:1.1.0' classpath "jp.classmethod.aws:gradle-aws-plugin:0.+" + classpath "org.kordamp.gradle:codenarc-gradle-plugin:0.51.0" } } @@ -23,6 +24,20 @@ apply plugin: 'java' apply plugin: 'groovy' apply plugin: 'idea' apply plugin: "com.egis.gradle" +apply plugin: 'codenarc' + +codenarc { + reportFormat = 'html' +} + +tasks.codenarcMain { + configFile = rootProject.file("codenarc/config/codenarc.groovy") + source = fileTree('src') { + include '**/*.groovy' + } + fileTree('resources') { + include '**/*.groovy' + } +} dependencies { repositories { diff --git a/{{cookiecutter.directory_name}}/codenarc/config/codenarc.groovy b/{{cookiecutter.directory_name}}/codenarc/config/codenarc.groovy new file mode 100644 index 0000000..36f9c0a --- /dev/null +++ b/{{cookiecutter.directory_name}}/codenarc/config/codenarc.groovy @@ -0,0 +1,327 @@ +reportFormat= 'console' +ruleset { + AssertWithinFinallyBlock + AssignmentInConditional + BigDecimalInstantiation + BitwiseOperatorInConditional + BooleanGetBoolean + BrokenNullCheck + BrokenOddnessCheck + ClassForName + ComparisonOfTwoConstants + ComparisonWithSelf + ConstantAssertExpression + ConstantIfExpression + ConstantTernaryExpression + DeadCode + DoubleNegative + DuplicateCaseStatement + DuplicateMapKey + DuplicateSetValue + EmptyCatchBlock + EmptyClass + EmptyElseBlock + EmptyFinallyBlock + EmptyForStatement + EmptyIfStatement + EmptyInstanceInitializer + EmptyMethod + EmptyStaticInitializer + EmptySwitchStatement + EmptySynchronizedStatement + EmptyTryBlock + EmptyWhileStatement + EqualsAndHashCode + EqualsOverloaded + ExplicitGarbageCollection + ForLoopShouldBeWhileLoop + HardCodedWindowsFileSeparator + HardCodedWindowsRootDirectory + IntegerGetInteger + MultipleUnaryOperators + RandomDoubleCoercedToZero + RemoveAllOnSelf + ReturnFromFinallyBlock + ThrowExceptionFromFinallyBlock + + ElseBlockBraces + ForStatementBraces + IfStatementBraces + WhileStatementBraces + + BusyWait + DoubleCheckedLocking + InconsistentPropertyLocking + InconsistentPropertySynchronization + NestedSynchronization + StaticCalendarField + StaticConnection + StaticDateFormatField + StaticMatcherField + StaticSimpleDateFormatField + SynchronizedMethod + SynchronizedOnBoxedPrimitive + SynchronizedOnGetClass + SynchronizedOnReentrantLock + SynchronizedOnString + SynchronizedOnThis + SynchronizedReadObjectMethod + SystemRunFinalizersOnExit + ThisReferenceEscapesConstructor + ThreadGroup + ThreadLocalNotStaticFinal + ThreadYield + UseOfNotifyMethod + VolatileArrayField + VolatileLongOrDoubleField + WaitOutsideOfWhileLoop + + ConfusingTernary + CouldBeElvis + HashtableIsObsolete + IfStatementCouldBeTernary + InvertedIfElse + LongLiteralWithLowerCaseL + NoDef + ParameterReassignment + TernaryCouldBeElvis + VectorIsObsolete + + AbstractClassWithPublicConstructor + AbstractClassWithoutAbstractMethod + BooleanMethodReturnsNull + BuilderMethodWithSideEffects + CloneableWithoutClone + CloseWithoutCloseable + CompareToWithoutComparable + ConstantsOnlyInterface + EmptyMethodInAbstractClass + FinalClassWithProtectedMember + ImplementationAsType + Instanceof + LocaleSetDefault + NestedForLoop + PrivateFieldCouldBeFinal + PublicInstanceField + ReturnsNullInsteadOfEmptyArray + ReturnsNullInsteadOfEmptyCollection + SimpleDateFormatMissingLocale + StatelessSingleton + ToStringReturnsNull + + CatchArrayIndexOutOfBoundsException + CatchError + CatchException + CatchIllegalMonitorStateException + CatchIndexOutOfBoundsException + CatchNullPointerException + CatchRuntimeException + CatchThrowable + ConfusingClassNamedException + ExceptionExtendsError + ExceptionExtendsThrowable + ExceptionNotThrown + MissingNewInThrowStatement + ReturnNullFromCatchBlock + SwallowThreadDeath + ThrowError + ThrowException + ThrowNullPointerException + + ThrowThrowable + BlankLineBeforePackage + BracesForClass + BracesForForLoop + BracesForIfElse + BracesForMethod + BracesForTryCatchFinally + + ClosureStatementOnOpeningLineOfMultipleLineClosure + ConsecutiveBlankLines + FileEndsWithoutNewline + + MissingBlankLineAfterImports + MissingBlankLineAfterPackage + SpaceAfterCatch + SpaceAfterClosingBrace + SpaceAfterComma + SpaceAfterFor + SpaceAfterIf + SpaceAfterOpeningBrace + SpaceAfterSemicolon + SpaceAfterSwitch + SpaceAfterWhile + SpaceAroundClosureArrow + SpaceAroundMapEntryColon(characterAfterColonRegex: /\s/) + SpaceAroundOperator + SpaceBeforeClosingBrace + SpaceBeforeOpeningBrace + TrailingWhitespace + + IllegalClassMember + IllegalClassReference + IllegalPackageReference + IllegalRegex + IllegalString + RequiredRegex + RequiredString + StatelessClass + + AssignCollectionSort + AssignCollectionUnique + ClosureAsLastMethodParameter + CollectAllIsDeprecated + ConfusingMultipleReturns + ExplicitArrayListInstantiation + ExplicitCallToAndMethod + ExplicitCallToCompareToMethod + ExplicitCallToDivMethod + ExplicitCallToEqualsMethod + ExplicitCallToGetAtMethod + ExplicitCallToLeftShiftMethod + ExplicitCallToMinusMethod + ExplicitCallToModMethod + ExplicitCallToMultiplyMethod + ExplicitCallToOrMethod + ExplicitCallToPlusMethod + ExplicitCallToPowerMethod + ExplicitCallToRightShiftMethod + ExplicitCallToXorMethod + ExplicitHashMapInstantiation + ExplicitHashSetInstantiation + ExplicitLinkedHashMapInstantiation + ExplicitLinkedListInstantiation + ExplicitStackInstantiation + ExplicitTreeSetInstantiation + GStringAsMapKey + GStringExpressionWithinString + GetterMethodCouldBeProperty + GroovyLangImmutable + UseCollectMany + UseCollectNested + + DuplicateImport + ImportFromSamePackage + ImportFromSunPackages + MisorderedStaticImports + UnnecessaryGroovyImport + UnusedImport + NoWildcardImports + + DirectConnectionManagement + JdbcConnectionReference + JdbcResultSetReference + JdbcStatementReference + + + LoggerForDifferentClass + LoggerWithWrongModifiers + LoggingSwallowsStacktrace + MultipleLoggers + PrintStackTrace + Println + SystemErrPrint + SystemOutPrint + + AbstractClassName + ClassName { + regex = '^[A-Z][\\$a-zA-Z0-9]*$' + } + ClassNameSameAsFilename + ConfusingMethodName + // FactoryMethodName + FieldName { + regex = '^_?[a-z][a-zA-Z0-9]*$' + finalRegex = '^_?[a-z][a-zA-Z0-9]*$' + staticFinalRegex = '^logger$|^[A-Z][A-Z_0-9]*$|^serialVersionUID$' + } + InterfaceName + MethodName { + regex = '^[a-z][\\$_a-zA-Z0-9]*$|^.*\\s.*$' + } + ObjectOverrideMisspelledMethodName + PackageName + ParameterName + PropertyName + VariableName { + finalRegex = '^[a-z][a-zA-Z0-9]*$' + } + + FileCreateTempFile + InsecureRandom + + NonFinalPublicField + NonFinalSubclassOfSensitiveInterface + ObjectFinalize + PublicFinalizeMethod + SystemExit + UnsafeArrayDeclaration + + EnumCustomSerializationIgnored + SerialPersistentFields + SerialVersionUID + SerializableClassMustDefineSerialVersionUID + + + AbcMetric + ClassSize + + CyclomaticComplexity + MethodSize + NestedBlockDepth + ParameterCount + + AddEmptyString + ConsecutiveLiteralAppends + ConsecutiveStringConcatenation + UnnecessaryBigDecimalInstantiation + UnnecessaryBigIntegerInstantiation + UnnecessaryBooleanExpression + UnnecessaryBooleanInstantiation + UnnecessaryCallForLastElement + UnnecessaryCallToSubstring + UnnecessaryCast + UnnecessaryCatchBlock + UnnecessaryCollectCall + UnnecessaryCollectionCall + UnnecessaryConstructor + UnnecessaryDefInFieldDeclaration + UnnecessaryDefInMethodDeclaration + UnnecessaryDefInVariableDeclaration + UnnecessaryDotClass + UnnecessaryDoubleInstantiation + UnnecessaryElseStatement + UnnecessaryFinalOnPrivateMethod + UnnecessaryFloatInstantiation + UnnecessaryGString + UnnecessaryGetter + UnnecessaryIfStatement + UnnecessaryInstanceOfCheck + UnnecessaryInstantiationToGetClass + UnnecessaryIntegerInstantiation + UnnecessaryLongInstantiation + UnnecessaryModOne + UnnecessaryNullCheck + UnnecessaryNullCheckBeforeInstanceOf + UnnecessaryObjectReferences + UnnecessaryOverridingMethod + UnnecessaryPackageReference + UnnecessaryParenthesesForMethodCallWithClosure + UnnecessaryPublicModifier + UnnecessaryReturnKeyword + //UnnecessarySelfAssignment + UnnecessarySemicolon + UnnecessaryStringInstantiation + + UnnecessaryTernaryExpression + UnnecessaryToString + UnnecessaryTransientModifier + + UnusedArray + UnusedMethodParameter + UnusedObject + UnusedPrivateField + UnusedPrivateMethod + UnusedPrivateMethodParameter + UnusedVariable +} diff --git a/{{cookiecutter.directory_name}}/gradle/wrapper/gradle-wrapper.jar b/{{cookiecutter.directory_name}}/gradle/wrapper/gradle-wrapper.jar index c1962a7..d64cd49 100644 Binary files a/{{cookiecutter.directory_name}}/gradle/wrapper/gradle-wrapper.jar and b/{{cookiecutter.directory_name}}/gradle/wrapper/gradle-wrapper.jar differ diff --git a/{{cookiecutter.directory_name}}/gradle/wrapper/gradle-wrapper.properties b/{{cookiecutter.directory_name}}/gradle/wrapper/gradle-wrapper.properties index 37aef8d..1af9e09 100644 --- a/{{cookiecutter.directory_name}}/gradle/wrapper/gradle-wrapper.properties +++ b/{{cookiecutter.directory_name}}/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/{{cookiecutter.directory_name}}/gradlew b/{{cookiecutter.directory_name}}/gradlew index aeb74cb..1aa94a4 100755 --- a/{{cookiecutter.directory_name}}/gradlew +++ b/{{cookiecutter.directory_name}}/gradlew @@ -83,7 +83,8 @@ done # This is normally unused # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -130,10 +131,13 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. @@ -141,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -149,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -198,11 +202,11 @@ fi # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ diff --git a/{{cookiecutter.directory_name}}/install/.keep b/{{cookiecutter.directory_name}}/install/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/{{cookiecutter.directory_name}}/libs/lib.txt b/{{cookiecutter.directory_name}}/libs/lib.txt deleted file mode 100644 index f983003..0000000 --- a/{{cookiecutter.directory_name}}/libs/lib.txt +++ /dev/null @@ -1 +0,0 @@ -# add any JAR depdencies here see https://github.com/egis/gradle-build#dependency-management \ No newline at end of file diff --git a/{{cookiecutter.directory_name}}/resources/System/scripts/.keep b/{{cookiecutter.directory_name}}/resources/System/scripts/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/{{cookiecutter.directory_name}}/src/js/.dev-loader.js b/{{cookiecutter.directory_name}}/src/js/.dev-loader.js deleted file mode 100644 index 592b5e7..0000000 --- a/{{cookiecutter.directory_name}}/src/js/.dev-loader.js +++ /dev/null @@ -1,38 +0,0 @@ -var moduleName = '{{cookiecutter.name}}'; -window[moduleName] = (function() { - "use strict"; - - var d0 = new Date().getTime(); - var moduleProxy; - - - var p = new Promise( function (resolve) { - EgisUI.loaded(function() { - log.info('Loading ' + moduleName + ' plugin with SystemJS..', EgisUI.currentTimeWithMillisString()); - var map = {}; - map[moduleName] = 'http://HOST:PORT/dist/main/dev-index'; - System.config({ - defaultJSExtensions: true, - map: map - }); - - System.import(moduleName).then(function(m) { - _.forEach(m, function(value, key) { - moduleProxy[key] = value; - }); - log.info(moduleName + ' plugin loaded in', new Date().getTime() - d0, EgisUI.currentTimeWithMillisString()); - resolve(m); - }); - }); - }); - - var moduleProxy = { - loaded: function(callback) { - p.then(function(m) { - m.loaded(callback); - }) - } - }; - - return moduleProxy; -})(); \ No newline at end of file diff --git a/{{cookiecutter.directory_name}}/src/js/.lib-exports.js b/{{cookiecutter.directory_name}}/src/js/.lib-exports.js deleted file mode 100644 index 23a93c4..0000000 --- a/{{cookiecutter.directory_name}}/src/js/.lib-exports.js +++ /dev/null @@ -1,12 +0,0 @@ -window.showDefaultPage = !location.hash || location.hash === '#'; // a flag in case the plugin needs to show some special page by default - -let loaded = (callback) => { - callback(); -}; - -export { - loaded -}; - -//pick the files code -import './{{cookiecutter.name}}Customization'; diff --git a/{{cookiecutter.directory_name}}/src/js/{{cookiecutter.name}}Customization.js b/{{cookiecutter.directory_name}}/src/js/{{cookiecutter.name}}Customization.js deleted file mode 100644 index 855e5bc..0000000 --- a/{{cookiecutter.directory_name}}/src/js/{{cookiecutter.name}}Customization.js +++ /dev/null @@ -1,34 +0,0 @@ -export default class {{cookiecutter.name}}Customization { - constructor() { - this.initRouter(); - this.initMenu(); - this.initToolbar(); - this.initActions(); - this.initViews(); - this.defaultRoute(); - } - - initRouter() { - } - - initViews() { - } - - defaultRoute() { - } - - initToolbar() { - } - - initActions() { - } - - initMenu() { - } -} - -UI.plugin(() => { - log.info('Loading {{cookiecutter.name}} plugin @@version @@timestamp'); - - window.customization = new {{cookiecutter.name}}Customization(); -}); diff --git a/{{cookiecutter.directory_name}}/test-libs/lib.txt b/{{cookiecutter.directory_name}}/test-libs/lib.txt deleted file mode 100644 index 91cde91..0000000 --- a/{{cookiecutter.directory_name}}/test-libs/lib.txt +++ /dev/null @@ -1 +0,0 @@ -# see https://github.com/egis/gradle-build#dependency-management \ No newline at end of file diff --git a/{{cookiecutter.directory_name}}/upgrade/.keep b/{{cookiecutter.directory_name}}/upgrade/.keep deleted file mode 100644 index e69de29..0000000