diff --git a/.circleci/config.yml b/.circleci/config.yml index 29685bf..1db0cc4 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -4,51 +4,50 @@ defaults: &defaults environment: JVM_OPTS: -Xmx3200m TERM: dumb - CI: true + CI_NAME: "CircleCI" -defaults_gradle: &defaults_gradle +defaults_gradle: &defaults_bld steps: - checkout - - restore_cache: - keys: - - gradle-dependencies-{{ checksum "build.gradle.kts" }} - # fallback to using the latest cache if no exact match is found - - gradle-dependencies- - run: - name: Gradle Dependencies - command: ./gradlew dependencies - - save_cache: - paths: ~/.m2 - key: gradle-dependencies-{{ checksum "build.gradle.kts" }} + name: Download the bld dependencies + command: ./bld download - run: - name: Run All Checks - command: ./gradlew check - - store_artifacts: - path: build/reports/ - destination: reports - - store_test_results: - path: build/reports/ + name: Compile source with bld + command: ./bld compile + - run: + name: Run tests with bld + command: ./bld test jobs: - build_gradle_jdk18: - <<: *defaults - - docker: - - image: cimg/openjdk:18.0 - - <<: *defaults_gradle - - build_gradle_jdk11: + bld_jdk11: <<: *defaults docker: - image: cimg/openjdk:11.0 - <<: *defaults_gradle + <<: *defaults_bld + + bld_jdk17: + <<: *defaults + + docker: + - image: cimg/openjdk:17.0 + + <<: *defaults_bld + + bld_jdk20: + <<: *defaults + + docker: + - image: cimg/openjdk:20.0 + + <<: *defaults_bld workflows: version: 2 - gradle: + bld: jobs: - - build_gradle_jdk11 - - build_gradle_jdk18 + - bld_jdk11 + - bld_jdk17 + - bld_jdk20 diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index a1e879d..a765b42 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -1,21 +1,21 @@ -name: gradle-ci +name: bld-ci on: [ push, pull_request, workflow_dispatch ] jobs: - build: + build-bld-project: runs-on: ubuntu-latest env: - GRADLE_OPTS: "-Dorg.gradle.jvmargs=-XX:MaxMetaspaceSize=512m" - SONAR_JDK: "11" + COVERAGE_SDK: "17" strategy: matrix: - java-version: [ 11, 18 ] + java-version: [ 11, 17, 20 ] steps: - - uses: actions/checkout@v3 + - name: Checkout source repository + uses: actions/checkout@v3 with: fetch-depth: 0 @@ -25,25 +25,25 @@ jobs: distribution: 'zulu' java-version: ${{ matrix.java-version }} - - name: Grant execute permission for gradlew - run: chmod +x gradlew + - name: Grant bld execute permission + run: chmod +x bld - - name: Cache SonarCloud packages - if: matrix.java-version == env.SONAR_JDK - uses: actions/cache@v3 - with: - path: ~/.sonar/cache - key: ${{ runner.os }}-sonar - restore-keys: ${{ runner.os }}-sonar + - name: Download the bld dependencies + run: ./bld download - - name: Test with Gradle - uses: gradle/gradle-build-action@v2 - with: - arguments: build check --stacktrace + - name: Compile source with bld + run: ./bld compile - - name: SonarCloud - if: success() && matrix.java-version == env.SONAR_JDK + - name: Run tests with bld + run: ./bld jacoco + + - name: Remove pom.xml + if: success() && matrix.java-version == env.COVERAGE_SDK + run: rm -rf pom.xml + + - name: SonarCloud Scan + uses: sonarsource/sonarcloud-github-action@master + if: success() && matrix.java-version == env.COVERAGE_SDK env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: ./gradlew sonar --info diff --git a/.gitignore b/.gitignore index 13a066e..ea86fe8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,85 +1,57 @@ -!.vscode/extensions.json -!.vscode/launch.json -!.vscode/settings.json -!.vscode/tasks.json -*.class -*.code-workspace -*.ctxt -*.iws -*.log -*.nar -*.rar -*.sublime-* -*.tar.gz -*.zip -.DS_Store -.classpath .gradle -.history -.kobalt -.mtj.tmp/ -.mvn/timing.properties -.mvn/wrapper/maven-wrapper.jar -.nb-gradle -.project -.scannerwork -.settings -.vscode/* -/**/.idea/$CACHE_FILE$ -/**/.idea/$PRODUCT_WORKSPACE_FILE$ -/**/.idea/**/caches/build_file_checksums.ser -/**/.idea/**/contentModel.xml -/**/.idea/**/dataSources.ids -/**/.idea/**/dataSources.local.xml -/**/.idea/**/dataSources/ -/**/.idea/**/dbnavigator.xml -/**/.idea/**/dictionaries -/**/.idea/**/dynamic.xml -/**/.idea/**/gradle.xml -/**/.idea/**/httpRequests -/**/.idea/**/libraries -/**/.idea/**/mongoSettings.xml -/**/.idea/**/replstate.xml -/**/.idea/**/shelf -/**/.idea/**/shelf/ -/**/.idea/**/sqlDataSources.xml -/**/.idea/**/tasks.xml -/**/.idea/**/uiDesigner.xml -/**/.idea/**/usage.statistics.xml -/**/.idea/**/workspace.xml -/**/.idea/sonarlint* -/**/.idea_modules/ -Thumbs.db -__pycache__ +.DS_Store +build +lib/bld/** +!lib/bld/bld-wrapper.jar +!lib/bld/bld-wrapper.properties +lib/compile/ +lib/runtime/ +lib/standalone/ +lib/test/ + +# IDEA ignores + +# User-specific +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin atlassian-ide-plugin.xml -bin/ -build/ -cmake-build-*/ -com_crashlytics_export_strings.xml -crashlytics-build.properties -crashlytics.properties -dependency-reduced-pom.xml -deploy/ -dist/ -ehthumbs.db -fabric.properties -gen/ -gradle.properties -hs_err_pid* -kobaltBuild -kobaltw*-test -lib/kotlin* -libs/ + +# Cursive Clojure plugin +.idea/replstate.xml + +# SonarLint plugin +.idea/sonarlint/ + +# Editor-based Rest Client +.idea/httpRequests + local.properties -out/ -pom.xml.asc -pom.xml.next -pom.xml.releaseBackup -pom.xml.tag -pom.xml.versionsBackup -proguard-project.txt -project.properties -release.properties -target/ -test-output -venv diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f30e74b..fe7fe02 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,31 +1,21 @@ -image: gradle:7-jdk11 +image: java:11:latest -variables: - GRADLE_OPTS: "-Dorg.gradle.daemon=false" - -before_script: - - export GRADLE_USER_HOME=`pwd`/.gradle +cache: + paths: + - .m2/repository/ stages: - build - test -build: +download: stage: build - script: gradle --build-cache assemble - cache: - key: "$CI_COMMIT_REF_NAME" - policy: push - paths: - - build - - .gradle + script: ./bld download + +compile: + stage: build + script: ./bld compile test: stage: test - script: gradle check - cache: - key: "$CI_COMMIT_REF_NAME" - policy: pull - paths: - - build - - .gradle + script: ./bld test diff --git a/.idea/.name b/.idea/.name deleted file mode 100644 index 9aa979d..0000000 --- a/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -readingtime \ No newline at end of file diff --git a/.idea/app.iml b/.idea/app.iml new file mode 100644 index 0000000..b074dbd --- /dev/null +++ b/.idea/app.iml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/bld.iml b/.idea/bld.iml new file mode 100644 index 0000000..e63e11e --- /dev/null +++ b/.idea/bld.iml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml deleted file mode 100644 index 7d0d0ad..0000000 --- a/.idea/codeStyles/Project.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml deleted file mode 100644 index 79ee123..0000000 --- a/.idea/codeStyles/codeStyleConfig.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/copyright/BSD_3.xml b/.idea/copyright/BSD_3.xml new file mode 100644 index 0000000..2586a79 --- /dev/null +++ b/.idea/copyright/BSD_3.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/copyright/Erik_s_Copyright_Notice.xml b/.idea/copyright/Erik_s_Copyright_Notice.xml deleted file mode 100644 index 0b64fd2..0000000 --- a/.idea/copyright/Erik_s_Copyright_Notice.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml index 1419e40..3203074 100644 --- a/.idea/copyright/profiles_settings.xml +++ b/.idea/copyright/profiles_settings.xml @@ -1,3 +1,3 @@ - + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml index 838047c..1e01b48 100644 --- a/.idea/inspectionProfiles/Project_Default.xml +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -1,36 +1,8 @@ \ No newline at end of file diff --git a/.idea/kotlinScripting.xml b/.idea/kotlinScripting.xml deleted file mode 100644 index bc444de..0000000 --- a/.idea/kotlinScripting.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file diff --git a/.idea/libraries-with-intellij-classes.xml b/.idea/libraries-with-intellij-classes.xml deleted file mode 100644 index 9fa3156..0000000 --- a/.idea/libraries-with-intellij-classes.xml +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/libraries/bld.xml b/.idea/libraries/bld.xml new file mode 100644 index 0000000..cf75013 --- /dev/null +++ b/.idea/libraries/bld.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/compile.xml b/.idea/libraries/compile.xml new file mode 100644 index 0000000..9bd86aa --- /dev/null +++ b/.idea/libraries/compile.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/runtime.xml b/.idea/libraries/runtime.xml new file mode 100644 index 0000000..2ae5c4b --- /dev/null +++ b/.idea/libraries/runtime.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/test.xml b/.idea/libraries/test.xml new file mode 100644 index 0000000..b80486a --- /dev/null +++ b/.idea/libraries/test.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 6575b4b..a7b0be7 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,8 +1,22 @@ - - + + + + + - + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..55adcb9 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations/Run Tests.xml b/.idea/runConfigurations/Run Tests.xml new file mode 100644 index 0000000..068d7e9 --- /dev/null +++ b/.idea/runConfigurations/Run Tests.xml @@ -0,0 +1,9 @@ + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml index 94a25f7..35eb1dd 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..ae95f51 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,11 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "type": "java", + "name": "Run Tests", + "request": "launch", + "mainClass": "net.thauvin.erik.ReadingTimeTest" + } + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..133aa45 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,15 @@ +{ + "java.project.sourcePaths": [ + "src/main/java", + "src/main/resources", + "src/test/java", + "src/bld/java" + ], + "java.configuration.updateBuildConfiguration": "automatic", + "java.project.referencedLibraries": [ + "${HOME}/.bld/dist/bld-1.7.5.jar", + "lib/compile/*.jar", + "lib/runtime/*.jar", + "lib/test/*.jar" + ] +} diff --git a/LICENSE.TXT b/LICENSE.TXT index 695e358..d8e958e 100644 --- a/LICENSE.TXT +++ b/LICENSE.TXT @@ -1,4 +1,4 @@ -Copyright (c) 2020-2022, Erik C. Thauvin (erik@thauvin.net) +Copyright (c) 2020-2023, Erik C. Thauvin (erik@thauvin.net) All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/README.md b/README.md index e508cef..a8f0c58 100644 --- a/README.md +++ b/README.md @@ -18,13 +18,24 @@ println(rt.calcEstimatedReadTime()) // eg: 2 min read ``` +- View [bld](https://github.com/ethauvin/readingtime/blob/master/examples/bld) or [Gradle](https://github.com/ethauvin/readingtime/blob/master/examples/gradle) Examples + To get the estimated reading time in seconds use the `calcReadingTimeInSec()` function. - - View [Kotlin](https://github.com/ethauvin/readingtime/blob/master/examples/src/main/kotlin/com/example/ReadingTimeExample.kt) or [Java](https://github.com/ethauvin/readingtime/blob/master/examples/src/main/java/com/example/ReadingTimeSample.java) Examples. +### bld + +To use with [bld](https://rife2.com/bld), include the following dependency in your [build](https://github.com/ethauvin/readingtime/blob/master/examples/bld/java/net/thauvin/erik/ReadingTimeBuild.java) file: + +```java +repositories = List.of(MAVEN_CENTRAL); + +scope(compile) + .include(dependency("net.thauvin.erik:readingtime:0.9.1")); +``` +Be sure to use the [bld Kotlin extension](https://github.com/rife2/bld-kotlin) in your project. ### Gradle, Maven, etc. - -To use with [Gradle](https://gradle.org/), include the following dependency in your [build](https://github.com/ethauvin/readingtime/blob/master/examples/build.gradle.kts) file: +To use with [Gradle](https://gradle.org/), include the following dependency in your [build](https://github.com/ethauvin/readingtime/blob/master/examples/gradle/build.gradle.kts) file: ```gradle repositories { @@ -35,7 +46,6 @@ dependencies { implementation("net.thauvin.erik:readingtime:0.9.1") } ``` - Instructions for using with Maven, Ivy, etc. can be found on [Maven Central](https://search.maven.org/search?q=g:%22net.thauvin.erik%22%20AND%20a:%22readingtime%22). ### Properties diff --git a/bitbucket-pipelines.yml b/bitbucket-pipelines.yml index a9514a0..85a9b6c 100644 --- a/bitbucket-pipelines.yml +++ b/bitbucket-pipelines.yml @@ -1,9 +1,17 @@ -image: maven:3-openjdk-18 +image: java:17:latest pipelines: default: - step: - caches: - - gradle + name: "Download dependencies" script: - - bash ./gradlew check + - bash ./bld download + - step: + name: "Compile project" + script: + - bash ./bld compile + - step: + name: "Run tests" + script: + - bash ./bld test + diff --git a/bld b/bld new file mode 100755 index 0000000..7c6b3a7 --- /dev/null +++ b/bld @@ -0,0 +1,2 @@ +#!/usr/bin/env sh +java -jar "$(dirname "$0")/lib/bld/bld-wrapper.jar" "$0" --build net.thauvin.erik.ReadingTimeBuild "$@" \ No newline at end of file diff --git a/bld.bat b/bld.bat new file mode 100644 index 0000000..9a33cdf --- /dev/null +++ b/bld.bat @@ -0,0 +1,4 @@ +@echo off +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +java -jar "%DIRNAME%/lib/bld/bld-wrapper.jar" "%0" --build net.thauvin.erik.ReadingTimeBuild %* \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts deleted file mode 100644 index b1e448c..0000000 --- a/build.gradle.kts +++ /dev/null @@ -1,205 +0,0 @@ -import org.jetbrains.dokka.gradle.DokkaTask -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile -import org.gradle.api.tasks.testing.logging.TestExceptionFormat -import org.gradle.api.tasks.testing.logging.TestLogEvent - -plugins { - id("com.github.ben-manes.versions") version "0.47.0" - id("io.gitlab.arturbosch.detekt") version "1.23.0" - id("java-library") - id("java") - id("maven-publish") - id("org.jetbrains.dokka") version "1.8.20" - id("org.jetbrains.kotlinx.kover") version "0.7.2" - id("org.sonarqube") version "4.2.1.3168" - id("signing") - kotlin("jvm") version "1.8.22" -} - -description = "Estimated Reading Time for Blog Posts, Articles, etc." -group = "net.thauvin.erik" -version = "0.9.1" - -val deployDir = "deploy" -val gitHub = "ethauvin/$name" -val mavenUrl = "https://github.com/$gitHub" -val publicationName = "mavenJava" -var isRelease = "release" in gradle.startParameter.taskNames - -repositories { - mavenCentral() - maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots") } -} - -dependencies { - implementation(platform(kotlin("bom"))) - - implementation("org.jsoup:jsoup:1.16.1") - - testImplementation(kotlin("test")) - testImplementation(kotlin("test-junit")) -} - -java { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 - withSourcesJar() -} - -detekt { - //toolVersion = "main-SNAPSHOT" - baseline = project.rootDir.resolve("config/detekt/baseline.xml") -} - -koverReport { - defaults { - xml { - onCheck = true - } - html { - onCheck = true - } - } -} - -sonarqube { - properties { - property("sonar.projectKey", "ethauvin_$name") - property("sonar.organization", "ethauvin-github") - property("sonar.host.url", "https://sonarcloud.io") - property("sonar.sourceEncoding", "UTF-8") - property("sonar.coverage.jacoco.xmlReportPaths", "${project.buildDir}/reports/kover/report.xml") - } -} - -val javadocJar by tasks.creating(Jar::class) { - dependsOn(tasks.dokkaJavadoc) - from(tasks.dokkaJavadoc) - archiveClassifier.set("javadoc") -} - -tasks { - withType().configureEach { - kotlinOptions.jvmTarget = java.targetCompatibility.toString() - } - - withType { - testLogging { - exceptionFormat = TestExceptionFormat.FULL - events = setOf(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED) - } - } - - withType { - destination = file("$projectDir/pom.xml") - } - - assemble { - dependsOn(javadocJar) - } - - clean { - doLast { - project.delete(fileTree(deployDir)) - } - } - - withType().configureEach { - dokkaSourceSets { - named("main") { - moduleName.set("ReadingTime") - apiVersion.set("${project.version}") - } - } - } - - val copyToDeploy by registering(Copy::class) { - from(configurations.runtimeClasspath) { - exclude("annotations-*.jar") - } - from(jar) - into(deployDir) - } - - val gitIsDirty by registering(Exec::class) { - description = "Fails if git has uncommitted changes." - group = "verification" - commandLine("git", "diff", "--quiet", "--exit-code") - } - - val gitTag by registering(Exec::class) { - description = "Tags the local repository with version ${project.version}" - group = PublishingPlugin.PUBLISH_TASK_GROUP - dependsOn(gitIsDirty) - if (isRelease) { - commandLine("git", "tag", "-a", project.version, "-m", "Version ${project.version}") - } - } - - register("deploy") { - description = "Copies all needed files to the $deployDir directory." - group = PublishingPlugin.PUBLISH_TASK_GROUP - dependsOn(clean, wrapper, build, jar) - outputs.dir(deployDir) - inputs.files(copyToDeploy) - mustRunAfter(clean) - } - - register("release") { - description = "Publishes version ${project.version} to local repository." - group = PublishingPlugin.PUBLISH_TASK_GROUP - dependsOn(wrapper, "deploy", gitTag, publishToMavenLocal) - } - -} - -publishing { - publications { - create(publicationName) { - from(components["java"]) - artifact(javadocJar) - pom { - name.set(project.name) - description.set(project.description) - url.set(mavenUrl) - licenses { - license { - name.set("BSD 3-Clause") - url.set("https://opensource.org/licenses/BSD-3-Clause") - } - } - developers { - developer { - id.set("ethauvin") - name.set("Erik C. Thauvin") - email.set("erik@thauvin.net") - url.set("https://erik.thauvin.net/") - } - } - scm { - connection.set("scm:git:https://github.com/$gitHub.git") - developerConnection.set("scm:git:git@github.com:$gitHub.git") - url.set(mavenUrl) - } - issueManagement { - system.set("GitHub") - url.set("$mavenUrl/issues") - } - } - } - } - repositories { - maven { - name = "ossrh" - url = if (project.version.toString().contains("SNAPSHOT")) - uri("https://oss.sonatype.org/content/repositories/snapshots/") else - uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/") - credentials(PasswordCredentials::class) - } - } -} - -signing { - useGpgCmd() - sign(publishing.publications[publicationName]) -} diff --git a/examples/bld/.gitignore b/examples/bld/.gitignore new file mode 100644 index 0000000..a2805aa --- /dev/null +++ b/examples/bld/.gitignore @@ -0,0 +1,55 @@ +.gradle +.DS_Store +build +lib/bld/** +!lib/bld/bld-wrapper.jar +!lib/bld/bld-wrapper.properties +lib/compile/ +lib/runtime/ +lib/standalone/ +lib/test/ + +# IDEA ignores + +# User-specific +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# SonarLint plugin +.idea/sonarlint/ + +# Editor-based Rest Client +.idea/httpRequests \ No newline at end of file diff --git a/examples/bld/.idea/app.iml b/examples/bld/.idea/app.iml new file mode 100644 index 0000000..2c1fe21 --- /dev/null +++ b/examples/bld/.idea/app.iml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/bld/.idea/bld.iml b/examples/bld/.idea/bld.iml new file mode 100644 index 0000000..e63e11e --- /dev/null +++ b/examples/bld/.idea/bld.iml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/bld/.idea/inspectionProfiles/Project_Default.xml b/examples/bld/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..1e01b48 --- /dev/null +++ b/examples/bld/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/examples/bld/.idea/libraries/bld.xml b/examples/bld/.idea/libraries/bld.xml new file mode 100644 index 0000000..cf75013 --- /dev/null +++ b/examples/bld/.idea/libraries/bld.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/bld/.idea/libraries/compile.xml b/examples/bld/.idea/libraries/compile.xml new file mode 100644 index 0000000..9bd86aa --- /dev/null +++ b/examples/bld/.idea/libraries/compile.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/bld/.idea/libraries/runtime.xml b/examples/bld/.idea/libraries/runtime.xml new file mode 100644 index 0000000..2ae5c4b --- /dev/null +++ b/examples/bld/.idea/libraries/runtime.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/bld/.idea/libraries/test.xml b/examples/bld/.idea/libraries/test.xml new file mode 100644 index 0000000..b80486a --- /dev/null +++ b/examples/bld/.idea/libraries/test.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/bld/.idea/misc.xml b/examples/bld/.idea/misc.xml new file mode 100644 index 0000000..ba79751 --- /dev/null +++ b/examples/bld/.idea/misc.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/bld/.idea/modules.xml b/examples/bld/.idea/modules.xml new file mode 100644 index 0000000..55adcb9 --- /dev/null +++ b/examples/bld/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/examples/bld/.idea/runConfigurations/Run Tests.xml b/examples/bld/.idea/runConfigurations/Run Tests.xml new file mode 100644 index 0000000..dd66624 --- /dev/null +++ b/examples/bld/.idea/runConfigurations/Run Tests.xml @@ -0,0 +1,9 @@ + + + + \ No newline at end of file diff --git a/examples/bld/.idea/vcs.xml b/examples/bld/.idea/vcs.xml new file mode 100644 index 0000000..b2bdec2 --- /dev/null +++ b/examples/bld/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/examples/bld/.vscode/launch.json b/examples/bld/.vscode/launch.json new file mode 100644 index 0000000..ee0090e --- /dev/null +++ b/examples/bld/.vscode/launch.json @@ -0,0 +1,11 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "type": "java", + "name": "Run Tests", + "request": "launch", + "mainClass": "com.example.ReadingTimeExampleTest" + } + ] +} diff --git a/examples/bld/.vscode/settings.json b/examples/bld/.vscode/settings.json new file mode 100644 index 0000000..133aa45 --- /dev/null +++ b/examples/bld/.vscode/settings.json @@ -0,0 +1,15 @@ +{ + "java.project.sourcePaths": [ + "src/main/java", + "src/main/resources", + "src/test/java", + "src/bld/java" + ], + "java.configuration.updateBuildConfiguration": "automatic", + "java.project.referencedLibraries": [ + "${HOME}/.bld/dist/bld-1.7.5.jar", + "lib/compile/*.jar", + "lib/runtime/*.jar", + "lib/test/*.jar" + ] +} diff --git a/examples/bld/README.md b/examples/bld/README.md new file mode 100644 index 0000000..8dfed5f --- /dev/null +++ b/examples/bld/README.md @@ -0,0 +1,14 @@ +## Kotlin Example +To compile & run the Kotlin example: + +```text +./bld compile run --args="example.html" +``` + +## Java Example + +To compile & run the Java example: + +```text +./bld compile run-java --args="example.html" +``` diff --git a/examples/bld/bld b/examples/bld/bld new file mode 100755 index 0000000..0057d8f --- /dev/null +++ b/examples/bld/bld @@ -0,0 +1,2 @@ +#!/usr/bin/env sh +java -jar "$(dirname "$0")/lib/bld/bld-wrapper.jar" "$0" --build com.example.ReadingTimeExampleBuild "$@" \ No newline at end of file diff --git a/examples/bld/bld.bat b/examples/bld/bld.bat new file mode 100644 index 0000000..5b69398 --- /dev/null +++ b/examples/bld/bld.bat @@ -0,0 +1,4 @@ +@echo off +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +java -jar "%DIRNAME%/lib/bld/bld-wrapper.jar" "%0" --build com.example.ReadingTimeExampleBuild %* \ No newline at end of file diff --git a/examples/example.html b/examples/bld/example.html similarity index 100% rename from examples/example.html rename to examples/bld/example.html diff --git a/examples/bld/lib/bld/bld-wrapper.jar b/examples/bld/lib/bld/bld-wrapper.jar new file mode 100644 index 0000000..7235eda Binary files /dev/null and b/examples/bld/lib/bld/bld-wrapper.jar differ diff --git a/examples/bld/lib/bld/bld-wrapper.properties b/examples/bld/lib/bld/bld-wrapper.properties new file mode 100644 index 0000000..095b48c --- /dev/null +++ b/examples/bld/lib/bld/bld-wrapper.properties @@ -0,0 +1,7 @@ +bld.downloadExtensionJavadoc=false +bld.downloadExtensionSources=true +bld.extensions=com.uwyn.rife2:bld-kotlin:0.9.0-SNAPSHOT +bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES +bld.downloadLocation= +bld.sourceDirectories= +bld.version=1.7.5 diff --git a/examples/bld/src/bld/java/com/example/ReadingTimeExampleBuild.java b/examples/bld/src/bld/java/com/example/ReadingTimeExampleBuild.java new file mode 100644 index 0000000..aa97d7f --- /dev/null +++ b/examples/bld/src/bld/java/com/example/ReadingTimeExampleBuild.java @@ -0,0 +1,59 @@ +package com.example; + +import rife.bld.BaseProject; +import rife.bld.BuildCommand; +import rife.bld.extension.CompileKotlinOperation; +import rife.bld.extension.CompileKotlinOptions; +import rife.bld.operations.RunOperation; + +import java.util.List; + +import static rife.bld.dependencies.Repository.MAVEN_CENTRAL; +import static rife.bld.dependencies.Repository.MAVEN_LOCAL; +import static rife.bld.dependencies.Scope.compile; + +public class ReadingTimeExampleBuild extends BaseProject { + public ReadingTimeExampleBuild() { + pkg = "com.example"; + name = "ReadingTimeExample"; + version = version(0, 1, 0); + + mainClass = "com.example.ReadingTimeExampleKt"; + + javaRelease = 11; + downloadSources = true; + autoDownloadPurge = true; + repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL); + + scope(compile) + .include(dependency("org.jetbrains.kotlin", "kotlin-stdlib", version(1, 9, 20))) + .include(dependency("net.thauvin.erik", "readingtime", version(0, 9, 2, "SNAPSHOT"))); + } + + public static void main(String[] args) { + new ReadingTimeExampleBuild().start(args); + } + + @Override + public void compile() throws Exception { + new CompileKotlinOperation() + .fromProject(this) + .compileOptions( + new CompileKotlinOptions() + .jdkRelease(javaRelease) + .verbose(true) + ) + .execute(); + + // Also compile the Java source code + super.compile(); + } + + @BuildCommand(value = "run-java", summary = "Runs the Java example") + public void runJava() throws Exception { + new RunOperation() + .fromProject(this) + .mainClass("com.example.ReadingTimeSample") + .execute(); + } +} diff --git a/examples/src/main/java/com/example/ReadingTimeSample.java b/examples/bld/src/main/java/com/example/ReadingTimeSample.java similarity index 100% rename from examples/src/main/java/com/example/ReadingTimeSample.java rename to examples/bld/src/main/java/com/example/ReadingTimeSample.java diff --git a/examples/src/main/kotlin/com/example/ReadingTimeExample.kt b/examples/bld/src/main/kotlin/com/example/ReadingTimeExample.kt similarity index 100% rename from examples/src/main/kotlin/com/example/ReadingTimeExample.kt rename to examples/bld/src/main/kotlin/com/example/ReadingTimeExample.kt diff --git a/examples/bld/src/main/main/java/com/example/ReadingTimeSample.java b/examples/bld/src/main/main/java/com/example/ReadingTimeSample.java new file mode 100644 index 0000000..faaf6a2 --- /dev/null +++ b/examples/bld/src/main/main/java/com/example/ReadingTimeSample.java @@ -0,0 +1,28 @@ +package com.example; + +import net.thauvin.erik.readingtime.ReadingTime; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; + +public class ReadingTimeSample { + public static void main(String[] args) { + if (args.length >= 1) { + final Path text = Path.of(args[0]); + try { + final ReadingTime rt = new ReadingTime(Files.readString(text)); + rt.setPostfix("minute to read"); + rt.setPlural("minutes to read"); + + System.out.println("It will take " + rt.calcReadingTime() + ' ' + ReadingTime.wordCount(rt.getText()) + + " words and " + ReadingTime.imgCount(rt.getText()) + " images at " + rt.getWpm() + + " words per minute."); + } catch (IOException e) { + System.err.println("The file could not be read or found."); + } + } else { + System.err.println("Please specify a file as an argument."); + } + } +} diff --git a/examples/bld/src/main/main/kotlin/com/example/ReadingTimeExample.kt b/examples/bld/src/main/main/kotlin/com/example/ReadingTimeExample.kt new file mode 100644 index 0000000..8563bc6 --- /dev/null +++ b/examples/bld/src/main/main/kotlin/com/example/ReadingTimeExample.kt @@ -0,0 +1,25 @@ +package com.example + +import net.thauvin.erik.readingtime.ReadingTime +import java.io.File + +fun main(args: Array) { + if (args.isNotEmpty()) { + with(File(args[0])) { + if (exists() && canRead()) { + val rt = ReadingTime(readText()) + rt.postfix = "minute to read" + rt.plural = "minutes to read" + + println( + "It will take ${rt.calcReadingTime()} ${ReadingTime.wordCount(rt.text)} words and " + + "${ReadingTime.imgCount(rt.text)} images at ${rt.wpm} words per minute." + ) + } else { + System.err.println("The file could not be read or found.") + } + } + } else { + System.err.println("Please specify a file as an argument.") + } +} diff --git a/examples/.gitattributes b/examples/gradle/.gitattributes similarity index 100% rename from examples/.gitattributes rename to examples/gradle/.gitattributes diff --git a/examples/.gitignore b/examples/gradle/.gitignore similarity index 100% rename from examples/.gitignore rename to examples/gradle/.gitignore diff --git a/.idea/.gitignore b/examples/gradle/.idea/.gitignore similarity index 100% rename from .idea/.gitignore rename to examples/gradle/.idea/.gitignore diff --git a/examples/gradle/.idea/.name b/examples/gradle/.idea/.name new file mode 100644 index 0000000..b726568 --- /dev/null +++ b/examples/gradle/.idea/.name @@ -0,0 +1 @@ +examples \ No newline at end of file diff --git a/.idea/compiler.xml b/examples/gradle/.idea/compiler.xml similarity index 75% rename from .idea/compiler.xml rename to examples/gradle/.idea/compiler.xml index 61a9130..fb7f4a8 100644 --- a/.idea/compiler.xml +++ b/examples/gradle/.idea/compiler.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/examples/gradle/.idea/gradle.xml b/examples/gradle/.idea/gradle.xml new file mode 100644 index 0000000..ce1c62c --- /dev/null +++ b/examples/gradle/.idea/gradle.xml @@ -0,0 +1,16 @@ + + + + + + + \ No newline at end of file diff --git a/examples/gradle/.idea/inspectionProfiles/Project_Default.xml b/examples/gradle/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..1e01b48 --- /dev/null +++ b/examples/gradle/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/examples/gradle/.idea/jarRepositories.xml similarity index 61% rename from .idea/jarRepositories.xml rename to examples/gradle/.idea/jarRepositories.xml index 906fb0a..a529ef2 100644 --- a/.idea/jarRepositories.xml +++ b/examples/gradle/.idea/jarRepositories.xml @@ -11,11 +11,6 @@