diff --git a/.cfformat.json b/.cfformat.json index aa464f6..443ef67 100644 --- a/.cfformat.json +++ b/.cfformat.json @@ -1,13 +1,14 @@ { "array.empty_padding": false, "array.padding": true, - "array.multiline.min_length": 40, + "array.multiline.min_length": 50, "array.multiline.element_count": 2, "array.multiline.leading_comma.padding": true, "array.multiline.leading_comma": false, "alignment.consecutive.assignments": true, "alignment.consecutive.properties": true, "alignment.consecutive.params": true, + "alignment.doc_comments" : true, "brackets.padding": true, "comment.asterisks": "align", "binary_operators.padding": true, @@ -19,20 +20,20 @@ "function_call.casing.userdefined": "camel", "function_call.multiline.element_count": 3, "function_call.multiline.leading_comma": false, - "function_call.multiline.min_length": 40, + "function_call.multiline.min_length": 50, "function_declaration.padding": true, "function_declaration.empty_padding": false, "function_declaration.multiline.leading_comma": false, "function_declaration.multiline.leading_comma.padding": true, "function_declaration.multiline.element_count": 3, - "function_declaration.multiline.min_length": 40, - "function_declaration.group_to_block_spacing": "spaced", + "function_declaration.multiline.min_length": 50, + "function_declaration.group_to_block_spacing": "compact", "function_anonymous.empty_padding": false, - "function_anonymous.group_to_block_spacing": "spaced", + "function_anonymous.group_to_block_spacing": "compact", "function_anonymous.multiline.element_count": 3, "function_anonymous.multiline.leading_comma": false, "function_anonymous.multiline.leading_comma.padding": true, - "function_anonymous.multiline.min_length": 40, + "function_anonymous.multiline.min_length": 50, "function_anonymous.padding": true, "indent_size": 4, "keywords.block_to_keyword_spacing": "spaced", @@ -41,15 +42,15 @@ "keywords.spacing_to_block": "spaced", "keywords.spacing_to_group": true, "keywords.empty_group_spacing": false, - "max_columns": 120, + "max_columns": 115, "metadata.multiline.element_count": 3, - "metadata.multiline.min_length": 40, + "metadata.multiline.min_length": 50, + "method_call.chain.multiline" : 3, "newline":"\n", "property.multiline.element_count": 3, - "property.multiline.min_length": 40, + "property.multiline.min_length": 30, "parentheses.padding": true, "strings.quote": "double", - "strings.convertNestedQuotes": false, "strings.attributes.quote": "double", "struct.separator": " : ", "struct.padding": true, @@ -57,6 +58,6 @@ "struct.multiline.leading_comma": false, "struct.multiline.leading_comma.padding": true, "struct.multiline.element_count": 2, - "struct.multiline.min_length": 40, + "struct.multiline.min_length": 60, "tab_indent": true } diff --git a/.cflintrc b/.cflintrc index 396a0b3..b392d05 100644 --- a/.cflintrc +++ b/.cflintrc @@ -11,6 +11,7 @@ { "code": "AVOID_USING_CFINSERT_TAG" }, { "code": "AVOID_USING_CFUPDATE_TAG" }, { "code": "ARG_VAR_CONFLICT" }, + { "code": "ARG_VAR_MIXED" }, { "code": "ARG_HINT_MISSING" }, { "code": "ARG_HINT_MISSING_SCRIPT" }, { "code" : "ARGUMENT_INVALID_NAME" }, @@ -58,4 +59,4 @@ "parameters": { "TooManyFunctionsChecker.maximum" : 20 } -} \ No newline at end of file +} diff --git a/.editorconfig b/.editorconfig index a2c8081..ec87892 100644 --- a/.editorconfig +++ b/.editorconfig @@ -17,4 +17,4 @@ indent_size = 2 [*.{md,markdown}] trim_trailing_whitespace = false -insert_final_newline = false \ No newline at end of file +insert_final_newline = false diff --git a/.github/FUNDING.YML b/.github/FUNDING.YML new file mode 100644 index 0000000..7e59d13 --- /dev/null +++ b/.github/FUNDING.YML @@ -0,0 +1 @@ +patreon: ortussolutions diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..0768ab8 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,129 @@ +name: Module CI + +# Only on Development we build snapshots +on: + push: + branches: + - development + - master + +# UPDATE WITH THE RIGHT MODULE NAME +env: + MODULE_ID: cbjavaloader + +jobs: + ############################################# + # Tests First baby! We fail, no build :( + ############################################# + tests: + uses: ./.github/workflows/tests.yml + secrets: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + + ############################################# + # Build Module + ############################################# + build: + name: Build & Publish + needs: tests + runs-on: ubuntu-20.04 + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Setup Java + uses: actions/setup-java@v2 + with: + distribution: "adopt" + java-version: "11" + + #- name: Setup nodejs + # uses: actions/setup-node@v2 + # with: + # node-version: 12.x + + - name: Cache CommandBox Dependencies + uses: actions/cache@v1 + if: ${{ true }} + with: + path: ~/.CommandBox/artifacts + key: ${{ runner.OS }}-commandbox-cache-${{ hashFiles( 'box.json' ) }}-${{ hashFiles( 'test-harness/box.json' ) }} + restore-keys: | + ${{ runner.OS }}-commandbox-cache-${{ hashFiles( 'box.json' ) }}-${{ hashFiles( 'test-harness/box.json' ) }} + + - name: Setup CommandBox + uses: Ortus-Solutions/setup-commandbox@main + with: + forgeboxAPIKey: ${{ secrets.FORGEBOX_TOKEN }} + + - name: Setup Environment Variables For Build Process + id: current_version + run: | + echo "VERSION=`cat box.json | jq '.version' -r`" >> $GITHUB_ENV + box package set version=@build.version@+@build.number@ + # master or snapshot + echo "Github Ref is $GITHUB_REF" + echo "BRANCH=master" >> $GITHUB_ENV + if [ $GITHUB_REF == 'refs/heads/development' ] + then + echo "BRANCH=development" >> $GITHUB_ENV + fi + + - name: Build ${{ env.MODULE_ID }} + run: | + #npm i npm@latest -g + #npm install + #npm run prod + #rm -Rf node_modules + box install commandbox-docbox + box task run taskfile=build/Build target=run :version=${{ env.VERSION }} :projectName=${{ env.MODULE_ID }} :buildID=${{ github.run_number }} :branch=${{ env.BRANCH }} + + - name: Upload Build Artifacts + if: success() + uses: actions/upload-artifact@v2 + with: + name: ${{ env.MODULE_ID }} + path: | + .artifacts/**/* + + - name: Upload Binaries to S3 + uses: jakejarvis/s3-sync-action@master + with: + args: --acl public-read + env: + AWS_S3_BUCKET: "downloads.ortussolutions.com" + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_ACCESS_SECRET }} + SOURCE_DIR: ".artifacts/${{ env.MODULE_ID }}" + DEST_DIR: "ortussolutions/coldbox-modules/${{ env.MODULE_ID }}" + + - name: Upload API Docs to S3 + uses: jakejarvis/s3-sync-action@master + with: + args: --acl public-read + env: + AWS_S3_BUCKET: "apidocs.ortussolutions.com" + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_ACCESS_SECRET }} + SOURCE_DIR: ".tmp/apidocs" + DEST_DIR: "coldbox-modules/${{ env.MODULE_ID }}/${{ env.VERSION }}" + + - name: Publish To ForgeBox + run: | + cd .tmp/${{ env.MODULE_ID }} + cat box.json + box forgebox publish + + - name: Inform Slack + if: ${{ always() }} + uses: rtCamp/action-slack-notify@v2 + env: + SLACK_CHANNEL: coding + SLACK_COLOR: ${{ job.status }} # or a specific color like 'green' or '#ff00ff' + SLACK_ICON_EMOJI: ":bell:" + SLACK_MESSAGE: '${{ env.MODULE_ID }} Built with ${{ job.status }}!' + SLACK_TITLE: "${{ env.MODULE_ID }} Build" + SLACK_USERNAME: CI + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 0000000..3423d27 --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,33 @@ +name: Pull Requests + +on: + push: + branches-ignore: + - "main" + - "master" + - "development" + pull_request: + branches: + - development + +jobs: + # UPDATE TO THE MODULE REPO SO PR'S CAN REUSE IT + tests: + uses: coldbox-modules/cbjavaloader/.github/workflows/tests.yml@development + + # Format PR + format: + name: Format + runs-on: ubuntu-20.04 + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + + - uses: Ortus-Solutions/commandbox-action@v1.0.2 + with: + cmd: run-script format + + - name: Commit Format Changes + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: Apply cfformat changes diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..b242479 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,123 @@ +name: Test Suites + +# We are a reusable Workflow only +on: + workflow_call: + secrets: + SLACK_WEBHOOK_URL: + required: true + +jobs: + tests: + name: Tests + runs-on: ubuntu-20.04 + env: + DB_USER: root + DB_PASSWORD: root + strategy: + fail-fast: false + matrix: + cfengine: [ "lucee@5", "adobe@2016", "adobe@2018", "adobe@2021" ] + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + + # Not Needed in this module + #- name: Setup Database and Fixtures + # run: | + # sudo /etc/init.d/mysql start + # mysql -u${{ env.DB_USER }} -p${{ env.DB_PASSWORD }} -e 'CREATE DATABASE coolblog;' + # mysql -u${{ env.DB_USER }} -p${{ env.DB_PASSWORD }} < test-harness/tests/resources/coolblog.sql + + - name: Setup Java + uses: actions/setup-java@v2 + with: + distribution: "adopt" + java-version: "11" + + - name: Setup CommandBox CLI + uses: Ortus-Solutions/setup-commandbox@main + + # Not Needed in this module + #- name: Setup Environment For Testing Process + # working-directory: ./test-harness + # run: | + # # Setup .env + # touch .env + # # ENV + # printf "DB_HOST=localhost\n" >> .env + # printf "DB_USER=${{ env.DB_USER }}\n" >> .env + # printf "DB_PASSWORD=${{ env.DB_PASSWORD }}\n" >> .env + # printf "DB_CLASS=com.mysql.cj.jdbc.Driver\n" >> .env + # printf "DB_BUNDLEVERSION=8.0.19\n" >> .env + # printf "DB_BUNDLENAME=com.mysql.cj\n" >> .env + + - name: Cache CommandBox Dependencies + uses: actions/cache@v1 + if: ${{ true }} + with: + path: ~/.CommandBox/artifacts + key: ${{ runner.OS }}-commandbox-cache-${{ hashFiles( 'box.json' ) }}-${{ hashFiles( 'test-harness/box.json' ) }} + restore-keys: | + ${{ runner.OS }}-commandbox-cache-${{ hashFiles( 'box.json' ) }}-${{ hashFiles( 'test-harness/box.json' ) }} + + - name: Install Test Harness Dependencies + working-directory: ./test-harness + run: | + box install + + - name: Start ${{ matrix.cfengine }} Server + run: | + box server start serverConfigFile="server-${{ matrix.cfengine }}.json" --noSaveSettings --debug + # Install Adobe 2021 cfpm modules + if [[ "${{ matrix.cfengine }}" == "adobe@2021" ]] ; then + box run-script install:2021 + fi + curl http://127.0.0.1:60299 + + - name: Run Tests + run: | + mkdir -p test-harness/tests/results + box testbox run --verbose outputFile=test-harness/tests/results/test-results outputFormats=json,antjunit + + - name: Publish Test Results + uses: EnricoMi/publish-unit-test-result-action@v1 + if: always() + with: + files: test-harness/tests/results/**/*.xml + check_name: "${{ matrix.cfengine }} Test Results" + + - name: Upload Test Results to Artifacts + if: always() + uses: actions/upload-artifact@v2 + with: + name: test-results-${{ matrix.cfengine }} + path: | + test-harness/tests/results/**/* + + - name: Show Server Log On Failures + if: ${{ failure() }} + run: | + box server log serverConfigFile="server-${{ matrix.cfengine }}.json" + + - name: Upload Debug Logs To Artifacts + if: ${{ failure() }} + uses: actions/upload-artifact@v2 + with: + name: Failure Debugging Info - ${{ matrix.cfengine }} + path: | + .engine/**/logs/* + .engine/**/WEB-INF/cfusion/logs/* + + - name: Slack Notifications + # Only on failures and NOT in pull requests + if: ${{ failure() && !startsWith( 'pull_request', github.event_name ) }} + uses: rtCamp/action-slack-notify@v2 + env: + SLACK_CHANNEL: coding + SLACK_COLOR: ${{ job.status }} # or a specific color like 'green' or '#ff00ff' + SLACK_ICON_EMOJI: ":bell:" + SLACK_MESSAGE: '${{ env.MODULE_ID }} tests failed :cry:' + SLACK_TITLE: ${{ env.MODULE_ID }} Tests For ${{ matrix.cfengine }} failed + SLACK_USERNAME: CI + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} diff --git a/.gitignore b/.gitignore index ddc3087..73b1199 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ .artifacts/** .tmp/** +.engine/** test-harness/.engine/** test-harness/coldbox/** test-harness/docbox/** @@ -11,4 +12,4 @@ test-harness/logs/** test-harness/modules/** # log files -logs/** \ No newline at end of file +logs/** diff --git a/.markdownlintrc.json b/.markdownlintrc.json index ceacd1f..3707fcb 100644 --- a/.markdownlintrc.json +++ b/.markdownlintrc.json @@ -1,8 +1,15 @@ { "line-length": false, "single-h1": false, + "no-hard-tabs" : false, + "fenced-code-language" : false, + "no-bare-urls" : false, "first-line-h1": false, "no-multiple-blanks": { "maximum": 2 - } -} \ No newline at end of file + }, + "no-duplicate-header" : { + "siblings_only" : true + }, + "no-inline-html" : false +} diff --git a/ModuleConfig.cfc b/ModuleConfig.cfc index 0e7c3d9..b403430 100644 --- a/ModuleConfig.cfc +++ b/ModuleConfig.cfc @@ -6,45 +6,41 @@ component { // Module Properties - this.title = "JavaLoader"; - this.author = "Ortus Solutions"; - this.webURL = "https://www.ortussolutions.com"; - this.description = "A JavaLoader Module for ColdBox"; - this.cfmapping = "cbjavaloader"; + this.title = "JavaLoader"; + this.author = "Ortus Solutions"; + this.webURL = "https://www.ortussolutions.com"; + this.description = "A JavaLoader Module for ColdBox"; + this.cfmapping = "cbjavaloader"; /** * Configure module */ function configure(){ - settings = { // The array paths to load - loadPaths = [], + loadPaths : [], // Load ColdFusion classes with loader - loadColdFusionClassPath = false, + loadColdFusionClassPath : false, // Attach a custom class loader as a parent - parentClassLoader = "", + parentClassLoader : "", // Directories that contain Java source code that are to be dynamically compiled - sourceDirectories = [], + sourceDirectories : [], // the directory to build the .jar file for dynamic compilation in, defaults to ./tmp - compileDirectory = variables.modulePath & "models/javaloader/tmp", + compileDirectory : variables.modulePath & "models/javaloader/tmp", // Whether or not the source is trusted, i.e. it is going to change? Defaults to false, so changes will be recompiled and loaded - trustedSource = false + trustedSource : false }; // Register Custom DSL, don't map it because it is too late, mapping DSLs are only good by the parent app - wireBox - .registerDSL( namespace="javaloader", path="#moduleMapping#.models.JavaLoaderDSL" ); + wireBox.registerDSL( namespace = "javaloader", path = "#moduleMapping#.models.JavaLoaderDSL" ); } /** * Fired when the module is registered and activated. */ function onLoad(){ - // Bind Core JavaLoader - binder.map( "jl@cbjavaloader" ) - .to( "#moduleMapping#.models.javaloader.JavaLoader" ); + binder.map( "jl@cbjavaloader" ).to( "#moduleMapping#.models.javaloader.JavaLoader" ); // Duplicating so our final change won't affect the main module settings var finalSettings = duplicate( settings ); @@ -56,13 +52,13 @@ component { var moduleSettingsLoadPath = settings.loadPaths; // Force array - if( isSimpleValue( moduleSettingsLoadPath ) ) { + if ( isSimpleValue( moduleSettingsLoadPath ) ) { moduleSettingsLoadPath = moduleSettingsLoadPath.listToArray(); } // Loop over settings, adding files and expanding directories - for( var thisLocation in moduleSettingsLoadPath ){ - if( directoryExists( thisLocation ) ) { + for ( var thisLocation in moduleSettingsLoadPath ) { + if ( directoryExists( thisLocation ) ) { finalSettings.loadPaths.addAll( getJars( thisLocation ) ); } else if ( fileExists( thisLocation ) ) { finalSettings.loadPaths.append( thisLocation ); @@ -84,9 +80,13 @@ component { /** * Get an array of jar files */ - private array function getJars( required string dirPath, string filter="*.jar" ){ - if( not directoryExists( arguments.dirPath ) ){ - throw( message="Invalid library path", detail="The path is #arguments.dirPath#", type="JavaLoader.DirectoryNotFoundException" ); + private array function getJars( required string dirPath, string filter = "*.jar" ){ + if ( not directoryExists( arguments.dirPath ) ) { + throw( + message = "Invalid library path", + detail = "The path is #arguments.dirPath#", + type = "JavaLoader.DirectoryNotFoundException" + ); } return directoryList( diff --git a/box.json b/box.json index e0d75e8..99fcb02 100644 --- a/box.json +++ b/box.json @@ -1,32 +1,49 @@ { - "name" : "JavaLoader", - "author" : "Ortus Solutions.com ", - "version" : "2.0.0", - "location" : "http://downloads.ortussolutions.com/ortussolutions/coldbox-modules/cbjavaloader/@build.version@/cbjavaloader-@build.version@.zip", - "slug" : "cbjavaloader", - "type" : "modules", - "homepage" : "https://github.com/coldbox-modules/cbox-javaloader", - "documentation" : "https://github.com/coldbox-modules/cbox-javaloader", - "repository" : { "type" : "git", "url" : "https://github.com/coldbox-modules/cbox-javaloader" }, - "shortDescription" : "A module to class load, compile and do much more with Java", - "license" : [ - { "type" : "Apache2", "url" : "http://www.apache.org/licenses/LICENSE-2.0.html" } - ], - "contributors" : [ - "Brad Wood ", "Curt Gratz " - ], - "ignore":[ + "name":"JavaLoader", + "author":"Ortus Solutions.com ", + "version":"2.1.0", + "location":"https://downloads.ortussolutions.com/ortussolutions/coldbox-modules/cbjavaloader/@build.version@/cbjavaloader-@build.version@.zip", + "slug":"cbjavaloader", + "type":"modules", + "homepage":"https://github.com/coldbox-modules/cbox-javaloader", + "documentation":"https://github.com/coldbox-modules/cbox-javaloader", + "repository":{ + "type":"git", + "url":"https://github.com/coldbox-modules/cbox-javaloader" + }, + "shortDescription":"A module to class load, compile and do much more with Java", + "license":[ + { + "type":"Apache2", + "url":"http://www.apache.org/licenses/LICENSE-2.0.html" + } + ], + "contributors":[ + "Brad Wood ", + "Curt Gratz " + ], + "ignore":[ "**/.*", - "tests", - "*/.md" - ], - "dependencies":{}, - "devDependencies":{}, - "installPaths":{}, - "scripts":{ + "test-harness", + "/server*.json" + ], + "dependencies":{}, + "devDependencies":{ + "commandbox-dotenv":"*", + "commandbox-cfconfig":"*", + "commandbox-cfformat":"*" + }, + "installPaths":{}, + "testbox":{ + "runner":"http://localhost:60299/tests/runner.cfm" + }, + "scripts":{ "release":"recipe build/release.boxr", - "format":"cfformat run models/,test-harness/tests/ --overwrite", - "format:watch":"cfformat watch models/,test-harness/tests/", - "format:check":"cfformat check models/,test-harness/tests/" + "format":"cfformat run models/,test-harness/**/*.cfc,ModuleConfig.cfc --overwrite", + "format:watch":"cfformat watch models/,test-harness/**/*.cfc,ModuleConfig.cfc ./.cfformat.json", + "format:check":"cfformat check models/,test-harness/**/*.cfc,ModuleConfig.cfc", + "cfpm":"echo '\".engine/adobe2021/WEB-INF/cfusion/bin/cfpm.sh\"' | run", + "cfpm:install":"echo '\".engine/adobe2021/WEB-INF/cfusion/bin/cfpm.sh\" install ${1}' | run", + "install:2021":"run-script cfpm:install zip,debugger" } -} \ No newline at end of file +} diff --git a/.travis.yml b/build/.travis.yml similarity index 100% rename from .travis.yml rename to build/.travis.yml diff --git a/build/Build.cfc b/build/Build.cfc index 20d86e4..ae94650 100644 --- a/build/Build.cfc +++ b/build/Build.cfc @@ -2,247 +2,315 @@ * Build process for ColdBox Modules * Adapt to your needs. */ -component{ - - /** - * Constructor - */ - function init(){ - // Setup Pathing - variables.cwd = getCWD().reReplace( "\.$", "" ); - variables.artifactsDir = cwd & "/.artifacts"; - variables.buildDir = cwd & "/.tmp"; - variables.apiDocsURL = "http://localhost:60299/apidocs/"; - variables.testRunner = "http://localhost:60299/tests/runner.cfm"; - - // Source Excludes Not Added to final binary - variables.excludes = [ - ".gitignore", - ".travis.yml", - ".artifacts", - ".tmp", - "build", - "test-harness", - ".DS_Store", - ".git" - ]; - - // Cleanup + Init Build Directories - [ variables.buildDir, variables.artifactsDir ].each( function( item ){ - if( directoryExists( item ) ){ - directoryDelete( item, true ); - } - // Create directories - directoryCreate( item, true, true ); +component { + + /** + * Constructor + */ + function init(){ + // Setup Pathing + variables.cwd = getCWD().reReplace( "\.$", "" ); + variables.artifactsDir = cwd & "/.artifacts"; + variables.buildDir = cwd & "/.tmp"; + variables.apiDocsURL = "http://localhost:60299/apidocs/"; + variables.testRunner = "http://localhost:60299/tests/runner.cfm"; + + // Source Excludes Not Added to final binary + variables.excludes = [ + "build", + "node-modules", + "resources", + "test-harness", + "(package|package-lock).json", + "webpack.config.js", + "^\..*" + ]; + + // Cleanup + Init Build Directories + [ + variables.buildDir, + variables.artifactsDir + ].each( function( item ){ + if ( directoryExists( item ) ) { + directoryDelete( item, true ); + } + // Create directories + directoryCreate( item, true, true ); } ); // Create Mappings - fileSystemUtil.createMapping( "coldbox", variables.cwd & "test-harness/coldbox" ); - - return this; - } - - /** - * Run the build process: test, build source, docs, checksums - * - * @projectName The project name used for resources and slugs - * @version The version you are building - * @buldID The build identifier - * @branch The branch you are building - */ - function run( - required projectName, - version="1.0.0", - buildID=createUUID(), - branch="development" - ){ + fileSystemUtil.createMapping( + "coldbox", + variables.cwd & "test-harness/coldbox" + ); + + return this; + } + + /** + * Run the build process: test, build source, docs, checksums + * + * @projectName The project name used for resources and slugs + * @version The version you are building + * @buldID The build identifier + * @branch The branch you are building + */ + function run( + required projectName, + version = "1.0.0", + buildID = createUUID(), + branch = "development" + ){ // Create project mapping fileSystemUtil.createMapping( arguments.projectName, variables.cwd ); - // Run the tests - runTests(); - - // Build the source - buildSource( argumentCollection=arguments ); - - // Build Docs - arguments.outputDir = variables.buildDir & "/apidocs"; - docs( argumentCollection=arguments ); - - // checksums - buildChecksums(); - - // Finalize Message - print.line() - .boldMagentaLine( "Build Process is done! Enjoy your build!" ) - .toConsole(); - } - - /** - * Run the test suites - */ - function runTests(){ - // Tests First, if they fail then exit - print.blueLine( "Testing the package, please wait..." ).toConsole(); - - command( 'testbox run' ) - .params( - runner = variables.testRunner, - verbose = true, - outputFile = "build/results.json" - ) - .run(); - - // Check Exit Code? - if( shell.getExitCode() ){ - return error( "Cannot continue building, tests failed!" ); - } - } - - /** - * Build the source + // Build the source + buildSource( argumentCollection = arguments ); + + // Build Docs + arguments.outputDir = variables.buildDir & "/apidocs"; + docs( argumentCollection = arguments ); + + // checksums + buildChecksums(); + + // Build latest changelog + latestChangelog(); + + // Finalize Message + print + .line() + .boldMagentaLine( "Build Process is done! Enjoy your build!" ) + .toConsole(); + } + + /** + * Run the test suites + */ + function runTests(){ + // Tests First, if they fail then exit + print.blueLine( "Testing the package, please wait..." ).toConsole(); + + command( "testbox run" ) + .params( + runner = variables.testRunner, + verbose = true, + outputFile = "#variables.cwd#/test-harness/results/test-results", + outputFormats="json,antjunit" + ) + .run(); + + // Check Exit Code? + if ( shell.getExitCode() ) { + return error( "Cannot continue building, tests failed!" ); + } + } + + /** + * Build the source * * @projectName The project name used for resources and slugs - * @version The version you are building - * @buldID The build identifier - * @branch The branch you are building - */ - function buildSource( - required projectName, - version="1.0.0", - buildID=createUUID(), - branch="development" - ){ - // Build Notice ID - print.line() - .boldMagentaLine( "Building #arguments.projectName# v#arguments.version#+#arguments.buildID# from #cwd# using the #arguments.branch# branch." ) - .toConsole(); - - // Prepare exports directory - variables.exportsDir = variables.artifactsDir & "/#projectName#/#arguments.version#"; - directoryCreate( variables.exportsDir, true, true ); - - // Project Build Dir - variables.projectBuildDir = variables.buildDir & "/#projectName#"; - directoryCreate( variables.projectBuildDir, true, true ); - - // Copy source - print.blueLine( "Copying source to build folder..." ).toConsole(); - copy( variables.cwd, variables.projectBuildDir ); - - // Create build ID - fileWrite( "#variables.projectBuildDir#/#projectName#-#version#+#buildID#", "Built with love on #dateTimeFormat( now(), "full")#" ); - - // Updating Placeholders - print.greenLine( "Updating version identifier to #arguments.version#" ).toConsole(); - command( 'tokenReplace' ) - .params( - path = "/#variables.projectBuildDir#/**", - token = "@build.version@", - replacement = arguments.version - ) - .run(); - - print.greenLine( "Updating build identifier to #arguments.buildID#" ).toConsole(); - command( 'tokenReplace' ) - .params( - path = "/#variables.projectBuildDir#/**", - token = ( arguments.branch == "master" ? "@build.number@" : "+@build.number@" ), - replacement = ( arguments.branch == "master" ? arguments.buildID : "-snapshot" ) - ) - .run(); - - // zip up source - var destination = "#variables.exportsDir#/#projectName#-#version#.zip"; - print.greenLine( "Zipping code to #destination#" ).toConsole(); - cfzip( - action="zip", - file="#destination#", - source="#variables.projectBuildDir#", - overwrite=true, - recurse=true - ); - - // Copy box.json for convenience - fileCopy( "#variables.projectBuildDir#/box.json", variables.exportsDir ); - } - - /** - * Produce the API Docs - */ - function docs( required projectName, version="1.0.0", outputDir=".tmp/apidocs" ){ - // Generate Docs - print.greenLine( "Generating API Docs, please wait..." ).toConsole(); - directoryCreate( arguments.outputDir, true, true ); - - command( 'docbox generate' ) - .params( - "source" = "models", - "mapping" = "models", - "strategy-projectTitle" = "#arguments.projectName# v#arguments.version#", - "strategy-outputDir" = arguments.outputDir - ) - .run(); - - print.greenLine( "API Docs produced at #arguments.outputDir#" ).toConsole(); - - var destination = "#variables.exportsDir#/#projectName#-docs-#version#.zip"; - print.greenLine( "Zipping apidocs to #destination#" ).toConsole(); - cfzip( - action="zip", - file="#destination#", - source="#arguments.outputDir#", - overwrite=true, - recurse=true - ); - } - - /********************************************* PRIVATE HELPERS *********************************************/ - - /** - * Build Checksums - */ - private function buildChecksums(){ - print.greenLine( "Building checksums" ).toConsole(); - command( 'checksum' ) - .params( path = '#variables.exportsDir#/*.zip', algorithm = 'SHA-512', extension="sha512", write=true ) - .run(); - command( 'checksum' ) - .params( path = '#variables.exportsDir#/*.zip', algorithm = 'md5', extension="md5", write=true ) - .run(); - } - - /** - * DirectoryCopy is broken in lucee - */ - private function copy( src, target, recurse=true ){ - // process paths with excludes - directoryList( src, false, "path", function( path ){ - var isExcluded = false; - variables.excludes.each( function( item ){ - if( path.replaceNoCase( variables.cwd, "", "all" ).findNoCase( item ) ){ - isExcluded = true; - } - } ); - return !isExcluded; - }).each( function( item ){ - // Copy to target - if( fileExists( item ) ){ - print.blueLine( "Copying #item#" ).toConsole(); - fileCopy( item, target ); - } else { - print.greenLine( "Copying directory #item#" ).toConsole(); - directoryCopy( item, target & "/" & item.replace( src, "" ), true ); - } - } ); - } - - /** + * @version The version you are building + * @buldID The build identifier + * @branch The branch you are building + */ + function buildSource( + required projectName, + version = "1.0.0", + buildID = createUUID(), + branch = "development" + ){ + // Build Notice ID + print + .line() + .boldMagentaLine( + "Building #arguments.projectName# v#arguments.version#+#arguments.buildID# from #cwd# using the #arguments.branch# branch." + ) + .toConsole(); + + // Prepare exports directory + variables.exportsDir = variables.artifactsDir & "/#projectName#/#arguments.version#"; + directoryCreate( variables.exportsDir, true, true ); + + // Project Build Dir + variables.projectBuildDir = variables.buildDir & "/#projectName#"; + directoryCreate( + variables.projectBuildDir, + true, + true + ); + + // Copy source + print.blueLine( "Copying source to build folder..." ).toConsole(); + copy( + variables.cwd, + variables.projectBuildDir + ); + + // Create build ID + fileWrite( + "#variables.projectBuildDir#/#projectName#-#version#+#buildID#", + "Built with love on #dateTimeFormat( now(), "full" )#" + ); + + // Updating Placeholders + print.greenLine( "Updating version identifier to #arguments.version#" ).toConsole(); + command( "tokenReplace" ) + .params( + path = "/#variables.projectBuildDir#/**", + token = "@build.version@", + replacement = arguments.version + ) + .run(); + + print.greenLine( "Updating build identifier to #arguments.buildID#" ).toConsole(); + command( "tokenReplace" ) + .params( + path = "/#variables.projectBuildDir#/**", + token = ( arguments.branch == "master" ? "@build.number@" : "+@build.number@" ), + replacement = ( arguments.branch == "master" ? arguments.buildID : "-snapshot" ) + ) + .run(); + + // zip up source + var destination = "#variables.exportsDir#/#projectName#-#version#.zip"; + print.greenLine( "Zipping code to #destination#" ).toConsole(); + cfzip( + action = "zip", + file = "#destination#", + source = "#variables.projectBuildDir#", + overwrite = true, + recurse = true + ); + + // Copy box.json for convenience + fileCopy( + "#variables.projectBuildDir#/box.json", + variables.exportsDir + ); + } + + /** + * Produce the API Docs + */ + function docs( + required projectName, + version = "1.0.0", + outputDir = ".tmp/apidocs" + ){ + // Create project mapping + fileSystemUtil.createMapping( arguments.projectName, variables.cwd ); + // Generate Docs + print.greenLine( "Generating API Docs, please wait..." ).toConsole(); + directoryCreate( arguments.outputDir, true, true ); + + command( "docbox generate" ) + .params( + "source" = "models", + "mapping" = "models", + "strategy-projectTitle" = "#arguments.projectName# v#arguments.version#", + "strategy-outputDir" = arguments.outputDir + ) + .run(); + + print.greenLine( "API Docs produced at #arguments.outputDir#" ).toConsole(); + + var destination = "#variables.exportsDir#/#projectName#-docs-#version#.zip"; + print.greenLine( "Zipping apidocs to #destination#" ).toConsole(); + cfzip( + action = "zip", + file = "#destination#", + source = "#arguments.outputDir#", + overwrite = true, + recurse = true + ); + } + + /** + * Build the latest changelog file: changelog-latest.md + */ + function latestChangelog(){ + print.blueLine( "Building latest changelog..." ).toConsole(); + + if ( !fileExists( variables.cwd & "changelog.md" ) ) { + return error( "Cannot continue building, changelog.md file doesn't exist!" ); + } + + fileWrite( + variables.cwd & "changelog-latest.md", + fileRead( variables.cwd & "changelog.md" ).split( "----" )[ 2 ].trim() & chr( 13 ) & chr( 10 ) + ); + + print + .greenLine( "Latest changelog file created at `changelog-latest.md`" ) + .line() + .line( fileRead( variables.cwd & "changelog-latest.md" ) ); + } + + /********************************************* PRIVATE HELPERS *********************************************/ + + /** + * Build Checksums + */ + private function buildChecksums(){ + print.greenLine( "Building checksums" ).toConsole(); + command( "checksum" ) + .params( + path = "#variables.exportsDir#/*.zip", + algorithm = "SHA-512", + extension = "sha512", + write = true + ) + .run(); + command( "checksum" ) + .params( + path = "#variables.exportsDir#/*.zip", + algorithm = "md5", + extension = "md5", + write = true + ) + .run(); + } + + /** + * DirectoryCopy is broken in lucee + */ + private function copy( src, target, recurse = true ){ + // process paths with excludes + directoryList( + src, + false, + "path", + function( path ){ + var isExcluded = false; + variables.excludes.each( function( item ){ + if ( path.replaceNoCase( variables.cwd, "", "all" ).reFindNoCase( item ) ) { + isExcluded = true; + } + } ); + return !isExcluded; + } + ).each( function( item ){ + // Copy to target + if ( fileExists( item ) ) { + print.blueLine( "Copying #item#" ).toConsole(); + fileCopy( item, target ); + } else { + print.greenLine( "Copying directory #item#" ).toConsole(); + directoryCopy( + item, + target & "/" & item.replace( src, "" ), + true + ); + } + } ); + } + + /** * Gets the last Exit code to be used **/ - private function getExitCode() { - return (createObject( 'java', 'java.lang.System' ).getProperty( 'cfml.cli.exitCode' ) ?: 0); - + private function getExitCode(){ + return ( createObject( "java", "java.lang.System" ).getProperty( "cfml.cli.exitCode" ) ?: 0 ); } -} \ No newline at end of file +} diff --git a/build/release.boxr b/build/release.boxr index e216f22..d0ba4f7 100755 --- a/build/release.boxr +++ b/build/release.boxr @@ -22,4 +22,4 @@ # Bump to prepare for a new release, do minor, change if needed and don't tag bump --minor --!tagVersion !git commit -a -m "version bump" -!git push origin development \ No newline at end of file +!git push origin development diff --git a/changelog.md b/changelog.md index 879c668..cece0de 100644 --- a/changelog.md +++ b/changelog.md @@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ---- +## [2.1.0] => 2022-FEB-04 + +### Added + +* More formatting rules +* Migration to github actions +* Updates from new module template + +---- + ## [2.0.0] => 2020-MAY-14 ### Added @@ -68,7 +78,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [1.2.0] -* Travis Updates +* Travis Updates * Changing the array of locations check so that it doesn't fail if a JAR file is passed in the array. * Readme Updates * ForgeBox2 Updates @@ -88,4 +98,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [1.0.0] -* Create first module version \ No newline at end of file +* Create first module version diff --git a/models/JavaLoaderDSL.cfc b/models/JavaLoaderDSL.cfc index e8fb09b..faceeec 100644 --- a/models/JavaLoaderDSL.cfc +++ b/models/JavaLoaderDSL.cfc @@ -20,7 +20,7 @@ component accessors="true" { /** * Constructor as per interface */ - public any function init( required any injector ) { + public any function init( required any injector ){ variables.injector = arguments.injector; variables.log = arguments.injector.getLogBox().getLogger( this ); @@ -28,9 +28,15 @@ component accessors="true" { } /** - * Process an incoming DSL definition and produce an object with it. + * Process an incoming DSL definition and produce an object with it + * + * @definition The injection dsl definition structure to process. Keys: name, dsl + * @targetObject The target object we are building the DSL dependency for. If empty, means we are just requesting building + * @targetID The target ID we are building this dependency for + * + * @return coldbox.system.ioc.dsl.IDSLBuilder */ - public any function process( required definition, targetObject ) { + function process( required definition, targetObject, targetID ){ var DSLNamespace = listFirst( arguments.definition.dsl, ":" ); switch ( DSLNamespace ) { case "javaloader": { @@ -42,13 +48,11 @@ component accessors="true" { /** * Get a JavaLoader Dependency */ - function getJavaLoaderDSL( required definition, targetObject ) { + function getJavaLoaderDSL( required definition, targetObject ){ var className = listLast( arguments.definition.dsl, ":" ); // Get Dependency, if not found, exception is thrown - return variables.injector - .getInstance( "loader@cbjavaloader" ) - .create( className ); + return variables.injector.getInstance( "loader@cbjavaloader" ).create( className ); } } diff --git a/models/Loader.cfc b/models/Loader.cfc index 52b6613..7c6b6b3 100755 --- a/models/Loader.cfc +++ b/models/Loader.cfc @@ -17,7 +17,7 @@ component accessors="true" singleton { /** * Constructor */ - function init() { + function init(){ // setup a static ID key according to coldbox app variables.staticIDKey = "cbox-javaloader-#hash( getCurrentTemplatePath() )#"; return this; @@ -26,16 +26,13 @@ component accessors="true" singleton { /** * Setup class loading */ - function setup( required struct moduleSettings ) { + function setup( required struct moduleSettings ){ // verify we have it loaded if ( not isJavaLoaderInScope() ) { lock name="#variables.staticIDKey#" throwontimeout="true" timeout="30" type="exclusive" { if ( not isJavaLoaderInScope() ) { setJavaLoaderInScope( - variables.wirebox.getInstance( - name = "jl@cbjavaloader", - initArguments = moduleSettings - ) + variables.wirebox.getInstance( name = "jl@cbjavaloader", initArguments = moduleSettings ) ); } } @@ -50,23 +47,24 @@ component accessors="true" singleton { /** * Get the original java loader object from scope */ - function getJavaLoader() { + function getJavaLoader(){ return getJavaLoaderFromScope(); } /** * Retrieves a reference to the java class. To create a instance, you must run init() on this object */ - function create( required string className ) { + function create( required string className ){ return getJavaLoaderFromScope().create( argumentCollection = arguments ); } /** * Appends a directory path of *.jar's,*.classes to the current loaded class loader. + * * @dirPath.hint The directory absolute path to load - * @filter.hint The directory filter + * @filter.hint The directory filter */ - function appendPaths( required string dirPath, string filter = "*.jar" ) { + function appendPaths( required string dirPath, string filter = "*.jar" ){ // Convert paths to array of file locations var qFiles = arrayOfJars( argumentCollection = arguments ); var iterator = qFiles.iterator(); @@ -100,7 +98,7 @@ component accessors="true" singleton { /** * Get all the loaded URLs */ - array function getLoadedURLs() { + array function getLoadedURLs(){ var loadedURLs = getURLClassLoader().getURLs(); var returnArray = arrayNew( 1 ); var x = 1; @@ -115,21 +113,21 @@ component accessors="true" singleton { /** * Returns the java.net.URLClassLoader in case you need access to it */ - any function getURLClassLoader() { + any function getURLClassLoader(){ return getJavaLoaderFromScope().getURLClassLoader(); } /** * Get the Javaloader Version */ - string function getVersion() { + string function getVersion(){ return getJavaLoaderFromScope().getVersion(); } /** * Get an array of jars from a directory location */ - array function arrayOfJars( required string dirPath, string filter = "*.jar" ) { + array function arrayOfJars( required string dirPath, string filter = "*.jar" ){ if ( not directoryExists( arguments.dirPath ) ) { throw( message = "Invalid library path", @@ -149,16 +147,16 @@ component accessors="true" singleton { /************************************** private *********************************************/ - private function setJavaLoaderInScope( required any javaLoader ) { + private function setJavaLoaderInScope( required any javaLoader ){ server[ getStaticIDKey() ] = arguments.javaLoader; } - private function getJavaLoaderFromScope() { + private function getJavaLoaderFromScope(){ return server[ getstaticIDKey() ]; } - private boolean function isJavaLoaderInScope() { + private boolean function isJavaLoaderInScope(){ return structKeyExists( server, getstaticIDKey() ); } diff --git a/readme.md b/readme.md index d731d29..b3d84a5 100644 --- a/readme.md +++ b/readme.md @@ -1,8 +1,10 @@ -[![Build Status](https://travis-ci.org/coldbox-modules/cbox-javaloader.svg?branch=development)](https://travis-ci.org/coldbox-modules/cbox-javaloader) +# Welcome to the cbJavaloader Project -# Welcome to the CBJavaloader Project + + + -The CB JavaLoader module will interface with Mark Mandel's JavaLoader to allow you to do a network class loader, compiler and proxy. +This module will allow your ColdBox applications to class load different Java classes and libraries at runtime via the JavaLoader project. It also registers a WireBox DSL so you can easily inject Java classes into your objects using WireBox. ## License @@ -10,8 +12,8 @@ Apache License, Version 2.0. ## Important Links -- https://github.com/coldbox-modules/cbox-javaloader -- https://forgebox.io/view/javaloader +- Repository: https://github.com/coldbox-modules/cbjavaloader +- ForgeBox: https://forgebox.io/view/cbjavaloader - Docs: https://github.com/Ortus-Solutions/JavaLoader - [Changelog](changelog.md) @@ -111,9 +113,9 @@ Because of His grace, this project exists. If you don't like this, then don't re By whom also we have access by faith into this grace wherein we stand, and rejoice in hope of the glory of God. And not only so, but we glory in tribulations also: knowing that tribulation worketh patience; And patience, experience; and experience, hope: -And hope maketh not ashamed; because the love of God is shed abroad in our hearts by the +And hope maketh not ashamed; because the love of God is shed abroad in our hearts by the Holy Ghost which is given unto us. ." Romans 5:5 ### THE DAILY BREAD - > "I am the way, and the truth, and the life; no one comes to the Father, but by me (JESUS)" Jn 14:1-12 \ No newline at end of file + > "I am the way, and the truth, and the life; no one comes to the Father, but by me (JESUS)" Jn 14:1-12 diff --git a/test-harness/server-adobe@2016.json b/server-adobe@2016.json similarity index 77% rename from test-harness/server-adobe@2016.json rename to server-adobe@2016.json index d65467b..a72e369 100644 --- a/test-harness/server-adobe@2016.json +++ b/server-adobe@2016.json @@ -10,7 +10,11 @@ }, "rewrites":{ "enable":"true" - } + }, + "webroot": "test-harness" + }, + "jvm":{ + "heapSize":"1024" }, "openBrowser":"false" -} \ No newline at end of file +} diff --git a/test-harness/server-adobe@2018.json b/server-adobe@2018.json similarity index 77% rename from test-harness/server-adobe@2018.json rename to server-adobe@2018.json index 4a6baf5..26e99aa 100644 --- a/test-harness/server-adobe@2018.json +++ b/server-adobe@2018.json @@ -10,7 +10,11 @@ }, "rewrites":{ "enable":"true" - } + }, + "webroot": "test-harness" + }, + "jvm":{ + "heapSize":"1024" }, "openBrowser":"false" -} \ No newline at end of file +} diff --git a/server-adobe@2021.json b/server-adobe@2021.json new file mode 100644 index 0000000..64c7d2c --- /dev/null +++ b/server-adobe@2021.json @@ -0,0 +1,20 @@ +{ + "name":"cbjavaloader-adobe@2021", + "app":{ + "serverHomeDirectory":".engine/adobe2021", + "cfengine":"adobe@2021" + }, + "web":{ + "http":{ + "port":"60299" + }, + "rewrites":{ + "enable":"true" + }, + "webroot": "test-harness" + }, + "jvm":{ + "heapSize":"1024" + }, + "openBrowser":"false" +} diff --git a/test-harness/server-lucee@5.json b/server-lucee@5.json similarity index 75% rename from test-harness/server-lucee@5.json rename to server-lucee@5.json index 22a9885..098eb43 100644 --- a/test-harness/server-lucee@5.json +++ b/server-lucee@5.json @@ -10,7 +10,11 @@ }, "rewrites":{ "enable":"true" - } + }, + "webroot":"test-harness" + }, + "jvm":{ + "heapSize":"1024" }, "openBrowser":"false" -} \ No newline at end of file +} diff --git a/test-harness/Application.cfc b/test-harness/Application.cfc index d3824e3..e4e41a7 100644 --- a/test-harness/Application.cfc +++ b/test-harness/Application.cfc @@ -4,7 +4,7 @@ Copyright 2005-2007 ColdBox Framework by Luis Majano and Ortus Solutions, Corp www.ortussolutions.com ******************************************************************************** */ -component{ +component { // UPDATE THE NAME OF THE MODULE IN TESTING BELOW request.MODULE_NAME = "cbjavaloader"; @@ -12,51 +12,63 @@ component{ // Application properties this.name = hash( getCurrentTemplatePath() ); this.sessionManagement = true; - this.sessionTimeout = createTimeSpan(0,0,15,0); - this.setClientCookies = true; + this.sessionTimeout = createTimespan( 0, 0, 15, 0 ); + this.setClientCookies = true; - /************************************** + /************************************** LUCEE Specific Settings **************************************/ // buffer the output of a tag/function body to output in case of a exception - this.bufferOutput = true; + this.bufferOutput = true; // Activate Gzip Compression - this.compression = false; + this.compression = false; // Turn on/off white space managemetn - this.whiteSpaceManagement = "smart"; + this.whiteSpaceManagement = "smart"; // Turn on/off remote cfc content whitespace this.suppressRemoteComponentContent = false; // COLDBOX STATIC PROPERTY, DO NOT CHANGE UNLESS THIS IS NOT THE ROOT OF YOUR COLDBOX APP - COLDBOX_APP_ROOT_PATH = getDirectoryFromPath( getCurrentTemplatePath() ); + COLDBOX_APP_ROOT_PATH = getDirectoryFromPath( getCurrentTemplatePath() ); // The web server mapping to this application. Used for remote purposes or static purposes - COLDBOX_APP_MAPPING = ""; + COLDBOX_APP_MAPPING = ""; // COLDBOX PROPERTIES - COLDBOX_CONFIG_FILE = ""; + COLDBOX_CONFIG_FILE = ""; // COLDBOX APPLICATION KEY OVERRIDE - COLDBOX_APP_KEY = ""; + COLDBOX_APP_KEY = ""; - // Mappings + // Mappings this.mappings[ "/root" ] = COLDBOX_APP_ROOT_PATH; // Map back to its root - moduleRootPath = REReplaceNoCase( this.mappings[ "/root" ], "#request.MODULE_NAME#(\\|/)test-harness(\\|/)", "" ); - modulePath = REReplaceNoCase( this.mappings[ "/root" ], "test-harness(\\|/)", "" ); + moduleRootPath = reReplaceNoCase( + this.mappings[ "/root" ], + "#request.MODULE_NAME#(\\|/)test-harness(\\|/)", + "" + ); + modulePath = reReplaceNoCase( + this.mappings[ "/root" ], + "test-harness(\\|/)", + "" + ); // Module Root + Path Mappings - this.mappings[ "/moduleroot" ] = moduleRootPath; + this.mappings[ "/moduleroot" ] = moduleRootPath; this.mappings[ "/#request.MODULE_NAME#" ] = modulePath; // application start public boolean function onApplicationStart(){ - application.cbBootstrap = new coldbox.system.Bootstrap( COLDBOX_CONFIG_FILE, COLDBOX_APP_ROOT_PATH, COLDBOX_APP_KEY, COLDBOX_APP_MAPPING ); + application.cbBootstrap = new coldbox.system.Bootstrap( + COLDBOX_CONFIG_FILE, + COLDBOX_APP_ROOT_PATH, + COLDBOX_APP_KEY, + COLDBOX_APP_MAPPING + ); application.cbBootstrap.loadColdbox(); return true; } // request start - public boolean function onRequestStart(String targetPage){ - + public boolean function onRequestStart( String targetPage ){ // Process ColdBox Request application.cbBootstrap.onRequestStart( arguments.targetPage ); @@ -68,11 +80,11 @@ component{ } public void function onSessionEnd( struct sessionScope, struct appScope ){ - arguments.appScope.cbBootStrap.onSessionEnd( argumentCollection=arguments ); + arguments.appScope.cbBootStrap.onSessionEnd( argumentCollection = arguments ); } public boolean function onMissingTemplate( template ){ - return application.cbBootstrap.onMissingTemplate( argumentCollection=arguments ); + return application.cbBootstrap.onMissingTemplate( argumentCollection = arguments ); } -} \ No newline at end of file +} diff --git a/test-harness/box.json b/test-harness/box.json index f660017..af8d603 100644 --- a/test-harness/box.json +++ b/test-harness/box.json @@ -5,10 +5,10 @@ "private":true, "description":"", "dependencies":{ - "coldbox":"^5.0.0" + "coldbox":"^6" }, "devDependencies":{ - "testbox":"^4.0.0" + "testbox":"*" }, "installPaths":{ "coldbox":"coldbox/", @@ -16,5 +16,6 @@ }, "testbox":{ "runner":"http://localhost:60299/tests/runner.cfm" - } -} \ No newline at end of file + }, + "scripts":{} +} diff --git a/test-harness/config/Coldbox.cfc b/test-harness/config/Coldbox.cfc index 6a3f72d..a2f86f7 100644 --- a/test-harness/config/Coldbox.cfc +++ b/test-harness/config/Coldbox.cfc @@ -1,110 +1,73 @@ -component{ +component { // Configure ColdBox Application function configure(){ - // coldbox directives coldbox = { - //Application Setup - appName = "Module Tester", - - //Development Settings - reinitPassword = "", - handlersIndexAutoReload = true, - modulesExternalLocation = [], - - //Implicit Events - defaultEvent = "", - requestStartHandler = "", - requestEndHandler = "", - applicationStartHandler = "main.onAppInit", - applicationEndHandler = "", - sessionStartHandler = "", - sessionEndHandler = "", - missingTemplateHandler = "", - - //Error/Exception Handling - exceptionHandler = "", - onInvalidEvent = "", - customErrorTemplate = "/coldbox/system/includes/BugReport.cfm", - - //Application Aspects - handlerCaching = false, - eventCaching = false + // Application Setup + appName : "Module Tester", + // Development Settings + reinitPassword : "", + handlersIndexAutoReload : true, + modulesExternalLocation : [], + // Implicit Events + defaultEvent : "", + requestStartHandler : "", + requestEndHandler : "", + applicationStartHandler : "main.onAppInit", + applicationEndHandler : "", + sessionStartHandler : "", + sessionEndHandler : "", + missingTemplateHandler : "", + // Error/Exception Handling + exceptionHandler : "", + onInvalidEvent : "", + customErrorTemplate : "/coldbox/system/exceptions/BugReport.cfm", + // Application Aspects + handlerCaching : false, + eventCaching : false }; // environment settings, create a detectEnvironment() method to detect it yourself. // create a function with the name of the environment so it can be executed if that environment is detected // the value of the environment is a list of regex patterns to match the cgi.http_host. - environments = { - development = "localhost,127\.0\.0\.1" - }; + environments = { development : "localhost,127\.0\.0\.1" }; // Module Directives modules = { // An array of modules names to load, empty means all of them - include = [], + include : [], // An array of modules names to NOT load, empty means none - exclude = [] + exclude : [] }; - //Register interceptors as an array, we need order - interceptors = [ - //SES - { class="coldbox.system.interceptors.SES" } - ]; + // Register interceptors as an array, we need order + interceptors = []; - //LogBox DSL + // LogBox DSL logBox = { // Define Appenders - appenders = { - files={class="coldbox.system.logging.appenders.RollingFileAppender", - properties = { - filename = "tester", filePath="/#appMapping#/logs" - } - } + appenders : { + files : { + class : "coldbox.system.logging.appenders.RollingFileAppender", + properties : { filename : "tester", filePath : "/#appMapping#/logs" } + }, + console : { class : "coldbox.system.logging.appenders.ConsoleAppender" } }, // Root Logger - root = { levelmax="DEBUG", appenders="*" }, + root : { levelmax : "DEBUG", appenders : "*" }, // Implicit Level Categories - info = [ "coldbox.system" ] - }; - - //Debugger Settings - debugger = { - // Debugger - debugMode = true, - debugPassword = "", - enableDumpVar = false, - persistentRequestProfilers = true, - maxPersistentRequestProfilers = 10, - maxRCPanelQueryRows = 50, - showRCSnapshots = true, - //Panels - showTracerPanel = true, - expandedTracerPanel = false, - showInfoPanel = true, - expandedInfoPanel = true, - showCachePanel = true, - expandedCachePanel = false, - showRCPanel = true, - expandedRCPanel = false, - showModulesPanel = true, - expandedModulesPanel = false, - wireboxCreationProfiler=true + info : [ "coldbox.system" ] }; - } /** * Load the Module you are testing */ function afterAspectsLoad( event, interceptData, rc, prc ){ - controller.getModuleService() - .registerAndActivateModule( - moduleName = request.MODULE_NAME, - invocationPath = "moduleroot" - ); + controller + .getModuleService() + .registerAndActivateModule( moduleName = request.MODULE_NAME, invocationPath = "moduleroot" ); } -} \ No newline at end of file +} diff --git a/test-harness/config/Routes.cfm b/test-harness/config/Routes.cfm deleted file mode 100644 index a304d25..0000000 --- a/test-harness/config/Routes.cfm +++ /dev/null @@ -1,46 +0,0 @@ - - // Allow unique URL or combination of URLs, we recommend both enabled - setUniqueURLS(false); - // Auto reload configuration, true in dev makes sense to reload the routes on every request - //setAutoReload(false); - // Sets automatic route extension detection and places the extension in the rc.format variable - // setExtensionDetection(true); - // The valid extensions this interceptor will detect - // setValidExtensions('xml,json,jsont,rss,html,htm'); - // If enabled, the interceptor will throw a 406 exception that an invalid format was detected or just ignore it - // setThrowOnInvalidExtension(true); - - // Base URL - if( len(getSetting('AppMapping') ) lte 1){ - setBaseURL("http://#cgi.HTTP_HOST#/"); - } - else{ - setBaseURL("http://#cgi.HTTP_HOST#/#getSetting('AppMapping')#/"); - } - - // Your Application Routes - addRoute(pattern=":handler/:action?"); - - - /** Developers can modify the CGI.PATH_INFO value in advance of the SES - interceptor to do all sorts of manipulations in advance of route - detection. If provided, this function will be called by the SES - interceptor instead of referencing the value CGI.PATH_INFO. - - This is a great place to perform custom manipulations to fix systemic - URL issues your Web site may have or simplify routes for i18n sites. - - @Event The ColdBox RequestContext Object - **/ - function PathInfoProvider(Event){ - /* Example: - var URI = CGI.PATH_INFO; - if (URI eq "api/foo/bar") - { - Event.setProxyRequest(true); - return "some/other/value/for/your/routes"; - } - */ - return CGI.PATH_INFO; - } - \ No newline at end of file diff --git a/test-harness/handlers/Main.cfc b/test-harness/handlers/Main.cfc index 0f0b859..8081f1a 100644 --- a/test-harness/handlers/Main.cfc +++ b/test-harness/handlers/Main.cfc @@ -1,16 +1,18 @@ /** -* My Event Handler Hint -*/ -component{ + * My Event Handler Hint + */ +component { property name="javaloader" inject="loader@cbjavaloader"; // Index - any function index( event,rc, prc ){ + any function index( event, rc, prc ){ + prc.test = wirebox.getInstance( dsl = "javaloader:HelloWorld" ); - prc.test = wirebox.getInstance( dsl="javaloader:HelloWorld" ); - - prc.hello = javaloader.create( "HelloWorld" ).init().hello(); + prc.hello = javaloader + .create( "HelloWorld" ) + .init() + .hello(); } // Run on first init @@ -18,4 +20,4 @@ component{ javaloader.appendPaths( getSetting( "ApplicationPath" ) & "jars" ); } -} \ No newline at end of file +} diff --git a/test-harness/tests/Application.cfc b/test-harness/tests/Application.cfc index 39416f3..7d7a72c 100644 --- a/test-harness/tests/Application.cfc +++ b/test-harness/tests/Application.cfc @@ -17,11 +17,7 @@ component { this.mappings[ "/tests" ] = getDirectoryFromPath( getCurrentTemplatePath() ); // The application root - rootPath = reReplaceNoCase( - this.mappings[ "/tests" ], - "tests(\\|/)", - "" - ); + rootPath = reReplaceNoCase( this.mappings[ "/tests" ], "tests(\\|/)", "" ); this.mappings[ "/root" ] = rootPath; // UPDATE THE NAME OF THE MODULE IN TESTING BELOW @@ -36,4 +32,25 @@ component { this.mappings[ "/moduleroot" ] = moduleRootPath; this.mappings[ "/#request.MODULE_NAME#" ] = moduleRootPath & "#request.MODULE_NAME#"; + // request start + public boolean function onRequestStart( String targetPage ){ + if ( url.keyExists( "fwreinit" ) ) { + if ( structKeyExists( server, "lucee" ) ) { + pagePoolClear(); + } + } + + return true; + } + + public function onRequestEnd(){ + // CB 6 graceful shutdown + if ( !isNull( application.cbController ) ) { + application.cbController.getLoaderService().processShutdown(); + } + + structDelete( application, "cbController" ); + structDelete( application, "wirebox" ); + } + } diff --git a/test-harness/tests/index.cfm b/test-harness/tests/index.cfm index f67cdb0..8126654 100644 --- a/test-harness/tests/index.cfm +++ b/test-harness/tests/index.cfm @@ -13,7 +13,6 @@ - @@ -26,14 +25,14 @@ #testbox.init( directory=rootMapping & url.path ).run()# -

Invalid incoming directory: #rootMapping & url.path#

+

Invalid incoming directory: #rootMapping & url.path#

- + @@ -42,155 +41,75 @@ + - TestBox Global Runner - - + + + + - }); - function runTests(){ - $("#btn-run").html( 'Running...' ).css( "opacity", "0.5" ); - $("#tb-results").load( "index.cfm", $("#runnerForm").serialize(), function( data ){ - $("#btn-run").html( 'Run' ).css( "opacity", "1" ); - } ); - } - function clearResults(){ - $("#tb-results").html( '' ); - $("#target").html( '' ); - $("#labels").html( '' ); - } - - -
-
- - -
-
v#testbox.getVersion()#
- - +
+
+
+ +
+ v#testbox.getVersion()# +
+ +
- -
-

TestBox Test Browser:

-

- Below is a listing of the files and folders starting from your root #rootPath#. You can click on individual tests in order to execute them - or click on the Run All button on your left and it will execute a directory runner from the visible folder. -

- -
Contents: #executePath# - -

-
- - - - - - - - +#qResults.name#
- - target="_blank"
>#qResults.name#
- - target="_blank">#qResults.name#
- - #qResults.name#
- - -
-
- +
+
+ + +

TestBox Test Browser:

+

+ Below is a listing of the files and folders starting from your root #rootPath#. You can click on individual tests in order to execute them + or click on the Run All button on your left and it will execute a directory runner from the visible folder. +

+ +
+ Contents: #executePath# + +

+
+ + + + + + + + ✚ #qResults.name#
+ + target="_blank"
>#qResults.name#
+ + target="_blank">#qResults.name#
+ + #qResults.name#
+ + +
+
+ +
- -
- -
- - \ No newline at end of file +