├── .github ├── dependabot.yml ├── pull_request_template.md └── workflows │ ├── ci.yml │ ├── release.yml │ └── snapshot.yml ├── .gitignore ├── .mvn └── wrapper │ └── maven-wrapper.properties ├── LICENSE ├── README.md ├── findbugs-exclude.xml ├── mvnw ├── pom.xml └── src ├── conf └── checkstyle-header.txt ├── it ├── integration_tests_Scala3_parent │ └── pom.xml ├── integration_tests_parent │ └── pom.xml ├── test_ScalaMavenPlugin_Scala2_12_JUnit │ ├── invoker.properties │ ├── pom.xml │ ├── src │ │ ├── main │ │ │ └── scala │ │ │ │ └── HelloServiceScala.scala │ │ └── test │ │ │ └── scala │ │ │ └── HelloServiceScalaTest.scala │ └── validate.groovy ├── test_ScalaMavenPlugin_Scala2_12_ScalaTest │ ├── invoker.properties │ ├── pom.xml │ ├── src │ │ ├── main │ │ │ └── scala │ │ │ │ └── HelloServiceScala.scala │ │ └── test │ │ │ └── scala │ │ │ └── HelloServiceScalaTest.scala │ └── validate.groovy ├── test_ScalaMavenPlugin_Scala2_13_JUnit │ ├── invoker.properties │ ├── pom.xml │ ├── src │ │ ├── main │ │ │ └── scala │ │ │ │ └── HelloServiceScala.scala │ │ └── test │ │ │ └── scala │ │ │ └── HelloServiceScalaTest.scala │ └── validate.groovy ├── test_ScalaMavenPlugin_Scala2_13_ScalaTest │ ├── invoker.properties │ ├── pom.xml │ ├── src │ │ ├── main │ │ │ └── scala │ │ │ │ └── HelloServiceScala.scala │ │ └── test │ │ │ └── scala │ │ │ └── HelloServiceScalaTest.scala │ └── validate.groovy ├── test_ScalaMavenPlugin_Scala3_2_Plus_ScalaTest │ ├── invoker.properties │ ├── pom.xml │ ├── src │ │ ├── main │ │ │ └── scala │ │ │ │ └── HelloServiceScala.scala │ │ └── test │ │ │ └── scala │ │ │ └── HelloServiceScalaTest.scala │ └── validate.groovy ├── test_ScalaMavenPlugin_Scala3_2_Plus_ScalaTest_ScalaVersion_Not_Set │ ├── invoker.properties │ ├── pom.xml │ ├── src │ │ ├── main │ │ │ └── scala │ │ │ │ └── HelloServiceScala.scala │ │ └── test │ │ │ └── scala │ │ │ └── HelloServiceScalaTest.scala │ └── validate.groovy ├── test_aggregate │ ├── invoker.properties │ ├── module01 │ │ ├── pom.xml │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── pkg01 │ │ │ │ └── HelloService1.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── pkg01 │ │ │ └── HelloServiceTest.scala │ ├── module02 │ │ ├── pom.xml │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── pkg02 │ │ │ │ └── HelloService2.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── pkg02 │ │ │ └── HelloServiceTest.scala │ ├── module03 │ │ ├── pom.xml │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── pkg03 │ │ │ │ └── HelloService3.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── pkg03 │ │ │ └── HelloServiceTest.scala │ ├── pom.xml │ └── validate.groovy ├── test_aggregate_Scala3 │ ├── invoker.properties │ ├── module01 │ │ ├── pom.xml │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── pkg01 │ │ │ │ └── HelloService1.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── pkg01 │ │ │ └── HelloServiceTest.scala │ ├── pom.xml │ └── validate.groovy ├── test_aggregate_only │ ├── invoker.properties │ ├── module01 │ │ ├── pom.xml │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── pkg01 │ │ │ │ └── HelloService1.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── pkg01 │ │ │ └── HelloServiceTest.scala │ ├── module02 │ │ ├── pom.xml │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── pkg02 │ │ │ │ └── HelloService2.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── pkg02 │ │ │ └── HelloServiceTest.scala │ ├── module03 │ │ ├── pom.xml │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── pkg03 │ │ │ │ └── HelloService3.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── pkg03 │ │ │ └── HelloServiceTest.scala │ ├── pom.xml │ └── validate.groovy ├── test_coverage_minima │ ├── invoker.properties │ ├── module01 │ │ ├── pom.xml │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── pkg01 │ │ │ │ └── HelloService1.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── pkg01 │ │ │ └── HelloServiceTest.scala │ ├── module02 │ │ ├── pom.xml │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ ├── pkg01 │ │ │ │ └── HelloService1.scala │ │ │ │ └── pkg02 │ │ │ │ └── HelloService1.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── pkg01 │ │ │ └── HelloServiceTest.scala │ ├── module03 │ │ ├── pom.xml │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── pkg01 │ │ │ │ └── HelloService1.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── pkg01 │ │ │ └── HelloServiceTest.scala │ ├── pom.xml │ └── validate.groovy ├── test_exclusion │ ├── invoker.properties │ ├── pom.xml │ ├── src │ │ ├── main │ │ │ └── scala │ │ │ │ └── org │ │ │ │ ├── package01 │ │ │ │ └── Package01HelloService.scala │ │ │ │ ├── package02 │ │ │ │ ├── nested02 │ │ │ │ │ └── package02nested02objects.scala │ │ │ │ └── package02objects.scala │ │ │ │ ├── package03 │ │ │ │ ├── Package03ByeService.scala │ │ │ │ ├── Package03HelloService1.scala │ │ │ │ └── Package03HelloService2.scala │ │ │ │ ├── package04 │ │ │ │ └── Package04HelloService.scala │ │ │ │ └── package05 │ │ │ │ └── package05objects.scala │ │ └── test │ │ │ └── scala │ │ │ └── org │ │ │ └── package01 │ │ │ └── Package01HelloServiceTest.scala │ └── validate.groovy ├── test_exclusion_Scala3_3_3 │ ├── invoker.properties │ ├── pom.xml │ ├── src │ │ ├── main │ │ │ └── scala │ │ │ │ └── org │ │ │ │ ├── package01 │ │ │ │ └── Package01HelloService.scala │ │ │ │ ├── package02 │ │ │ │ ├── nested02 │ │ │ │ │ └── package02nested02objects.scala │ │ │ │ └── package02objects.scala │ │ │ │ ├── package03 │ │ │ │ ├── Package03ByeService.scala │ │ │ │ ├── Package03HelloService1.scala │ │ │ │ └── Package03HelloService2.scala │ │ │ │ └── package05 │ │ │ │ └── package05objects.scala │ │ └── test │ │ │ └── scala │ │ │ └── org │ │ │ └── package01 │ │ │ └── Package01HelloServiceTest.scala │ └── validate.groovy ├── test_exclusion_Scala3_3_4 │ ├── invoker.properties │ ├── pom.xml │ ├── src │ │ ├── main │ │ │ └── scala │ │ │ │ └── org │ │ │ │ ├── package01 │ │ │ │ └── Package01HelloService.scala │ │ │ │ ├── package02 │ │ │ │ ├── nested02 │ │ │ │ │ └── package02nested02objects.scala │ │ │ │ └── package02objects.scala │ │ │ │ ├── package03 │ │ │ │ ├── Package03ByeService.scala │ │ │ │ ├── Package03HelloService1.scala │ │ │ │ └── Package03HelloService2.scala │ │ │ │ └── package05 │ │ │ │ └── package05objects.scala │ │ └── test │ │ │ └── scala │ │ │ └── org │ │ │ └── package01 │ │ │ └── Package01HelloServiceTest.scala │ └── validate.groovy ├── test_exclusion_Scala3_4_1 │ ├── invoker.properties │ ├── pom.xml │ ├── src │ │ ├── main │ │ │ └── scala │ │ │ │ └── org │ │ │ │ ├── package01 │ │ │ │ └── Package01HelloService.scala │ │ │ │ ├── package02 │ │ │ │ ├── nested02 │ │ │ │ │ └── package02nested02objects.scala │ │ │ │ └── package02objects.scala │ │ │ │ ├── package03 │ │ │ │ ├── Package03ByeService.scala │ │ │ │ ├── Package03HelloService1.scala │ │ │ │ └── Package03HelloService2.scala │ │ │ │ └── package05 │ │ │ │ └── package05objects.scala │ │ └── test │ │ │ └── scala │ │ │ └── org │ │ │ └── package01 │ │ │ └── Package01HelloServiceTest.scala │ └── validate.groovy ├── test_exclusion_Scala3_4_2 │ ├── invoker.properties │ ├── pom.xml │ ├── src │ │ ├── main │ │ │ └── scala │ │ │ │ └── org │ │ │ │ ├── package01 │ │ │ │ └── Package01HelloService.scala │ │ │ │ ├── package02 │ │ │ │ ├── nested02 │ │ │ │ │ └── package02nested02objects.scala │ │ │ │ └── package02objects.scala │ │ │ │ ├── package03 │ │ │ │ ├── Package03ByeService.scala │ │ │ │ ├── Package03HelloService1.scala │ │ │ │ └── Package03HelloService2.scala │ │ │ │ └── package05 │ │ │ │ └── package05objects.scala │ │ └── test │ │ │ └── scala │ │ │ └── org │ │ │ └── package01 │ │ │ └── Package01HelloServiceTest.scala │ └── validate.groovy ├── test_report_for_some_submodules │ ├── invoker.properties │ ├── module01 │ │ ├── pom.xml │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── pkg01 │ │ │ │ └── HelloService1.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── pkg01 │ │ │ └── HelloServiceTest.scala │ ├── module02 │ │ ├── pom.xml │ │ ├── submodule02_01 │ │ │ ├── pom.xml │ │ │ └── src │ │ │ │ ├── main │ │ │ │ └── scala │ │ │ │ │ └── pkg02_01 │ │ │ │ │ └── HelloService2.scala │ │ │ │ └── test │ │ │ │ └── scala │ │ │ │ └── pkg02_01 │ │ │ │ └── HelloServiceTest.scala │ │ └── submodule02_02 │ │ │ ├── pom.xml │ │ │ └── src │ │ │ ├── main │ │ │ └── scala │ │ │ │ └── pkg02_02 │ │ │ │ └── HelloService2.scala │ │ │ └── test │ │ │ └── scala │ │ │ └── pkg02_02 │ │ │ └── HelloServiceTest.scala │ ├── pom.xml │ └── validate.groovy ├── test_skip_Scala3_1 │ ├── invoker.properties │ ├── pom.xml │ ├── src │ │ ├── main │ │ │ └── scala │ │ │ │ └── HelloServiceScala.scala │ │ └── test │ │ │ └── scala │ │ │ └── HelloServiceScalaTest.scala │ └── validate.groovy └── test_skip_configured │ ├── invoker.properties │ ├── pom.xml │ ├── src │ ├── main │ │ └── scala │ │ │ └── HelloServiceScala.scala │ └── test │ │ └── scala │ │ └── HelloServiceScalaTest.scala │ └── validate.groovy ├── main ├── java │ └── org │ │ └── scoverage │ │ └── plugin │ │ ├── SCoverageCheckMojo.java │ │ ├── SCoverageCheckOnlyMojo.java │ │ ├── SCoverageForkedLifecycleConfigurator.java │ │ ├── SCoverageIntegrationCheckMojo.java │ │ ├── SCoverageIntegrationReportMojo.java │ │ ├── SCoverageIntegrationTestMojo.java │ │ ├── SCoveragePackageMojo.java │ │ ├── SCoveragePostCompileMojo.java │ │ ├── SCoveragePreCompileMojo.java │ │ ├── SCoverageReportMojo.java │ │ ├── SCoverageReportOnlyMojo.java │ │ ├── SCoverageTestMojo.java │ │ └── ScalaVersion.java └── resources │ ├── META-INF │ └── maven │ │ └── lifecycle.xml │ └── scoverage-report.properties ├── site ├── resources │ ├── css │ │ └── site.css │ └── images │ │ └── my-avatar-80.png └── site.xml └── test └── java └── org └── scoverage └── plugin └── ScalaVersionTest.java /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "maven" 4 | directory: "/" 5 | schedule: 6 | interval: "daily" 7 | - package-ecosystem: "github-actions" 8 | directory: "/" 9 | schedule: 10 | interval: "daily" 11 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | ## Motivation 2 | 3 | Explain the why of this pull request. 4 | 5 | ## Checklist 6 | - [ ] Add/Update integration tests in src/it 7 | - [ ] Add/Update documentation in README 8 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - main 7 | push: 8 | branches: 9 | - main 10 | 11 | jobs: 12 | build: 13 | strategy: 14 | matrix: 15 | maven: [ '3.8.8', '3.9.9' ] 16 | java: [ '17', '21' ] 17 | os: [ 'ubuntu-latest', 'windows-latest' ] 18 | runs-on: ${{ matrix.os }} 19 | steps: 20 | - uses: actions/checkout@v4 21 | - name: Set up JDK 22 | uses: actions/setup-java@v4 23 | with: 24 | distribution: 'temurin' 25 | java-version: ${{ matrix.java }} 26 | - name: Set up Maven 27 | uses: stCarolas/setup-maven@v5 28 | with: 29 | maven-version: ${{ matrix.maven }} 30 | - name: print Maven and Java versions 31 | run: mvn --version 32 | - name: Build 33 | run: mvn -ntp -B clean verify 34 | - name: Generate site 35 | run: mvn -ntp -B clean site -P publicsite 36 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release new version 2 | 3 | on: 4 | workflow_dispatch 5 | 6 | jobs: 7 | build: 8 | runs-on: ubuntu-latest 9 | 10 | steps: 11 | - uses: actions/checkout@v4 12 | - uses: webfactory/ssh-agent@v0.9.1 13 | with: 14 | ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} 15 | 16 | - name: Setup git profile 17 | run: | 18 | git config user.name "github-actions[bot]" 19 | git config user.email "41898282+github-actions[bot]@users.noreply.github.com" 20 | 21 | - name: Set up JDK 22 | uses: actions/setup-java@v4 23 | with: 24 | distribution: 'temurin' 25 | java-version: '17' 26 | cache: maven 27 | server-id: central # Value of the distributionManagement/repository/id field of the pom.xml 28 | server-username: SONATYPE_USERNAME 29 | server-password: SONATYPE_PASSWORD 30 | gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} # has to be read directly from secrets 31 | gpg-passphrase: MAVEN_GPG_PASSPHRASE # default name used by maven-gpg-plugin 32 | 33 | - name: Release new version 34 | run: mvn clean -Darguments=-DskipTests -ntp -B release:clean release:prepare release:perform -P release 35 | env: 36 | SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} 37 | SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} 38 | MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} 39 | -------------------------------------------------------------------------------- /.github/workflows/snapshot.yml: -------------------------------------------------------------------------------- 1 | name: Deploy snapshot 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | jobs: 9 | deploy: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v4 13 | - name: Set up JDK 14 | uses: actions/setup-java@v4 15 | with: 16 | distribution: 'temurin' 17 | java-version: '17' 18 | cache: maven 19 | server-id: central # Value of the distributionManagement/repository/id field of the pom.xml 20 | server-username: SONATYPE_USERNAME 21 | server-password: SONATYPE_PASSWORD 22 | gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} # has to be read directly from secrets 23 | gpg-passphrase: MAVEN_GPG_PASSPHRASE # default name used by maven-gpg-plugin 24 | - name: Deploy snapshot 25 | run: mvn -Dmaven.test.skip=true -ntp -B clean deploy -P release 26 | env: 27 | SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} 28 | SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} 29 | MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .settings/ 2 | target/ 3 | .cache 4 | .classpath 5 | .project 6 | pom.xml.tag 7 | pom.xml.releaseBackup 8 | pom.xml.versionsBackup 9 | pom.xml.next 10 | release.properties 11 | .idea/ 12 | *.iml 13 | ./src/site/markdown/README.md -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.6/apache-maven-3.9.6-bin.zip 18 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | -------------------------------------------------------------------------------- /findbugs-exclude.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Apache Maven Wrapper startup batch script, version 3.2.0 23 | # 24 | # Optional ENV vars 25 | # ----------------- 26 | # JAVA_HOME - location of a JDK home dir, required when download maven via java source 27 | # MVNW_REPOURL - repo url base for downloading maven distribution 28 | # MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven 29 | # MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output 30 | # ---------------------------------------------------------------------------- 31 | 32 | set -euf 33 | [ "${MVNW_VERBOSE-}" != debug ] || set -x 34 | 35 | # OS specific support. 36 | native_path() { printf %s\\n "$1"; } 37 | case "$(uname)" in 38 | (CYGWIN*|MINGW*) [ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")" 39 | native_path() { cygpath --path --windows "$1"; } ;; 40 | esac 41 | 42 | # set JAVACMD and JAVACCMD 43 | set_java_home() { 44 | # For Cygwin and MinGW, ensure paths are in Unix format before anything is touched 45 | if [ -n "${JAVA_HOME-}" ] ; then 46 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 47 | # IBM's JDK on AIX uses strange locations for the executables 48 | JAVACMD="$JAVA_HOME/jre/sh/java" 49 | JAVACCMD="$JAVA_HOME/jre/sh/javac" 50 | else 51 | JAVACMD="$JAVA_HOME/bin/java" 52 | JAVACCMD="$JAVA_HOME/bin/javac" 53 | 54 | if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ] ; then 55 | echo "The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run." >&2 56 | echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" or \"\$JAVA_HOME/bin/javac\" does not exist." >&2 57 | return 1 58 | fi 59 | fi 60 | else 61 | JAVACMD="$('set' +e; 'unset' -f command 2>/dev/null; 'command' -v java)" || : 62 | JAVACCMD="$('set' +e; 'unset' -f command 2>/dev/null; 'command' -v javac)" || : 63 | 64 | if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ] ; then 65 | echo "The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run." >&2 66 | return 1 67 | fi 68 | fi 69 | } 70 | 71 | # hash string like Java String::hashCode 72 | hash_string() { 73 | str="${1:-}" h=0 74 | while [ -n "$str" ]; do 75 | h=$(( ( h * 31 + $(LC_CTYPE=C printf %d "'$str") ) % 4294967296 )) 76 | str="${str#?}" 77 | done 78 | printf %x\\n $h 79 | } 80 | 81 | verbose() { :; } 82 | [ "${MVNW_VERBOSE-}" != true ] || verbose() { printf %s\\n "${1-}"; } 83 | 84 | die() { 85 | printf %s\\n "$1" >&2 86 | exit 1 87 | } 88 | 89 | # parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties 90 | while IFS="=" read -r key value; do 91 | case "${key-}" in 92 | distributionUrl) distributionUrl="${value-}" ;; 93 | distributionSha256Sum) distributionSha256Sum="${value-}" ;; 94 | esac 95 | done < "${0%/*}/.mvn/wrapper/maven-wrapper.properties" 96 | [ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in ${0%/*}/.mvn/wrapper/maven-wrapper.properties" 97 | 98 | 99 | case "${distributionUrl##*/}" in 100 | (maven-mvnd-*bin.*) 101 | MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ 102 | case "${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)" in 103 | (*AMD64:CYGWIN*|*AMD64:MINGW*) distributionPlatform=windows-amd64 ;; 104 | (:Darwin*x86_64) distributionPlatform=darwin-amd64 ;; 105 | (:Darwin*arm64) distributionPlatform=darwin-aarch64 ;; 106 | (:Linux*x86_64*) distributionPlatform=linux-amd64 ;; 107 | (*) echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2 108 | distributionPlatform=linux-amd64 109 | ;; 110 | esac 111 | distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip" 112 | ;; 113 | (maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;; 114 | (*) MVN_CMD="mvn${0##*/mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;; 115 | esac 116 | 117 | # apply MVNW_REPOURL and calculate MAVEN_HOME 118 | # maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ 119 | [ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}" 120 | distributionUrlName="${distributionUrl##*/}" 121 | distributionUrlNameMain="${distributionUrlName%.*}" 122 | distributionUrlNameMain="${distributionUrlNameMain%-bin}" 123 | MAVEN_HOME="$HOME/.m2/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")" 124 | 125 | exec_maven() { 126 | unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || : 127 | exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD" 128 | } 129 | 130 | if [ -d "$MAVEN_HOME" ]; then 131 | verbose "found existing MAVEN_HOME at $MAVEN_HOME" 132 | exec_maven "$@" 133 | fi 134 | 135 | case "${distributionUrl-}" in 136 | (*?-bin.zip|*?maven-mvnd-?*-?*.zip) ;; 137 | (*) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;; 138 | esac 139 | 140 | # prepare tmp dir 141 | if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then 142 | clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; } 143 | trap clean HUP INT TERM EXIT 144 | else 145 | die "cannot create temp dir" 146 | fi 147 | 148 | mkdir -p -- "${MAVEN_HOME%/*}" 149 | 150 | # Download and Install Apache Maven 151 | verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." 152 | verbose "Downloading from: $distributionUrl" 153 | verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" 154 | 155 | # select .zip or .tar.gz 156 | if ! command -v unzip >/dev/null; then 157 | distributionUrl="${distributionUrl%.zip}.tar.gz" 158 | distributionUrlName="${distributionUrl##*/}" 159 | fi 160 | 161 | # verbose opt 162 | __MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR='' 163 | [ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v 164 | 165 | # normalize http auth 166 | case "${MVNW_PASSWORD:+has-password}" in 167 | '') MVNW_USERNAME='' MVNW_PASSWORD='' ;; 168 | has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;; 169 | esac 170 | 171 | if [ -z "${MVNW_USERNAME-}" ] && command -v wget > /dev/null; then 172 | verbose "Found wget ... using wget" 173 | wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" 174 | elif [ -z "${MVNW_USERNAME-}" ] && command -v curl > /dev/null; then 175 | verbose "Found curl ... using curl" 176 | curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" 177 | elif set_java_home; then 178 | verbose "Falling back to use Java to download" 179 | javaSource="$TMP_DOWNLOAD_DIR/Downloader.java" 180 | targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName" 181 | cat > "$javaSource" <<-END 182 | public class Downloader extends java.net.Authenticator 183 | { 184 | protected java.net.PasswordAuthentication getPasswordAuthentication() 185 | { 186 | return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() ); 187 | } 188 | public static void main( String[] args ) throws Exception 189 | { 190 | setDefault( new Downloader() ); 191 | java.nio.file.Files.copy( new java.net.URL( args[0] ).openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() ); 192 | } 193 | } 194 | END 195 | # For Cygwin/MinGW, switch paths to Windows format before running javac and java 196 | verbose " - Compiling Downloader.java ..." 197 | "$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" 198 | verbose " - Running Downloader.java ..." 199 | "$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")" 200 | fi 201 | 202 | # If specified, validate the SHA-256 sum of the Maven distribution zip file 203 | if [ -n "${distributionSha256Sum-}" ]; then 204 | distributionSha256Result=false 205 | if [ "$MVN_CMD" = mvnd.sh ]; then 206 | echo "Checksum validation is not supported for maven-mvnd." >&2 207 | echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 208 | exit 1 209 | elif command -v sha256sum > /dev/null; then 210 | if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c > /dev/null 2>&1; then 211 | distributionSha256Result=true 212 | fi 213 | elif command -v shasum > /dev/null; then 214 | if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c > /dev/null 2>&1; then 215 | distributionSha256Result=true 216 | fi 217 | else 218 | echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2 219 | echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 220 | exit 1 221 | fi 222 | if [ $distributionSha256Result = false ]; then 223 | echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2 224 | echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2 225 | exit 1 226 | fi 227 | fi 228 | 229 | # unzip and move 230 | if command -v unzip > /dev/null; then 231 | unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" 232 | else 233 | tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" 234 | fi 235 | printf %s\\n "$distributionUrl" > "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/mvnw.url" 236 | mv -- "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME" 237 | 238 | clean || : 239 | exec_maven "$@" 240 | -------------------------------------------------------------------------------- /src/conf/checkstyle-header.txt: -------------------------------------------------------------------------------- 1 | ^/\*\s*$ 2 | ^ \* Copyright 2014-2024 Grzegorz Slowikowski \(gslowikowski at gmail dot com\)\s*$ 3 | ^ \*\s*$ 4 | ^ \* Licensed under the Apache License, Version 2.0 \(the "License"\);\s*$ 5 | ^ \* you may not use this file except in compliance with the License.\s*$ 6 | ^ \* You may obtain a copy of the License at\s*$ 7 | ^ \*\s*$ 8 | ^ \*\s+http://www\.apache\.org/licenses/LICENSE-2\.0\s*$ 9 | ^ \*\s*$ 10 | ^ \* Unless required by applicable law or agreed to in writing,\s*$ 11 | ^ \* software distributed under the License is distributed on an\s*$ 12 | ^ \* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\s*$ 13 | ^ \* KIND, either express or implied. See the License for the\s*$ 14 | ^ \* specific language governing permissions and limitations\s*$ 15 | ^ \* under the License.\s*$ 16 | ^ \*/\s*$ 17 | ^\s*$ -------------------------------------------------------------------------------- /src/it/integration_tests_Scala3_parent/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 4.0.0 6 | 7 | 8 | it.scoverage-maven-plugin 9 | integration_tests_parent 10 | 1.0-SNAPSHOT 11 | ../integration_tests_parent/pom.xml 12 | 13 | 14 | integration_tests_Scala3_parent 15 | 1.0-SNAPSHOT 16 | pom 17 | Scoverage Plugin Integration Tests for Scala 3 Parent 18 | Scoverage Plugin Integration Tests for Scala 3 Parent 19 | 20 | 21 | 3 22 | 3.5.2 23 | scala3-library_3 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/it/integration_tests_parent/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 4.0.0 6 | 7 | it.scoverage-maven-plugin 8 | integration_tests_parent 9 | 1.0-SNAPSHOT 10 | pom 11 | Scoverage Plugin Integration Tests Parent 12 | Scoverage Plugin Integration Tests Parent 13 | 14 | 15 | 3.6.3 16 | 17 | 18 | 19 | UTF-8 20 | 4.13.2 21 | 3.2.17 22 | 23 | 3.13.0 24 | 3.5.2 25 | 4.9.2 26 | 2.2.0 27 | 3.8.0 28 | 3.21.0 29 | 30 | 2.13 31 | 16 32 | ${scala.compat.version}.${scala.minor.version} 33 | scala-library 34 | 35 | 36 | 37 | 38 | org.scala-lang 39 | ${scala.library.artifact.id} 40 | ${scala.version} 41 | 42 | 43 | 44 | junit 45 | junit 46 | ${junit.version} 47 | test 48 | 49 | 50 | org.scalatest 51 | scalatest_${scala.compat.version} 52 | ${scalatest.version} 53 | test 54 | 55 | 56 | 57 | 58 | src/main/scala 59 | src/test/scala 60 | 61 | 62 | 63 | 64 | org.apache.maven.plugins 65 | maven-compiler-plugin 66 | ${compiler.plugin.version} 67 | 68 | true 69 | true 70 | 71 | 72 | 73 | org.apache.maven.plugins 74 | maven-surefire-plugin 75 | ${surefire.plugin.version} 76 | 77 | 78 | net.alchim31.maven 79 | scala-maven-plugin 80 | ${scala.plugin.version} 81 | 82 | 83 | default-sbt-compile 84 | 85 | compile 86 | testCompile 87 | 88 | 89 | 90 | 91 | 92 | org.apache.maven.plugins 93 | maven-site-plugin 94 | ${site.plugin.version} 95 | 96 | 97 | @project.groupId@ 98 | @project.artifactId@ 99 | @project.version@ 100 | 101 | 102 | org.scalatest 103 | scalatest-maven-plugin 104 | ${scalatest.plugin.version} 105 | 106 | 107 | test 108 | test 109 | 110 | test 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | org.apache.maven.plugins 123 | maven-project-info-reports-plugin 124 | ${project-info-reports.plugin.version} 125 | 126 | 127 | 128 | index 129 | 130 | 131 | 132 | 133 | 134 | 135 | @project.groupId@ 136 | @project.artifactId@ 137 | @project.version@ 138 | 139 | 140 | 141 | report 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | -------------------------------------------------------------------------------- /src/it/test_ScalaMavenPlugin_Scala2_12_JUnit/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals=clean verify site -e -ntp -------------------------------------------------------------------------------- /src/it/test_ScalaMavenPlugin_Scala2_12_JUnit/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 4.0.0 6 | 7 | 8 | it.scoverage-maven-plugin 9 | integration_tests_parent 10 | 1.0-SNAPSHOT 11 | ../integration_tests_parent/pom.xml 12 | 13 | 14 | test_ScalaMavenPlugin_Scala2_12_JUnit 15 | 1.0-SNAPSHOT 16 | jar 17 | Test Scoverage Report using scala-maven-plugin, Scala 2.12 and JUnit 18 | Test Scoverage Report using scala-maven-plugin, Scala 2.12 and JUnit 19 | 20 | 21 | 2.12 22 | 20 23 | 24 | 25 | 26 | 27 | 28 | org.apache.maven.plugins 29 | maven-compiler-plugin 30 | 31 | 32 | net.alchim31.maven 33 | scala-maven-plugin 34 | 35 | 36 | org.apache.maven.plugins 37 | maven-surefire-plugin 38 | 39 | 40 | @project.groupId@ 41 | @project.artifactId@ 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /src/it/test_ScalaMavenPlugin_Scala2_12_JUnit/src/main/scala/HelloServiceScala.scala: -------------------------------------------------------------------------------- 1 | package service 2 | 3 | object HelloServiceScala { 4 | def hello = { "Hello" } 5 | 6 | } 7 | -------------------------------------------------------------------------------- /src/it/test_ScalaMavenPlugin_Scala2_12_JUnit/src/test/scala/HelloServiceScalaTest.scala: -------------------------------------------------------------------------------- 1 | package service 2 | 3 | import org.junit.Test; 4 | import org.junit.Assert.assertEquals 5 | 6 | class HelloServiceScalaTest 7 | { 8 | @Test 9 | def test1() = assertEquals("Hello", HelloServiceScala.hello) 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/it/test_ScalaMavenPlugin_Scala2_12_JUnit/validate.groovy: -------------------------------------------------------------------------------- 1 | try { 2 | 3 | def logFile = new File(basedir, "build.log") 4 | def lines = logFile.readLines() 5 | assert lines.contains("[INFO] Statement coverage.: 100.00%") 6 | assert lines.contains("[INFO] Branch coverage....: 100.00%") 7 | 8 | def scoverageFile = new File(basedir, "target/scoverage.xml") 9 | assert scoverageFile.exists() 10 | 11 | def reportFile = new File(basedir, "target/site/scoverage/index.html") 12 | assert reportFile.exists() 13 | 14 | return true 15 | 16 | } catch (Throwable e) { 17 | e.printStackTrace() 18 | return false 19 | } 20 | -------------------------------------------------------------------------------- /src/it/test_ScalaMavenPlugin_Scala2_12_ScalaTest/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals=clean verify site -e -ntp -------------------------------------------------------------------------------- /src/it/test_ScalaMavenPlugin_Scala2_12_ScalaTest/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 4.0.0 6 | 7 | 8 | it.scoverage-maven-plugin 9 | integration_tests_parent 10 | 1.0-SNAPSHOT 11 | ../integration_tests_parent/pom.xml 12 | 13 | 14 | test_ScalaMavenPlugin_Scala2_12_ScalaTest 15 | 1.0-SNAPSHOT 16 | jar 17 | Test Scoverage Report using scala-maven-plugin, Scala 2.12 and ScalaTest 18 | Test Scoverage Report using scala-maven-plugin, Scala 2.12 and ScalaTest 19 | 20 | 21 | 2.12 22 | 20 23 | 24 | 25 | 26 | 27 | 28 | org.apache.maven.plugins 29 | maven-compiler-plugin 30 | 31 | 32 | net.alchim31.maven 33 | scala-maven-plugin 34 | 35 | 36 | org.scalatest 37 | scalatest-maven-plugin 38 | 39 | 40 | @project.groupId@ 41 | @project.artifactId@ 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /src/it/test_ScalaMavenPlugin_Scala2_12_ScalaTest/src/main/scala/HelloServiceScala.scala: -------------------------------------------------------------------------------- 1 | package service 2 | 3 | object HelloServiceScala { 4 | def hello = { "Hello" } 5 | 6 | } 7 | -------------------------------------------------------------------------------- /src/it/test_ScalaMavenPlugin_Scala2_12_ScalaTest/src/test/scala/HelloServiceScalaTest.scala: -------------------------------------------------------------------------------- 1 | package service 2 | 3 | import org.scalatest.wordspec.AnyWordSpec 4 | 5 | class HelloServiceScalaTest extends AnyWordSpec { 6 | 7 | "HelloService" should { 8 | "say hello" in { 9 | assert(HelloServiceScala.hello == "Hello") 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/it/test_ScalaMavenPlugin_Scala2_12_ScalaTest/validate.groovy: -------------------------------------------------------------------------------- 1 | try { 2 | 3 | def logFile = new File(basedir, "build.log") 4 | def lines = logFile.readLines() 5 | assert lines.contains("[INFO] Statement coverage.: 100.00%") 6 | assert lines.contains("[INFO] Branch coverage....: 100.00%") 7 | 8 | def scoverageFile = new File(basedir, "target/scoverage.xml") 9 | assert scoverageFile.exists() 10 | 11 | def reportFile = new File(basedir, "target/site/scoverage/index.html") 12 | assert reportFile.exists() 13 | 14 | return true 15 | 16 | } catch (Throwable e) { 17 | e.printStackTrace() 18 | return false 19 | } 20 | -------------------------------------------------------------------------------- /src/it/test_ScalaMavenPlugin_Scala2_13_JUnit/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals=clean verify site -e -ntp -------------------------------------------------------------------------------- /src/it/test_ScalaMavenPlugin_Scala2_13_JUnit/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 4.0.0 6 | 7 | 8 | it.scoverage-maven-plugin 9 | integration_tests_parent 10 | 1.0-SNAPSHOT 11 | ../integration_tests_parent/pom.xml 12 | 13 | 14 | test_ScalaMavenPlugin_Scala2_13_JUnit 15 | 1.0-SNAPSHOT 16 | jar 17 | Test Scoverage Report using scala-maven-plugin, Scala 2.13 and JUnit 18 | Test Scoverage Report using scala-maven-plugin, Scala 2.13 and JUnit 19 | 20 | 21 | 22 | 23 | org.apache.maven.plugins 24 | maven-compiler-plugin 25 | 26 | 27 | net.alchim31.maven 28 | scala-maven-plugin 29 | 30 | 31 | org.apache.maven.plugins 32 | maven-surefire-plugin 33 | 34 | 35 | @project.groupId@ 36 | @project.artifactId@ 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /src/it/test_ScalaMavenPlugin_Scala2_13_JUnit/src/main/scala/HelloServiceScala.scala: -------------------------------------------------------------------------------- 1 | package service 2 | 3 | object HelloServiceScala { 4 | def hello = { "Hello" } 5 | 6 | } 7 | -------------------------------------------------------------------------------- /src/it/test_ScalaMavenPlugin_Scala2_13_JUnit/src/test/scala/HelloServiceScalaTest.scala: -------------------------------------------------------------------------------- 1 | package service 2 | 3 | import org.junit.Test; 4 | import org.junit.Assert.assertEquals 5 | 6 | class HelloServiceScalaTest 7 | { 8 | @Test 9 | def test1() = assertEquals("Hello", HelloServiceScala.hello) 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/it/test_ScalaMavenPlugin_Scala2_13_JUnit/validate.groovy: -------------------------------------------------------------------------------- 1 | try { 2 | 3 | def logFile = new File(basedir, "build.log") 4 | def lines = logFile.readLines() 5 | assert lines.contains("[INFO] Statement coverage.: 100.00%") 6 | assert lines.contains("[INFO] Branch coverage....: 100.00%") 7 | 8 | def scoverageFile = new File(basedir, "target/scoverage.xml") 9 | assert scoverageFile.exists() 10 | 11 | def reportFile = new File(basedir, "target/site/scoverage/index.html") 12 | assert reportFile.exists() 13 | 14 | return true 15 | 16 | } catch (Throwable e) { 17 | e.printStackTrace() 18 | return false 19 | } 20 | -------------------------------------------------------------------------------- /src/it/test_ScalaMavenPlugin_Scala2_13_ScalaTest/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals=clean verify site -e -ntp -------------------------------------------------------------------------------- /src/it/test_ScalaMavenPlugin_Scala2_13_ScalaTest/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 4.0.0 6 | 7 | 8 | it.scoverage-maven-plugin 9 | integration_tests_parent 10 | 1.0-SNAPSHOT 11 | ../integration_tests_parent/pom.xml 12 | 13 | 14 | test_ScalaMavenPlugin_Scala2_13_ScalaTest 15 | 1.0-SNAPSHOT 16 | jar 17 | Test Scoverage Report using scala-maven-plugin, Scala 2.13 and ScalaTest 18 | Test Scoverage Report using scala-maven-plugin, Scala 2.13 and ScalaTest 19 | 20 | 21 | 22 | 23 | org.apache.maven.plugins 24 | maven-compiler-plugin 25 | 26 | 27 | net.alchim31.maven 28 | scala-maven-plugin 29 | 30 | 31 | org.scalatest 32 | scalatest-maven-plugin 33 | 34 | 35 | @project.groupId@ 36 | @project.artifactId@ 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /src/it/test_ScalaMavenPlugin_Scala2_13_ScalaTest/src/main/scala/HelloServiceScala.scala: -------------------------------------------------------------------------------- 1 | package service 2 | 3 | object HelloServiceScala { 4 | def hello = { "Hello" } 5 | 6 | } 7 | -------------------------------------------------------------------------------- /src/it/test_ScalaMavenPlugin_Scala2_13_ScalaTest/src/test/scala/HelloServiceScalaTest.scala: -------------------------------------------------------------------------------- 1 | package service 2 | 3 | import org.scalatest.wordspec.AnyWordSpec 4 | 5 | class HelloServiceScalaTest extends AnyWordSpec { 6 | 7 | "HelloService" should { 8 | "say hello" in { 9 | assert(HelloServiceScala.hello == "Hello") 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/it/test_ScalaMavenPlugin_Scala2_13_ScalaTest/validate.groovy: -------------------------------------------------------------------------------- 1 | try { 2 | 3 | def logFile = new File(basedir, "build.log") 4 | def lines = logFile.readLines() 5 | assert lines.contains("[INFO] Statement coverage.: 100.00%") 6 | assert lines.contains("[INFO] Branch coverage....: 100.00%") 7 | 8 | def scoverageFile = new File(basedir, "target/scoverage.xml") 9 | assert scoverageFile.exists() 10 | 11 | def reportFile = new File(basedir, "target/site/scoverage/index.html") 12 | assert reportFile.exists() 13 | 14 | return true 15 | 16 | } catch (Throwable e) { 17 | e.printStackTrace() 18 | return false 19 | } 20 | -------------------------------------------------------------------------------- /src/it/test_ScalaMavenPlugin_Scala3_2_Plus_ScalaTest/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals=clean verify site -e -ntp -------------------------------------------------------------------------------- /src/it/test_ScalaMavenPlugin_Scala3_2_Plus_ScalaTest/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 4.0.0 6 | 7 | 8 | it.scoverage-maven-plugin 9 | integration_tests_Scala3_parent 10 | 1.0-SNAPSHOT 11 | ../integration_tests_Scala3_parent/pom.xml 12 | 13 | 14 | test_ScalaMavenPlugin_Scala3_2_Plus_ScalaTest 15 | 1.0-SNAPSHOT 16 | jar 17 | Test Scoverage Report using scala-maven-plugin, Scala 3.2+ and ScalaTest 18 | Test Scoverage Report using scala-maven-plugin, Scala 3.2+ and ScalaTest 19 | 20 | 21 | 22 | 23 | org.apache.maven.plugins 24 | maven-compiler-plugin 25 | 26 | 27 | net.alchim31.maven 28 | scala-maven-plugin 29 | 30 | 31 | org.scalatest 32 | scalatest-maven-plugin 33 | 34 | 35 | @project.groupId@ 36 | @project.artifactId@ 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /src/it/test_ScalaMavenPlugin_Scala3_2_Plus_ScalaTest/src/main/scala/HelloServiceScala.scala: -------------------------------------------------------------------------------- 1 | package service 2 | 3 | object HelloServiceScala { 4 | def hello = { "Hello" } 5 | 6 | } 7 | -------------------------------------------------------------------------------- /src/it/test_ScalaMavenPlugin_Scala3_2_Plus_ScalaTest/src/test/scala/HelloServiceScalaTest.scala: -------------------------------------------------------------------------------- 1 | package service 2 | 3 | import org.scalatest.wordspec.AnyWordSpec 4 | 5 | class HelloServiceScalaTest extends AnyWordSpec { 6 | 7 | "HelloService" should { 8 | "say hello" in { 9 | assert(HelloServiceScala.hello == "Hello") 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/it/test_ScalaMavenPlugin_Scala3_2_Plus_ScalaTest/validate.groovy: -------------------------------------------------------------------------------- 1 | try { 2 | 3 | def logFile = new File(basedir, "build.log") 4 | def lines = logFile.readLines() 5 | assert lines.contains("[INFO] Statement coverage.: 100.00%") 6 | assert lines.contains("[INFO] Branch coverage....: 100.00%") 7 | 8 | def scoverageFile = new File(basedir, "target/scoverage.xml") 9 | assert scoverageFile.exists() 10 | 11 | def reportFile = new File(basedir, "target/site/scoverage/index.html") 12 | assert reportFile.exists() 13 | 14 | return true 15 | 16 | } catch (Throwable e) { 17 | e.printStackTrace() 18 | return false 19 | } 20 | -------------------------------------------------------------------------------- /src/it/test_ScalaMavenPlugin_Scala3_2_Plus_ScalaTest_ScalaVersion_Not_Set/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals=clean verify site -e -ntp -------------------------------------------------------------------------------- /src/it/test_ScalaMavenPlugin_Scala3_2_Plus_ScalaTest_ScalaVersion_Not_Set/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 4.0.0 6 | 7 | 8 | it.scoverage-maven-plugin 9 | integration_tests_Scala3_parent 10 | 1.0-SNAPSHOT 11 | ../integration_tests_Scala3_parent/pom.xml 12 | 13 | 14 | test_ScalaMavenPlugin_Scala3_2_Plus_ScalaTest_ScalaVersion_Not_Set 15 | 1.0-SNAPSHOT 16 | jar 17 | Test Scoverage Report using scala-maven-plugin, Scala 3.2+ and ScalaTest when scala.version is not set 18 | Test Scoverage Report using scala-maven-plugin, Scala 3.2+ and ScalaTest when scala.version is not set 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | org.scala-lang 27 | ${scala.library.artifact.id} 28 | 3.5.2 29 | 30 | 31 | 32 | 33 | 34 | 35 | org.apache.maven.plugins 36 | maven-compiler-plugin 37 | 38 | 39 | net.alchim31.maven 40 | scala-maven-plugin 41 | 42 | 43 | org.scalatest 44 | scalatest-maven-plugin 45 | 46 | 47 | @project.groupId@ 48 | @project.artifactId@ 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /src/it/test_ScalaMavenPlugin_Scala3_2_Plus_ScalaTest_ScalaVersion_Not_Set/src/main/scala/HelloServiceScala.scala: -------------------------------------------------------------------------------- 1 | package service 2 | 3 | object HelloServiceScala { 4 | def hello = { "Hello" } 5 | 6 | } 7 | -------------------------------------------------------------------------------- /src/it/test_ScalaMavenPlugin_Scala3_2_Plus_ScalaTest_ScalaVersion_Not_Set/src/test/scala/HelloServiceScalaTest.scala: -------------------------------------------------------------------------------- 1 | package service 2 | 3 | import org.scalatest.wordspec.AnyWordSpec 4 | 5 | class HelloServiceScalaTest extends AnyWordSpec { 6 | 7 | "HelloService" should { 8 | "say hello" in { 9 | assert(HelloServiceScala.hello == "Hello") 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/it/test_ScalaMavenPlugin_Scala3_2_Plus_ScalaTest_ScalaVersion_Not_Set/validate.groovy: -------------------------------------------------------------------------------- 1 | try { 2 | 3 | def logFile = new File(basedir, "build.log") 4 | def lines = logFile.readLines() 5 | assert lines.contains("[INFO] Statement coverage.: 100.00%") 6 | assert lines.contains("[INFO] Branch coverage....: 100.00%") 7 | 8 | def scoverageFile = new File(basedir, "target/scoverage.xml") 9 | assert scoverageFile.exists() 10 | 11 | def reportFile = new File(basedir, "target/site/scoverage/index.html") 12 | assert reportFile.exists() 13 | 14 | return true 15 | 16 | } catch (Throwable e) { 17 | e.printStackTrace() 18 | return false 19 | } 20 | -------------------------------------------------------------------------------- /src/it/test_aggregate/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals=clean verify site -e -ntp -------------------------------------------------------------------------------- /src/it/test_aggregate/module01/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | it.scoverage-maven-plugin 7 | test_aggregate 8 | 1.0-SNAPSHOT 9 | ../pom.xml 10 | 11 | 12 | 4.0.0 13 | module01 14 | Test SCoverage Aggregation : Module 1 15 | 16 | -------------------------------------------------------------------------------- /src/it/test_aggregate/module01/src/main/scala/pkg01/HelloService1.scala: -------------------------------------------------------------------------------- 1 | package pkg01 2 | 3 | class HelloService1 4 | { 5 | def hello = 6 | { 7 | "Hello from module 1" 8 | } 9 | 10 | } 11 | 12 | object HelloService1 extends HelloService1 13 | -------------------------------------------------------------------------------- /src/it/test_aggregate/module01/src/test/scala/pkg01/HelloServiceTest.scala: -------------------------------------------------------------------------------- 1 | package pkg01 2 | 3 | import org.junit.Test; 4 | import org.junit.Assert.assertEquals 5 | 6 | class HelloServiceTest 7 | { 8 | @Test 9 | def test1() 10 | { 11 | assertEquals("Hello from module 1", HelloService1.hello) 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/it/test_aggregate/module02/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | it.scoverage-maven-plugin 7 | test_aggregate 8 | 1.0-SNAPSHOT 9 | ../pom.xml 10 | 11 | 12 | 4.0.0 13 | module02 14 | Test SCoverage Aggregation : Module 2 15 | 16 | -------------------------------------------------------------------------------- /src/it/test_aggregate/module02/src/main/scala/pkg02/HelloService2.scala: -------------------------------------------------------------------------------- 1 | package pkg02 2 | 3 | class HelloService2 4 | { 5 | def hello = 6 | { 7 | "Hello from module 2" 8 | } 9 | 10 | } 11 | 12 | object HelloService2 extends HelloService2 13 | -------------------------------------------------------------------------------- /src/it/test_aggregate/module02/src/test/scala/pkg02/HelloServiceTest.scala: -------------------------------------------------------------------------------- 1 | package pkg02 2 | 3 | import org.junit.Test; 4 | import org.junit.Assert.assertEquals 5 | 6 | class HelloServiceTest 7 | { 8 | @Test 9 | def test2() 10 | { 11 | assertEquals("Hello from module 2", HelloService2.hello) 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/it/test_aggregate/module03/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | it.scoverage-maven-plugin 7 | test_aggregate 8 | 1.0-SNAPSHOT 9 | ../pom.xml 10 | 11 | 12 | 4.0.0 13 | module03 14 | Test SCoverage Aggregation : Module 3 15 | 16 | -------------------------------------------------------------------------------- /src/it/test_aggregate/module03/src/main/scala/pkg03/HelloService3.scala: -------------------------------------------------------------------------------- 1 | package pkg03 2 | 3 | class HelloService3 4 | { 5 | def hello = 6 | { 7 | "Hello from module 3" 8 | } 9 | 10 | } 11 | 12 | object HelloService3 extends HelloService3 13 | -------------------------------------------------------------------------------- /src/it/test_aggregate/module03/src/test/scala/pkg03/HelloServiceTest.scala: -------------------------------------------------------------------------------- 1 | package pkg03 2 | 3 | import org.junit.Test; 4 | import org.junit.Assert.assertEquals 5 | 6 | class HelloServiceTest 7 | { 8 | @Test 9 | def test3() 10 | { 11 | assertEquals("Hello from module 3", HelloService3.hello) 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/it/test_aggregate/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 4.0.0 6 | 7 | 8 | it.scoverage-maven-plugin 9 | integration_tests_parent 10 | 1.0-SNAPSHOT 11 | ../integration_tests_parent/pom.xml 12 | 13 | 14 | test_aggregate 15 | 1.0-SNAPSHOT 16 | pom 17 | Test Scoverage aggregation 18 | Test Scoverage aggregation 19 | 20 | 21 | module01 22 | module02 23 | module03 24 | 25 | 26 | 27 | 28 | 29 | org.apache.maven.plugins 30 | maven-compiler-plugin 31 | 32 | 33 | net.alchim31.maven 34 | scala-maven-plugin 35 | 36 | 37 | org.apache.maven.plugins 38 | maven-surefire-plugin 39 | 40 | 41 | @project.groupId@ 42 | @project.artifactId@ 43 | 44 | true 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | @project.groupId@ 54 | @project.artifactId@ 55 | 56 | true 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /src/it/test_aggregate/validate.groovy: -------------------------------------------------------------------------------- 1 | try { 2 | 3 | def module1ScoverageFile = new File(basedir, "module01/target/scoverage.xml") 4 | assert module1ScoverageFile.exists() 5 | 6 | def module1ReportFile = new File(basedir, "module01/target/site/scoverage/index.html") 7 | assert module1ReportFile.exists() 8 | 9 | def module2ScoverageFile = new File(basedir, "module02/target/scoverage.xml") 10 | assert module2ScoverageFile.exists() 11 | 12 | def module2ReportFile = new File(basedir, "module02/target/site/scoverage/index.html") 13 | assert module2ReportFile.exists() 14 | 15 | def module3ScoverageFile = new File(basedir, "module03/target/scoverage.xml") 16 | assert module3ScoverageFile.exists() 17 | 18 | def module3ReportFile = new File(basedir, "module03/target/site/scoverage/index.html") 19 | assert module3ReportFile.exists() 20 | 21 | def aggregatedScoverageFile = new File(basedir, "target/scoverage.xml") 22 | assert aggregatedScoverageFile.exists() 23 | 24 | def aggregatedReportFile = new File(basedir, "target/site/scoverage/index.html") 25 | assert aggregatedReportFile.exists() 26 | 27 | return true 28 | 29 | } catch (Throwable e) { 30 | e.printStackTrace() 31 | return false 32 | } 33 | -------------------------------------------------------------------------------- /src/it/test_aggregate_Scala3/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals=clean verify site -e -ntp -------------------------------------------------------------------------------- /src/it/test_aggregate_Scala3/module01/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | it.scoverage-maven-plugin 8 | test_aggregate_Scala3 9 | 1.0-SNAPSHOT 10 | ../pom.xml 11 | 12 | 13 | 4.0.0 14 | module01 15 | Test Scala 3 Multi-Module: Module 1 16 | 17 | -------------------------------------------------------------------------------- /src/it/test_aggregate_Scala3/module01/src/main/scala/pkg01/HelloService1.scala: -------------------------------------------------------------------------------- 1 | package pkg01 2 | 3 | class HelloService1 4 | { 5 | def hello: String = 6 | { 7 | "Hello from module 1" 8 | } 9 | 10 | } 11 | 12 | object HelloService1 extends HelloService1 13 | -------------------------------------------------------------------------------- /src/it/test_aggregate_Scala3/module01/src/test/scala/pkg01/HelloServiceTest.scala: -------------------------------------------------------------------------------- 1 | package pkg01 2 | 3 | import org.junit.Test; 4 | import org.junit.Assert.assertEquals 5 | 6 | class HelloServiceTest 7 | { 8 | @Test 9 | def test1(): Unit = 10 | { 11 | assertEquals("Hello from module 1", HelloService1.hello) 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/it/test_aggregate_Scala3/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 4.0.0 6 | 7 | 8 | it.scoverage-maven-plugin 9 | integration_tests_Scala3_parent 10 | 1.0-SNAPSHOT 11 | ../integration_tests_Scala3_parent/pom.xml 12 | 13 | 14 | test_aggregate_Scala3 15 | 1.0-SNAPSHOT 16 | pom 17 | Test Scala 3 Multi-Module 18 | Test Scala 3 Multi-Module 19 | 20 | 21 | module01 22 | 23 | 24 | 25 | 26 | 27 | org.apache.maven.plugins 28 | maven-compiler-plugin 29 | 30 | 31 | net.alchim31.maven 32 | scala-maven-plugin 33 | 34 | 35 | org.apache.maven.plugins 36 | maven-surefire-plugin 37 | 38 | 39 | @project.groupId@ 40 | @project.artifactId@ 41 | 42 | true 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | @project.groupId@ 52 | @project.artifactId@ 53 | 54 | true 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /src/it/test_aggregate_Scala3/validate.groovy: -------------------------------------------------------------------------------- 1 | try { 2 | 3 | def module1ScoverageFile = new File(basedir, "module01/target/scoverage.xml") 4 | assert module1ScoverageFile.exists() 5 | 6 | def module1ReportFile = new File(basedir, "module01/target/site/scoverage/index.html") 7 | assert module1ReportFile.exists() 8 | 9 | def aggregatedScoverageFile = new File(basedir, "target/scoverage.xml") 10 | assert aggregatedScoverageFile.exists() 11 | 12 | def aggregatedReportFile = new File(basedir, "target/site/scoverage/index.html") 13 | assert aggregatedReportFile.exists() 14 | 15 | return true 16 | 17 | } catch (Throwable e) { 18 | e.printStackTrace() 19 | return false 20 | } 21 | -------------------------------------------------------------------------------- /src/it/test_aggregate_only/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals=clean verify site -e -ntp -------------------------------------------------------------------------------- /src/it/test_aggregate_only/module01/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | it.scoverage-maven-plugin 7 | test_aggregate_only 8 | 1.0-SNAPSHOT 9 | ../pom.xml 10 | 11 | 12 | 4.0.0 13 | module01 14 | Test SCoverage Only Aggregation : Module 1 15 | 16 | -------------------------------------------------------------------------------- /src/it/test_aggregate_only/module01/src/main/scala/pkg01/HelloService1.scala: -------------------------------------------------------------------------------- 1 | package pkg01 2 | 3 | class HelloService1 4 | { 5 | def hello = 6 | { 7 | "Hello from module 1" 8 | } 9 | 10 | } 11 | 12 | object HelloService1 extends HelloService1 13 | -------------------------------------------------------------------------------- /src/it/test_aggregate_only/module01/src/test/scala/pkg01/HelloServiceTest.scala: -------------------------------------------------------------------------------- 1 | package pkg01 2 | 3 | import org.junit.Test; 4 | import org.junit.Assert.assertEquals 5 | 6 | class HelloServiceTest 7 | { 8 | @Test 9 | def test1() 10 | { 11 | assertEquals("Hello from module 1", HelloService1.hello) 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/it/test_aggregate_only/module02/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | it.scoverage-maven-plugin 7 | test_aggregate_only 8 | 1.0-SNAPSHOT 9 | ../pom.xml 10 | 11 | 12 | 4.0.0 13 | module02 14 | Test SCoverage Only Aggregation : Module 2 15 | 16 | -------------------------------------------------------------------------------- /src/it/test_aggregate_only/module02/src/main/scala/pkg02/HelloService2.scala: -------------------------------------------------------------------------------- 1 | package pkg02 2 | 3 | class HelloService2 4 | { 5 | def hello = 6 | { 7 | "Hello from module 2" 8 | } 9 | 10 | } 11 | 12 | object HelloService2 extends HelloService2 13 | -------------------------------------------------------------------------------- /src/it/test_aggregate_only/module02/src/test/scala/pkg02/HelloServiceTest.scala: -------------------------------------------------------------------------------- 1 | package pkg02 2 | 3 | import org.junit.Test; 4 | import org.junit.Assert.assertEquals 5 | 6 | class HelloServiceTest 7 | { 8 | @Test 9 | def test2() 10 | { 11 | assertEquals("Hello from module 2", HelloService2.hello) 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/it/test_aggregate_only/module03/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | it.scoverage-maven-plugin 7 | test_aggregate_only 8 | 1.0-SNAPSHOT 9 | ../pom.xml 10 | 11 | 12 | 4.0.0 13 | module03 14 | Test SCoverage Only Aggregation : Module 3 15 | 16 | -------------------------------------------------------------------------------- /src/it/test_aggregate_only/module03/src/main/scala/pkg03/HelloService3.scala: -------------------------------------------------------------------------------- 1 | package pkg03 2 | 3 | class HelloService3 4 | { 5 | def hello = 6 | { 7 | "Hello from module 3" 8 | } 9 | 10 | } 11 | 12 | object HelloService3 extends HelloService3 13 | -------------------------------------------------------------------------------- /src/it/test_aggregate_only/module03/src/test/scala/pkg03/HelloServiceTest.scala: -------------------------------------------------------------------------------- 1 | package pkg03 2 | 3 | import org.junit.Test; 4 | import org.junit.Assert.assertEquals 5 | 6 | class HelloServiceTest 7 | { 8 | @Test 9 | def test3() 10 | { 11 | assertEquals("Hello from module 3", HelloService3.hello) 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/it/test_aggregate_only/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 4.0.0 6 | 7 | 8 | it.scoverage-maven-plugin 9 | integration_tests_parent 10 | 1.0-SNAPSHOT 11 | ../integration_tests_parent/pom.xml 12 | 13 | 14 | test_aggregate_only 15 | 1.0-SNAPSHOT 16 | pom 17 | Test Scoverage only aggregation 18 | Test Scoverage only aggregation 19 | 20 | 21 | module01 22 | module02 23 | module03 24 | 25 | 26 | 27 | 28 | 29 | org.apache.maven.plugins 30 | maven-compiler-plugin 31 | 32 | 33 | net.alchim31.maven 34 | scala-maven-plugin 35 | 36 | 37 | org.apache.maven.plugins 38 | maven-surefire-plugin 39 | 40 | 41 | @project.groupId@ 42 | @project.artifactId@ 43 | 44 | true 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | @project.groupId@ 54 | @project.artifactId@ 55 | 56 | true 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /src/it/test_aggregate_only/validate.groovy: -------------------------------------------------------------------------------- 1 | try { 2 | 3 | def module1ScoverageFile = new File(basedir, "module01/target/scoverage.xml") 4 | assert !module1ScoverageFile.exists() 5 | 6 | def module1ReportFile = new File(basedir, "module01/target/site/scoverage/index.html") 7 | assert !module1ReportFile.exists() 8 | 9 | def module2ScoverageFile = new File(basedir, "module02/target/scoverage.xml") 10 | assert !module2ScoverageFile.exists() 11 | 12 | def module2ReportFile = new File(basedir, "module02/target/site/scoverage/index.html") 13 | assert !module2ReportFile.exists() 14 | 15 | def module3ScoverageFile = new File(basedir, "module03/target/scoverage.xml") 16 | assert !module3ScoverageFile.exists() 17 | 18 | def module3ReportFile = new File(basedir, "module03/target/site/scoverage/index.html") 19 | assert !module3ReportFile.exists() 20 | 21 | def aggregatedScoverageFile = new File(basedir, "target/scoverage.xml") 22 | assert aggregatedScoverageFile.exists() 23 | 24 | def aggregatedReportFile = new File(basedir, "target/site/scoverage/index.html") 25 | assert aggregatedReportFile.exists() 26 | 27 | return true 28 | 29 | } catch (Throwable e) { 30 | e.printStackTrace() 31 | return false 32 | } 33 | -------------------------------------------------------------------------------- /src/it/test_coverage_minima/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals=clean scoverage:check site -e -ntp 2 | -------------------------------------------------------------------------------- /src/it/test_coverage_minima/module01/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | it.scoverage-maven-plugin 7 | test_coverage_minima 8 | 1.0-SNAPSHOT 9 | ../pom.xml 10 | 11 | 12 | 4.0.0 13 | module01 14 | Test SCoverage Coverage Minima : Module 1 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/it/test_coverage_minima/module01/src/main/scala/pkg01/HelloService1.scala: -------------------------------------------------------------------------------- 1 | package pkg01 2 | 3 | class HelloService1 4 | { 5 | def hello = 6 | { 7 | "Hello from module 1" 8 | } 9 | 10 | } 11 | 12 | object HelloService1 extends HelloService1 13 | -------------------------------------------------------------------------------- /src/it/test_coverage_minima/module01/src/test/scala/pkg01/HelloServiceTest.scala: -------------------------------------------------------------------------------- 1 | package pkg01 2 | 3 | import org.junit.Test; 4 | import org.junit.Assert.assertEquals 5 | 6 | class HelloServiceTest 7 | { 8 | @Test 9 | def test1() 10 | { 11 | assertEquals("Hello from module 1", HelloService1.hello) 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/it/test_coverage_minima/module02/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | it.scoverage-maven-plugin 7 | test_coverage_minima 8 | 1.0-SNAPSHOT 9 | ../pom.xml 10 | 11 | 12 | 4.0.0 13 | module02 14 | Test SCoverage Coverage Minima : Module 2 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/it/test_coverage_minima/module02/src/main/scala/pkg01/HelloService1.scala: -------------------------------------------------------------------------------- 1 | package pkg01 2 | 3 | class HelloService1 4 | { 5 | def hello = 6 | { 7 | "Hello from module 2" 8 | } 9 | 10 | } 11 | 12 | object HelloService1 extends HelloService1 13 | -------------------------------------------------------------------------------- /src/it/test_coverage_minima/module02/src/main/scala/pkg02/HelloService1.scala: -------------------------------------------------------------------------------- 1 | package pkg02 2 | 3 | class HelloService1 4 | { 5 | def hello = 6 | { 7 | "Hello from module 2" 8 | } 9 | 10 | } 11 | 12 | object HelloService1 extends HelloService1 13 | -------------------------------------------------------------------------------- /src/it/test_coverage_minima/module02/src/test/scala/pkg01/HelloServiceTest.scala: -------------------------------------------------------------------------------- 1 | package pkg01 2 | 3 | import org.junit.Test; 4 | import org.junit.Assert.assertEquals 5 | 6 | class HelloServiceTest 7 | { 8 | @Test 9 | def test1() 10 | { 11 | assertEquals("Hello from module 2", HelloService1.hello) 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/it/test_coverage_minima/module03/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | it.scoverage-maven-plugin 7 | test_coverage_minima 8 | 1.0-SNAPSHOT 9 | ../pom.xml 10 | 11 | 12 | 4.0.0 13 | module03 14 | Test SCoverage Coverage Minima : Module 3 15 | 16 | 17 | 18 | 19 | @project.groupId@ 20 | @project.artifactId@ 21 | 22 | true 23 | 100 24 | 100 25 | 100 26 | 100 27 | 100 28 | 100 29 | 30 | 31 | 32 | 33 | check 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /src/it/test_coverage_minima/module03/src/main/scala/pkg01/HelloService1.scala: -------------------------------------------------------------------------------- 1 | package pkg01 2 | 3 | class HelloService1 4 | { 5 | def hello = 6 | { 7 | "Hello from module 3" 8 | } 9 | 10 | } 11 | 12 | object HelloService1 extends HelloService1 13 | -------------------------------------------------------------------------------- /src/it/test_coverage_minima/module03/src/test/scala/pkg01/HelloServiceTest.scala: -------------------------------------------------------------------------------- 1 | package pkg01 2 | 3 | import org.junit.Test; 4 | import org.junit.Assert.assertEquals 5 | 6 | class HelloServiceTest 7 | { 8 | @Test 9 | def test1() 10 | { 11 | assertEquals("Hello from module 3", HelloService1.hello) 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/it/test_coverage_minima/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 4.0.0 6 | 7 | 8 | it.scoverage-maven-plugin 9 | integration_tests_parent 10 | 1.0-SNAPSHOT 11 | ../integration_tests_parent/pom.xml 12 | 13 | 14 | test_coverage_minima 15 | 1.0-SNAPSHOT 16 | pom 17 | Test Scoverage coverage minima 18 | Test Scoverage coverage minima 19 | 20 | 21 | module01 22 | module02 23 | module03 24 | 25 | 26 | 27 | 28 | 29 | org.apache.maven.plugins 30 | maven-compiler-plugin 31 | 32 | 33 | net.alchim31.maven 34 | scala-maven-plugin 35 | 36 | 37 | org.apache.maven.plugins 38 | maven-surefire-plugin 39 | 40 | 41 | @project.groupId@ 42 | @project.artifactId@ 43 | 44 | true 45 | 95 46 | 90 47 | 90 48 | 85 49 | 85 50 | 80 51 | false 52 | 53 | 54 | 55 | 56 | check 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /src/it/test_coverage_minima/validate.groovy: -------------------------------------------------------------------------------- 1 | def checkModule(logText, module, coverageLog) { 2 | assert new File(basedir, module + "/target/scoverage.xml").exists() 3 | assert new File(basedir, module + "/target/site/scoverage/index.html").exists() 4 | def entry = logText.find { 5 | it.startsWith("scoverage") && 6 | it.contains(":check (default-cli) @ " + module + " ---\n") 7 | } 8 | assert entry != null 9 | assert entry.endsWith(" @ " + module + " ---" + coverageLog.replaceAll("\r\n", "\n") + "[INFO] ") 10 | } 11 | 12 | try { 13 | // check coverage minima 14 | def logText = (new File(basedir, "build.log")).text.replaceAll("\r\n", "\n").split(/\n\[INFO\] \-\-\- /) 15 | 16 | checkModule(logText, "module01", 17 | """ 18 | |[INFO] Coverage is 100%: Statement:Total! 19 | |[INFO] Coverage is 100%: Branch:Total! 20 | |""".stripMargin() 21 | ) 22 | checkModule(logText, "module02", 23 | """ 24 | |[ERROR] Coverage is below minimum [50.00% < 95.00%]: Statement:Total 25 | |[INFO] Coverage is 100%: Branch:Total! 26 | |[ERROR] Coverage is below minimum [0.00% < 90.00%]: Statement:Package:pkg02 27 | |[ERROR] Coverage is below minimum [0.00% < 85.00%]: Branch:Package:pkg02 28 | |[ERROR] Coverage is below minimum [0.00% < 85.00%]: Statement:File:HelloService1.scala 29 | |[ERROR] Coverage is below minimum [0.00% < 80.00%]: Branch:File:HelloService1.scala 30 | |""".stripMargin() 31 | ) 32 | checkModule(logText, "module03", 33 | """ 34 | |[INFO] Coverage is 100%: Statement:Total! 35 | |[INFO] Coverage is 100%: Branch:Total! 36 | |""".stripMargin() 37 | ) 38 | 39 | return true 40 | 41 | } catch (Throwable e) { 42 | e.printStackTrace() 43 | return false 44 | } 45 | -------------------------------------------------------------------------------- /src/it/test_exclusion/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals=clean verify site -e -ntp -------------------------------------------------------------------------------- /src/it/test_exclusion/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 4.0.0 6 | 7 | 8 | it.scoverage-maven-plugin 9 | integration_tests_parent 10 | 1.0-SNAPSHOT 11 | ../integration_tests_parent/pom.xml 12 | 13 | 14 | test_exclusion 15 | 1.0-SNAPSHOT 16 | jar 17 | Test Scoverage exclusion 18 | Test Scoverage exclusion 19 | 20 | 21 | 22 | 23 | org.apache.maven.plugins 24 | maven-compiler-plugin 25 | 26 | 27 | net.alchim31.maven 28 | scala-maven-plugin 29 | 30 | 31 | org.scalatest 32 | scalatest-maven-plugin 33 | 34 | 35 | @project.groupId@ 36 | @project.artifactId@ 37 | 38 | .*package02.*;.*package05 39 | .*Package03HelloService.*;.*Package03ByeService 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /src/it/test_exclusion/src/main/scala/org/package01/Package01HelloService.scala: -------------------------------------------------------------------------------- 1 | package org.package01 2 | 3 | object Package01HelloService { 4 | 5 | // gonna be included in coverage report 6 | def hello: String = "Hello from package01" 7 | 8 | } 9 | -------------------------------------------------------------------------------- /src/it/test_exclusion/src/main/scala/org/package02/nested02/package02nested02objects.scala: -------------------------------------------------------------------------------- 1 | // gonna be excluded from coverage report by package exclusion 2 | package org.package02.nested02 3 | 4 | object ImGonnaBeExcludedCauseImInPackage02Nested02 { 5 | 6 | def hello: String = "Hello from package02.nested02" 7 | 8 | } 9 | 10 | object SameStoryBro { 11 | 12 | def hello: String = "Hello from package02.nested02 again" 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/it/test_exclusion/src/main/scala/org/package02/package02objects.scala: -------------------------------------------------------------------------------- 1 | // gonna be excluded from coverage report by package exclusion 2 | package org.package02 3 | 4 | object ImGonnaBeExcludedCauseImInPackage02 { 5 | 6 | def hello: String = "Hello from package02" 7 | 8 | } 9 | 10 | object SameStoryBro { 11 | 12 | def hello: String = "Hello from package02 again" 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/it/test_exclusion/src/main/scala/org/package03/Package03ByeService.scala: -------------------------------------------------------------------------------- 1 | package org.package03 2 | 3 | object Package03ByeService { 4 | 5 | // gonna be excluded from coverage report by file exclusion 6 | def bye: String = "Bye from package03" 7 | 8 | } 9 | -------------------------------------------------------------------------------- /src/it/test_exclusion/src/main/scala/org/package03/Package03HelloService1.scala: -------------------------------------------------------------------------------- 1 | package org.package03 2 | 3 | object Package03HelloService1 { 4 | 5 | // gonna be excluded from coverage report by file exclusion 6 | def hello: String = "Hello from package03 service 1" 7 | 8 | } 9 | -------------------------------------------------------------------------------- /src/it/test_exclusion/src/main/scala/org/package03/Package03HelloService2.scala: -------------------------------------------------------------------------------- 1 | package org.package03 2 | 3 | object Package03HelloService2 { 4 | 5 | // gonna be excluded from coverage report by file exclusion 6 | def hello: String = "Hello from package03 service 2" 7 | 8 | } 9 | -------------------------------------------------------------------------------- /src/it/test_exclusion/src/main/scala/org/package04/Package04HelloService.scala: -------------------------------------------------------------------------------- 1 | package org.package04 2 | 3 | object Package04HelloService { 4 | 5 | // gonna be excluded from coverage report by code comments below 6 | 7 | // $COVERAGE-OFF$ 8 | def hello: String = "Hello from package04" 9 | // $COVERAGE-ON$ 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/it/test_exclusion/src/main/scala/org/package05/package05objects.scala: -------------------------------------------------------------------------------- 1 | // gonna be excluded from coverage report by package exclusion 2 | package org.package05 3 | 4 | object ImGonnaBeExcludedCauseImInPackage05 { 5 | 6 | def hello: String = "Hello from package05" 7 | 8 | } 9 | 10 | object SameStoryBro { 11 | 12 | def hello: String = "Hello from package05 again" 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/it/test_exclusion/src/test/scala/org/package01/Package01HelloServiceTest.scala: -------------------------------------------------------------------------------- 1 | package org.package01 2 | 3 | import org.scalatest.wordspec.AnyWordSpec 4 | 5 | class Package01HelloServiceTest extends AnyWordSpec { 6 | 7 | "Package01HelloService" should { 8 | "say hello" in { 9 | assert(Package01HelloService.hello == "Hello from package01") 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/it/test_exclusion/validate.groovy: -------------------------------------------------------------------------------- 1 | try { 2 | 3 | def logFile = new File(basedir, "build.log") 4 | def lines = logFile.readLines() 5 | assert lines.contains("[INFO] Statement coverage.: 100.00%") 6 | assert lines.contains("[INFO] Branch coverage....: 100.00%") 7 | 8 | def scoverageFile = new File(basedir, "target/scoverage.xml") 9 | assert scoverageFile.exists() 10 | 11 | def reportFile = new File(basedir, "target/site/scoverage/index.html") 12 | assert reportFile.exists() 13 | 14 | return true 15 | 16 | } catch (Throwable e) { 17 | e.printStackTrace() 18 | return false 19 | } 20 | -------------------------------------------------------------------------------- /src/it/test_exclusion_Scala3_3_3/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals=clean verify site -e -ntp -------------------------------------------------------------------------------- /src/it/test_exclusion_Scala3_3_3/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 4.0.0 6 | 7 | 8 | it.scoverage-maven-plugin 9 | integration_tests_Scala3_parent 10 | 1.0-SNAPSHOT 11 | ../integration_tests_Scala3_parent/pom.xml 12 | 13 | 14 | test_exclusion 15 | 1.0-SNAPSHOT 16 | jar 17 | Test Scoverage exclusion 18 | Test Scoverage exclusion 19 | 20 | 21 | 3.3.3 22 | 23 | 24 | 25 | 26 | 27 | org.apache.maven.plugins 28 | maven-compiler-plugin 29 | 30 | 31 | net.alchim31.maven 32 | scala-maven-plugin 33 | 34 | 35 | org.scalatest 36 | scalatest-maven-plugin 37 | 38 | 39 | @project.groupId@ 40 | @project.artifactId@ 41 | 42 | .*package02.*;.*package05 43 | .*Package03HelloService.*;.*Package03ByeService 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /src/it/test_exclusion_Scala3_3_3/src/main/scala/org/package01/Package01HelloService.scala: -------------------------------------------------------------------------------- 1 | package org.package01 2 | 3 | object Package01HelloService { 4 | 5 | // gonna be included in coverage report 6 | def hello: String = "Hello from package01" 7 | 8 | } 9 | -------------------------------------------------------------------------------- /src/it/test_exclusion_Scala3_3_3/src/main/scala/org/package02/nested02/package02nested02objects.scala: -------------------------------------------------------------------------------- 1 | // gonna be excluded from coverage report by package exclusion 2 | package org.package02.nested02 3 | 4 | object ImGonnaBeExcludedCauseImInPackage02Nested02 { 5 | 6 | def hello: String = "Hello from package02.nested02" 7 | 8 | } 9 | 10 | object SameStoryBro { 11 | 12 | def hello: String = "Hello from package02.nested02 again" 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/it/test_exclusion_Scala3_3_3/src/main/scala/org/package02/package02objects.scala: -------------------------------------------------------------------------------- 1 | // gonna be excluded from coverage report by package exclusion 2 | package org.package02 3 | 4 | object ImGonnaBeExcludedCauseImInPackage02 { 5 | 6 | def hello: String = "Hello from package02" 7 | 8 | } 9 | 10 | object SameStoryBro { 11 | 12 | def hello: String = "Hello from package02 again" 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/it/test_exclusion_Scala3_3_3/src/main/scala/org/package03/Package03ByeService.scala: -------------------------------------------------------------------------------- 1 | package org.package03 2 | 3 | object Package03ByeService { 4 | 5 | // gonna be excluded from coverage report by file exclusion 6 | def bye: String = "Bye from package03" 7 | 8 | } 9 | -------------------------------------------------------------------------------- /src/it/test_exclusion_Scala3_3_3/src/main/scala/org/package03/Package03HelloService1.scala: -------------------------------------------------------------------------------- 1 | package org.package03 2 | 3 | object Package03HelloService1 { 4 | 5 | // gonna be excluded from coverage report by file exclusion 6 | def hello: String = "Hello from package03 service 1" 7 | 8 | } 9 | -------------------------------------------------------------------------------- /src/it/test_exclusion_Scala3_3_3/src/main/scala/org/package03/Package03HelloService2.scala: -------------------------------------------------------------------------------- 1 | package org.package03 2 | 3 | object Package03HelloService2 { 4 | 5 | // gonna be excluded from coverage report by file exclusion 6 | def hello: String = "Hello from package03 service 2" 7 | 8 | } 9 | -------------------------------------------------------------------------------- /src/it/test_exclusion_Scala3_3_3/src/main/scala/org/package05/package05objects.scala: -------------------------------------------------------------------------------- 1 | // gonna be excluded from coverage report by package exclusion 2 | package org.package05 3 | 4 | object ImGonnaBeExcludedCauseImInPackage05 { 5 | 6 | def hello: String = "Hello from package05" 7 | 8 | } 9 | 10 | object SameStoryBro { 11 | 12 | def hello: String = "Hello from package05 again" 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/it/test_exclusion_Scala3_3_3/src/test/scala/org/package01/Package01HelloServiceTest.scala: -------------------------------------------------------------------------------- 1 | package org.package01 2 | 3 | import org.scalatest.wordspec.AnyWordSpec 4 | 5 | class Package01HelloServiceTest extends AnyWordSpec { 6 | 7 | "Package01HelloService" should { 8 | "say hello" in { 9 | assert(Package01HelloService.hello == "Hello from package01") 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/it/test_exclusion_Scala3_3_3/validate.groovy: -------------------------------------------------------------------------------- 1 | try { 2 | 3 | def logFile = new File(basedir, "build.log") 4 | def lines = logFile.readLines() 5 | assert lines.contains("[WARNING] Package exclusion is supported for Scala [3.3.4-3.4.0) or 3.4.2+") 6 | assert lines.contains("[WARNING] File exclusion is supported for Scala [3.3.4-3.4.0) or 3.4.2+") 7 | assert lines.contains("[INFO] Statement coverage.: 10.00%") 8 | 9 | return true 10 | 11 | } catch (Throwable e) { 12 | e.printStackTrace() 13 | return false 14 | } 15 | -------------------------------------------------------------------------------- /src/it/test_exclusion_Scala3_3_4/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals=clean verify site -e -ntp -------------------------------------------------------------------------------- /src/it/test_exclusion_Scala3_3_4/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 4.0.0 6 | 7 | 8 | it.scoverage-maven-plugin 9 | integration_tests_Scala3_parent 10 | 1.0-SNAPSHOT 11 | ../integration_tests_Scala3_parent/pom.xml 12 | 13 | 14 | test_exclusion 15 | 1.0-SNAPSHOT 16 | jar 17 | Test Scoverage exclusion 18 | Test Scoverage exclusion 19 | 20 | 21 | 3.3.4 22 | 23 | 24 | 25 | 26 | 27 | org.apache.maven.plugins 28 | maven-compiler-plugin 29 | 30 | 31 | net.alchim31.maven 32 | scala-maven-plugin 33 | 34 | 35 | org.scalatest 36 | scalatest-maven-plugin 37 | 38 | 39 | @project.groupId@ 40 | @project.artifactId@ 41 | 42 | .*package02.*;.*package05 43 | .*Package03HelloService.*;.*Package03ByeService 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /src/it/test_exclusion_Scala3_3_4/src/main/scala/org/package01/Package01HelloService.scala: -------------------------------------------------------------------------------- 1 | package org.package01 2 | 3 | object Package01HelloService { 4 | 5 | // gonna be included in coverage report 6 | def hello: String = "Hello from package01" 7 | 8 | } 9 | -------------------------------------------------------------------------------- /src/it/test_exclusion_Scala3_3_4/src/main/scala/org/package02/nested02/package02nested02objects.scala: -------------------------------------------------------------------------------- 1 | // gonna be excluded from coverage report by package exclusion 2 | package org.package02.nested02 3 | 4 | object ImGonnaBeExcludedCauseImInPackage02Nested02 { 5 | 6 | def hello: String = "Hello from package02.nested02" 7 | 8 | } 9 | 10 | object SameStoryBro { 11 | 12 | def hello: String = "Hello from package02.nested02 again" 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/it/test_exclusion_Scala3_3_4/src/main/scala/org/package02/package02objects.scala: -------------------------------------------------------------------------------- 1 | // gonna be excluded from coverage report by package exclusion 2 | package org.package02 3 | 4 | object ImGonnaBeExcludedCauseImInPackage02 { 5 | 6 | def hello: String = "Hello from package02" 7 | 8 | } 9 | 10 | object SameStoryBro { 11 | 12 | def hello: String = "Hello from package02 again" 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/it/test_exclusion_Scala3_3_4/src/main/scala/org/package03/Package03ByeService.scala: -------------------------------------------------------------------------------- 1 | package org.package03 2 | 3 | object Package03ByeService { 4 | 5 | // gonna be excluded from coverage report by file exclusion 6 | def bye: String = "Bye from package03" 7 | 8 | } 9 | -------------------------------------------------------------------------------- /src/it/test_exclusion_Scala3_3_4/src/main/scala/org/package03/Package03HelloService1.scala: -------------------------------------------------------------------------------- 1 | package org.package03 2 | 3 | object Package03HelloService1 { 4 | 5 | // gonna be excluded from coverage report by file exclusion 6 | def hello: String = "Hello from package03 service 1" 7 | 8 | } 9 | -------------------------------------------------------------------------------- /src/it/test_exclusion_Scala3_3_4/src/main/scala/org/package03/Package03HelloService2.scala: -------------------------------------------------------------------------------- 1 | package org.package03 2 | 3 | object Package03HelloService2 { 4 | 5 | // gonna be excluded from coverage report by file exclusion 6 | def hello: String = "Hello from package03 service 2" 7 | 8 | } 9 | -------------------------------------------------------------------------------- /src/it/test_exclusion_Scala3_3_4/src/main/scala/org/package05/package05objects.scala: -------------------------------------------------------------------------------- 1 | // gonna be excluded from coverage report by package exclusion 2 | package org.package05 3 | 4 | object ImGonnaBeExcludedCauseImInPackage05 { 5 | 6 | def hello: String = "Hello from package05" 7 | 8 | } 9 | 10 | object SameStoryBro { 11 | 12 | def hello: String = "Hello from package05 again" 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/it/test_exclusion_Scala3_3_4/src/test/scala/org/package01/Package01HelloServiceTest.scala: -------------------------------------------------------------------------------- 1 | package org.package01 2 | 3 | import org.scalatest.wordspec.AnyWordSpec 4 | 5 | class Package01HelloServiceTest extends AnyWordSpec { 6 | 7 | "Package01HelloService" should { 8 | "say hello" in { 9 | assert(Package01HelloService.hello == "Hello from package01") 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/it/test_exclusion_Scala3_3_4/validate.groovy: -------------------------------------------------------------------------------- 1 | try { 2 | 3 | def logFile = new File(basedir, "build.log") 4 | def lines = logFile.readLines() 5 | assert lines.contains("[INFO] Statement coverage.: 100.00%") 6 | assert lines.contains("[INFO] Branch coverage....: 100.00%") 7 | 8 | def scoverageFile = new File(basedir, "target/scoverage.xml") 9 | assert scoverageFile.exists() 10 | 11 | def reportFile = new File(basedir, "target/site/scoverage/index.html") 12 | assert reportFile.exists() 13 | 14 | return true 15 | 16 | } catch (Throwable e) { 17 | e.printStackTrace() 18 | return false 19 | } 20 | -------------------------------------------------------------------------------- /src/it/test_exclusion_Scala3_4_1/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals=clean verify site -e -ntp -------------------------------------------------------------------------------- /src/it/test_exclusion_Scala3_4_1/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 4.0.0 6 | 7 | 8 | it.scoverage-maven-plugin 9 | integration_tests_Scala3_parent 10 | 1.0-SNAPSHOT 11 | ../integration_tests_Scala3_parent/pom.xml 12 | 13 | 14 | test_exclusion 15 | 1.0-SNAPSHOT 16 | jar 17 | Test Scoverage exclusion 18 | Test Scoverage exclusion 19 | 20 | 21 | 3.4.1 22 | 23 | 24 | 25 | 26 | 27 | org.apache.maven.plugins 28 | maven-compiler-plugin 29 | 30 | 31 | net.alchim31.maven 32 | scala-maven-plugin 33 | 34 | 35 | org.scalatest 36 | scalatest-maven-plugin 37 | 38 | 39 | @project.groupId@ 40 | @project.artifactId@ 41 | 42 | .*package02.*;.*package05 43 | .*Package03HelloService.*;.*Package03ByeService 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /src/it/test_exclusion_Scala3_4_1/src/main/scala/org/package01/Package01HelloService.scala: -------------------------------------------------------------------------------- 1 | package org.package01 2 | 3 | object Package01HelloService { 4 | 5 | // gonna be included in coverage report 6 | def hello: String = "Hello from package01" 7 | 8 | } 9 | -------------------------------------------------------------------------------- /src/it/test_exclusion_Scala3_4_1/src/main/scala/org/package02/nested02/package02nested02objects.scala: -------------------------------------------------------------------------------- 1 | // gonna be excluded from coverage report by package exclusion 2 | package org.package02.nested02 3 | 4 | object ImGonnaBeExcludedCauseImInPackage02Nested02 { 5 | 6 | def hello: String = "Hello from package02.nested02" 7 | 8 | } 9 | 10 | object SameStoryBro { 11 | 12 | def hello: String = "Hello from package02.nested02 again" 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/it/test_exclusion_Scala3_4_1/src/main/scala/org/package02/package02objects.scala: -------------------------------------------------------------------------------- 1 | // gonna be excluded from coverage report by package exclusion 2 | package org.package02 3 | 4 | object ImGonnaBeExcludedCauseImInPackage02 { 5 | 6 | def hello: String = "Hello from package02" 7 | 8 | } 9 | 10 | object SameStoryBro { 11 | 12 | def hello: String = "Hello from package02 again" 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/it/test_exclusion_Scala3_4_1/src/main/scala/org/package03/Package03ByeService.scala: -------------------------------------------------------------------------------- 1 | package org.package03 2 | 3 | object Package03ByeService { 4 | 5 | // gonna be excluded from coverage report by file exclusion 6 | def bye: String = "Bye from package03" 7 | 8 | } 9 | -------------------------------------------------------------------------------- /src/it/test_exclusion_Scala3_4_1/src/main/scala/org/package03/Package03HelloService1.scala: -------------------------------------------------------------------------------- 1 | package org.package03 2 | 3 | object Package03HelloService1 { 4 | 5 | // gonna be excluded from coverage report by file exclusion 6 | def hello: String = "Hello from package03 service 1" 7 | 8 | } 9 | -------------------------------------------------------------------------------- /src/it/test_exclusion_Scala3_4_1/src/main/scala/org/package03/Package03HelloService2.scala: -------------------------------------------------------------------------------- 1 | package org.package03 2 | 3 | object Package03HelloService2 { 4 | 5 | // gonna be excluded from coverage report by file exclusion 6 | def hello: String = "Hello from package03 service 2" 7 | 8 | } 9 | -------------------------------------------------------------------------------- /src/it/test_exclusion_Scala3_4_1/src/main/scala/org/package05/package05objects.scala: -------------------------------------------------------------------------------- 1 | // gonna be excluded from coverage report by package exclusion 2 | package org.package05 3 | 4 | object ImGonnaBeExcludedCauseImInPackage05 { 5 | 6 | def hello: String = "Hello from package05" 7 | 8 | } 9 | 10 | object SameStoryBro { 11 | 12 | def hello: String = "Hello from package05 again" 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/it/test_exclusion_Scala3_4_1/src/test/scala/org/package01/Package01HelloServiceTest.scala: -------------------------------------------------------------------------------- 1 | package org.package01 2 | 3 | import org.scalatest.wordspec.AnyWordSpec 4 | 5 | class Package01HelloServiceTest extends AnyWordSpec { 6 | 7 | "Package01HelloService" should { 8 | "say hello" in { 9 | assert(Package01HelloService.hello == "Hello from package01") 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/it/test_exclusion_Scala3_4_1/validate.groovy: -------------------------------------------------------------------------------- 1 | try { 2 | 3 | def logFile = new File(basedir, "build.log") 4 | def lines = logFile.readLines() 5 | assert lines.contains("[WARNING] Package exclusion is supported for Scala [3.3.4-3.4.0) or 3.4.2+") 6 | assert lines.contains("[WARNING] File exclusion is supported for Scala [3.3.4-3.4.0) or 3.4.2+") 7 | assert lines.contains("[INFO] Statement coverage.: 10.00%") 8 | 9 | return true 10 | 11 | } catch (Throwable e) { 12 | e.printStackTrace() 13 | return false 14 | } 15 | -------------------------------------------------------------------------------- /src/it/test_exclusion_Scala3_4_2/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals=clean verify site -e -ntp -------------------------------------------------------------------------------- /src/it/test_exclusion_Scala3_4_2/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 4.0.0 6 | 7 | 8 | it.scoverage-maven-plugin 9 | integration_tests_Scala3_parent 10 | 1.0-SNAPSHOT 11 | ../integration_tests_Scala3_parent/pom.xml 12 | 13 | 14 | test_exclusion 15 | 1.0-SNAPSHOT 16 | jar 17 | Test Scoverage exclusion 18 | Test Scoverage exclusion 19 | 20 | 21 | 3.4.2 22 | 23 | 24 | 25 | 26 | 27 | org.apache.maven.plugins 28 | maven-compiler-plugin 29 | 30 | 31 | net.alchim31.maven 32 | scala-maven-plugin 33 | 34 | 35 | org.scalatest 36 | scalatest-maven-plugin 37 | 38 | 39 | @project.groupId@ 40 | @project.artifactId@ 41 | 42 | .*package02.*;.*package05 43 | .*Package03HelloService.*;.*Package03ByeService 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /src/it/test_exclusion_Scala3_4_2/src/main/scala/org/package01/Package01HelloService.scala: -------------------------------------------------------------------------------- 1 | package org.package01 2 | 3 | object Package01HelloService { 4 | 5 | // gonna be included in coverage report 6 | def hello: String = "Hello from package01" 7 | 8 | } 9 | -------------------------------------------------------------------------------- /src/it/test_exclusion_Scala3_4_2/src/main/scala/org/package02/nested02/package02nested02objects.scala: -------------------------------------------------------------------------------- 1 | // gonna be excluded from coverage report by package exclusion 2 | package org.package02.nested02 3 | 4 | object ImGonnaBeExcludedCauseImInPackage02Nested02 { 5 | 6 | def hello: String = "Hello from package02.nested02" 7 | 8 | } 9 | 10 | object SameStoryBro { 11 | 12 | def hello: String = "Hello from package02.nested02 again" 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/it/test_exclusion_Scala3_4_2/src/main/scala/org/package02/package02objects.scala: -------------------------------------------------------------------------------- 1 | // gonna be excluded from coverage report by package exclusion 2 | package org.package02 3 | 4 | object ImGonnaBeExcludedCauseImInPackage02 { 5 | 6 | def hello: String = "Hello from package02" 7 | 8 | } 9 | 10 | object SameStoryBro { 11 | 12 | def hello: String = "Hello from package02 again" 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/it/test_exclusion_Scala3_4_2/src/main/scala/org/package03/Package03ByeService.scala: -------------------------------------------------------------------------------- 1 | package org.package03 2 | 3 | object Package03ByeService { 4 | 5 | // gonna be excluded from coverage report by file exclusion 6 | def bye: String = "Bye from package03" 7 | 8 | } 9 | -------------------------------------------------------------------------------- /src/it/test_exclusion_Scala3_4_2/src/main/scala/org/package03/Package03HelloService1.scala: -------------------------------------------------------------------------------- 1 | package org.package03 2 | 3 | object Package03HelloService1 { 4 | 5 | // gonna be excluded from coverage report by file exclusion 6 | def hello: String = "Hello from package03 service 1" 7 | 8 | } 9 | -------------------------------------------------------------------------------- /src/it/test_exclusion_Scala3_4_2/src/main/scala/org/package03/Package03HelloService2.scala: -------------------------------------------------------------------------------- 1 | package org.package03 2 | 3 | object Package03HelloService2 { 4 | 5 | // gonna be excluded from coverage report by file exclusion 6 | def hello: String = "Hello from package03 service 2" 7 | 8 | } 9 | -------------------------------------------------------------------------------- /src/it/test_exclusion_Scala3_4_2/src/main/scala/org/package05/package05objects.scala: -------------------------------------------------------------------------------- 1 | // gonna be excluded from coverage report by package exclusion 2 | package org.package05 3 | 4 | object ImGonnaBeExcludedCauseImInPackage05 { 5 | 6 | def hello: String = "Hello from package05" 7 | 8 | } 9 | 10 | object SameStoryBro { 11 | 12 | def hello: String = "Hello from package05 again" 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/it/test_exclusion_Scala3_4_2/src/test/scala/org/package01/Package01HelloServiceTest.scala: -------------------------------------------------------------------------------- 1 | package org.package01 2 | 3 | import org.scalatest.wordspec.AnyWordSpec 4 | 5 | class Package01HelloServiceTest extends AnyWordSpec { 6 | 7 | "Package01HelloService" should { 8 | "say hello" in { 9 | assert(Package01HelloService.hello == "Hello from package01") 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/it/test_exclusion_Scala3_4_2/validate.groovy: -------------------------------------------------------------------------------- 1 | try { 2 | 3 | def logFile = new File(basedir, "build.log") 4 | def lines = logFile.readLines() 5 | assert lines.contains("[INFO] Statement coverage.: 100.00%") 6 | assert lines.contains("[INFO] Branch coverage....: 100.00%") 7 | 8 | def scoverageFile = new File(basedir, "target/scoverage.xml") 9 | assert scoverageFile.exists() 10 | 11 | def reportFile = new File(basedir, "target/site/scoverage/index.html") 12 | assert reportFile.exists() 13 | 14 | return true 15 | 16 | } catch (Throwable e) { 17 | e.printStackTrace() 18 | return false 19 | } 20 | -------------------------------------------------------------------------------- /src/it/test_report_for_some_submodules/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals=clean scoverage:report -e -ntp -pl module01 -pl module02/submodule02_02 -------------------------------------------------------------------------------- /src/it/test_report_for_some_submodules/module01/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | it.scoverage-maven-plugin 7 | test_report_for_some_submodules 8 | 1.0-SNAPSHOT 9 | ../pom.xml 10 | 11 | 12 | 4.0.0 13 | module01 14 | Test Scoverage report works for specified submodules: Module 1 15 | 16 | -------------------------------------------------------------------------------- /src/it/test_report_for_some_submodules/module01/src/main/scala/pkg01/HelloService1.scala: -------------------------------------------------------------------------------- 1 | package pkg01 2 | 3 | class HelloService1 4 | { 5 | def hello = 6 | { 7 | "Hello from module 1" 8 | } 9 | 10 | } 11 | 12 | object HelloService1 extends HelloService1 13 | -------------------------------------------------------------------------------- /src/it/test_report_for_some_submodules/module01/src/test/scala/pkg01/HelloServiceTest.scala: -------------------------------------------------------------------------------- 1 | package pkg01 2 | 3 | import org.junit.Test; 4 | import org.junit.Assert.assertEquals 5 | 6 | class HelloServiceTest 7 | { 8 | @Test 9 | def test1() 10 | { 11 | assertEquals("Hello from module 1", HelloService1.hello) 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/it/test_report_for_some_submodules/module02/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | it.scoverage-maven-plugin 7 | test_report_for_some_submodules 8 | 1.0-SNAPSHOT 9 | ../pom.xml 10 | 11 | 12 | 4.0.0 13 | module02 14 | pom 15 | Test Scoverage report works for specified submodules: Module 2 16 | 17 | 18 | submodule02_01 19 | submodule02_02 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/it/test_report_for_some_submodules/module02/submodule02_01/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | it.scoverage-maven-plugin 7 | module02 8 | 1.0-SNAPSHOT 9 | ../pom.xml 10 | 11 | 12 | 4.0.0 13 | submodule02_01 14 | Test Scoverage report works for specified submodules: SubModule 2_1 15 | 16 | -------------------------------------------------------------------------------- /src/it/test_report_for_some_submodules/module02/submodule02_01/src/main/scala/pkg02_01/HelloService2.scala: -------------------------------------------------------------------------------- 1 | package pkg02_01 2 | 3 | class HelloService2 4 | { 5 | def hello = 6 | { 7 | "Hello from submodule02_01" 8 | } 9 | 10 | } 11 | 12 | object HelloService2 extends HelloService2 13 | -------------------------------------------------------------------------------- /src/it/test_report_for_some_submodules/module02/submodule02_01/src/test/scala/pkg02_01/HelloServiceTest.scala: -------------------------------------------------------------------------------- 1 | package pkg02_01 2 | 3 | import org.junit.Test; 4 | import org.junit.Assert.assertEquals 5 | 6 | class HelloServiceTest 7 | { 8 | @Test 9 | def test2() 10 | { 11 | assertEquals("Hello from submodule02_01", HelloService2.hello) 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/it/test_report_for_some_submodules/module02/submodule02_02/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | it.scoverage-maven-plugin 7 | module02 8 | 1.0-SNAPSHOT 9 | ../pom.xml 10 | 11 | 12 | 4.0.0 13 | submodule02_02 14 | Test Scoverage report works for specified submodules: SubModule 2_2 15 | 16 | -------------------------------------------------------------------------------- /src/it/test_report_for_some_submodules/module02/submodule02_02/src/main/scala/pkg02_02/HelloService2.scala: -------------------------------------------------------------------------------- 1 | package pkg02_02 2 | 3 | class HelloService2 4 | { 5 | def hello = 6 | { 7 | "Hello from submodule02_02" 8 | } 9 | 10 | } 11 | 12 | object HelloService2 extends HelloService2 13 | -------------------------------------------------------------------------------- /src/it/test_report_for_some_submodules/module02/submodule02_02/src/test/scala/pkg02_02/HelloServiceTest.scala: -------------------------------------------------------------------------------- 1 | package pkg02_02 2 | 3 | import org.junit.Test; 4 | import org.junit.Assert.assertEquals 5 | 6 | class HelloServiceTest 7 | { 8 | @Test 9 | def test2() 10 | { 11 | assertEquals("Hello from submodule02_02", HelloService2.hello) 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/it/test_report_for_some_submodules/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 4.0.0 6 | 7 | 8 | it.scoverage-maven-plugin 9 | integration_tests_parent 10 | 1.0-SNAPSHOT 11 | ../integration_tests_parent/pom.xml 12 | 13 | 14 | test_report_for_some_submodules 15 | 1.0-SNAPSHOT 16 | pom 17 | Test Scoverage report works for specified submodules 18 | Test Scoverage report works for specified submodules 19 | 20 | 21 | module01 22 | module02 23 | 24 | 25 | 26 | 27 | 28 | org.apache.maven.plugins 29 | maven-compiler-plugin 30 | 31 | 32 | net.alchim31.maven 33 | scala-maven-plugin 34 | 35 | 36 | org.apache.maven.plugins 37 | maven-surefire-plugin 38 | 39 | 40 | @project.groupId@ 41 | @project.artifactId@ 42 | 43 | true 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | @project.groupId@ 53 | @project.artifactId@ 54 | 55 | true 56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /src/it/test_report_for_some_submodules/validate.groovy: -------------------------------------------------------------------------------- 1 | try { 2 | 3 | def aggregatedScoverageFile = new File(basedir, "target/scoverage.xml") 4 | assert aggregatedScoverageFile.exists() 5 | 6 | def aggregatedReportFile = new File(basedir, "target/site/scoverage/index.html") 7 | assert aggregatedReportFile.exists() 8 | 9 | return true 10 | 11 | } catch (Throwable e) { 12 | e.printStackTrace() 13 | return false 14 | } 15 | -------------------------------------------------------------------------------- /src/it/test_skip_Scala3_1/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals=clean verify site -e -ntp -------------------------------------------------------------------------------- /src/it/test_skip_Scala3_1/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 4.0.0 6 | 7 | 8 | it.scoverage-maven-plugin 9 | integration_tests_parent 10 | 1.0-SNAPSHOT 11 | ../integration_tests_parent/pom.xml 12 | 13 | 14 | test_skip_Scala3_1 15 | 1.0-SNAPSHOT 16 | jar 17 | Test Scoverage is Skipped for Scala 3.1 18 | Test Scoverage is Skipped for Scala 3.1 19 | 20 | 21 | 3 22 | 3.1.0 23 | scala3-library_3 24 | 25 | 26 | 27 | 28 | run 29 | 30 | 17 31 | 32 | 33 | 34 | 35 | org.apache.maven.plugins 36 | maven-compiler-plugin 37 | 38 | 39 | net.alchim31.maven 40 | scala-maven-plugin 41 | 42 | 43 | org.scalatest 44 | scalatest-maven-plugin 45 | 46 | 47 | @project.groupId@ 48 | @project.artifactId@ 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /src/it/test_skip_Scala3_1/src/main/scala/HelloServiceScala.scala: -------------------------------------------------------------------------------- 1 | package service 2 | 3 | object HelloServiceScala { 4 | def hello = { "Hello" } 5 | 6 | } 7 | -------------------------------------------------------------------------------- /src/it/test_skip_Scala3_1/src/test/scala/HelloServiceScalaTest.scala: -------------------------------------------------------------------------------- 1 | package service 2 | 3 | import org.scalatest.wordspec.AnyWordSpec 4 | 5 | class HelloServiceScalaTest extends AnyWordSpec { 6 | 7 | "HelloService" should { 8 | "say hello" in { 9 | assert(HelloServiceScala.hello == "Hello") 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/it/test_skip_Scala3_1/validate.groovy: -------------------------------------------------------------------------------- 1 | try { 2 | 3 | def logFile = new File(basedir, "build.log") 4 | def lines = logFile.readLines() 5 | assert lines.contains("[WARNING] Skipping SCoverage execution - unsupported Scala version \"3.1.0\". Supported Scala versions are 2.12.8+, 2.13.0+ and 3.2.0+ .") 6 | 7 | return true 8 | 9 | } catch (Throwable e) { 10 | e.printStackTrace() 11 | return false 12 | } 13 | -------------------------------------------------------------------------------- /src/it/test_skip_configured/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals=clean scoverage:check site -e -ntp -------------------------------------------------------------------------------- /src/it/test_skip_configured/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 4.0.0 6 | 7 | 8 | it.scoverage-maven-plugin 9 | integration_tests_parent 10 | 1.0-SNAPSHOT 11 | ../integration_tests_parent/pom.xml 12 | 13 | 14 | test_skip_configured 15 | 1.0-SNAPSHOT 16 | jar 17 | Test Scoverage is Skipped when configured 18 | Test Scoverage is Skipped when configured 19 | 20 | 21 | 22 | 23 | org.apache.maven.plugins 24 | maven-compiler-plugin 25 | 26 | 27 | net.alchim31.maven 28 | scala-maven-plugin 29 | 30 | 31 | org.scalatest 32 | scalatest-maven-plugin 33 | 34 | 35 | @project.groupId@ 36 | @project.artifactId@ 37 | 38 | true 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /src/it/test_skip_configured/src/main/scala/HelloServiceScala.scala: -------------------------------------------------------------------------------- 1 | package service 2 | 3 | object HelloServiceScala { 4 | def hello = { "Hello" } 5 | 6 | } 7 | -------------------------------------------------------------------------------- /src/it/test_skip_configured/src/test/scala/HelloServiceScalaTest.scala: -------------------------------------------------------------------------------- 1 | package service 2 | 3 | import org.scalatest.wordspec.AnyWordSpec 4 | 5 | class HelloServiceScalaTest extends AnyWordSpec { 6 | 7 | "HelloService" should { 8 | "say hello" in { 9 | assert(HelloServiceScala.hello == "Hello") 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/it/test_skip_configured/validate.groovy: -------------------------------------------------------------------------------- 1 | try { 2 | 3 | def logFile = new File(basedir, "build.log") 4 | def lines = logFile.readLines() 5 | assert lines.contains("[INFO] Skipping Scoverage execution as configured") 6 | assert !lines.contains("Generating \"SCoverage\" report") 7 | 8 | // let's check main code is also not compiled 9 | def scalaMainSourcesCompilerInfoIndex = lines.findIndexOf { it ==~ /.*:compile \(default-sbt-compile\).*/ } + 1 10 | def scalaMainSourcesCompilerInfo = lines.get(scalaMainSourcesCompilerInfoIndex) 11 | def expectedInfo = "[INFO] Not compiling main sources" 12 | assert scalaMainSourcesCompilerInfo.contains(expectedInfo) : "Expected '$expectedInfo' but got: '$scalaMainSourcesCompilerInfo'" 13 | 14 | return true 15 | 16 | } catch (Throwable e) { 17 | e.printStackTrace() 18 | return false 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/org/scoverage/plugin/SCoverageCheckMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2024 Grzegorz Slowikowski (gslowikowski at gmail dot com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, 11 | * software distributed under the License is distributed on an 12 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 13 | * KIND, either express or implied. See the License for the 14 | * specific language governing permissions and limitations 15 | * under the License. 16 | */ 17 | 18 | package org.scoverage.plugin; 19 | 20 | import java.io.File; 21 | import java.util.Arrays; 22 | import java.util.List; 23 | import java.util.function.Function; 24 | import java.util.function.Predicate; 25 | 26 | import org.apache.maven.plugin.AbstractMojo; 27 | import org.apache.maven.plugin.MojoFailureException; 28 | import org.apache.maven.plugin.logging.Log; 29 | import org.apache.maven.plugins.annotations.Execute; 30 | import org.apache.maven.plugins.annotations.LifecyclePhase; 31 | import org.apache.maven.plugins.annotations.Mojo; 32 | import org.apache.maven.plugins.annotations.Parameter; 33 | import org.apache.maven.project.MavenProject; 34 | 35 | import scala.Tuple2; 36 | import scala.jdk.javaapi.CollectionConverters; 37 | 38 | import scoverage.domain.Coverage; 39 | import scoverage.domain.CoverageMetrics; 40 | import scoverage.domain.DoubleFormat; 41 | import scoverage.domain.MeasuredFile; 42 | import scoverage.domain.MeasuredPackage; 43 | import scoverage.reporter.IOUtils; 44 | import scoverage.serialize.Serializer; 45 | 46 | /** 47 | * Checks if minimum code coverage by unit tests reached 48 | * in forked {@code scoverage} life cycle. 49 | *
50 | *
51 | * In forked {@code scoverage} life cycle project is compiled with SCoverage instrumentation 52 | * and unit tests are executed before checking. 53 | *
54 | * 55 | * @author Grzegorz Slowikowski 56 | * @since 1.0.0 57 | */ 58 | @Mojo( name = "check", threadSafe = false ) 59 | @Execute( lifecycle = "scoverage", phase = LifecyclePhase.TEST ) 60 | public class SCoverageCheckMojo 61 | extends AbstractMojo 62 | { 63 | 64 | /** 65 | * Allows SCoverage to be skipped. 66 | *
67 | * 68 | * @since 1.0.0 69 | */ 70 | @Parameter( property = "scoverage.skip", defaultValue = "false" ) 71 | private boolean skip; 72 | 73 | /** 74 | * Directory where the coverage files should be written. 75 | */ 76 | @Parameter( property = "scoverage.dataDirectory", defaultValue = "${project.build.directory}/scoverage-data", required = true, readonly = true ) 77 | private File dataDirectory; 78 | 79 | /** 80 | * Required minimum total statement coverage. 81 | *
82 | *
83 | * See https://github.com/scoverage/sbt-scoverage#minimum-coverage for additional documentation. 84 | *
85 | * 86 | * @since 1.0.0 87 | */ 88 | @Parameter( property = "scoverage.minimumCoverage", defaultValue = "0" ) 89 | private Double minimumCoverage; 90 | 91 | /** 92 | * Required minimum total branch coverage. 93 | *
94 | *
95 | * See https://github.com/scoverage/sbt-scoverage#minimum-coverage for additional documentation. 96 | *
97 | * 98 | * @since 2.0.1 99 | */ 100 | @Parameter( property = "scoverage.minimumCoverageBranchTotal", defaultValue = "0" ) 101 | private Double minimumCoverageBranchTotal; 102 | 103 | /** 104 | * Required minimum per-package statement coverage. 105 | *
106 | *
107 | * See https://github.com/scoverage/sbt-scoverage#minimum-coverage for additional documentation. 108 | *
109 | * 110 | * @since 2.0.1 111 | */ 112 | @Parameter( property = "scoverage.minimumCoverageStmtPerPackage", defaultValue = "0" ) 113 | private Double minimumCoverageStmtPerPackage; 114 | 115 | /** 116 | * Required minimum per-package branch coverage. 117 | *
118 | *
119 | * See https://github.com/scoverage/sbt-scoverage#minimum-coverage for additional documentation. 120 | *
121 | * 122 | * @since 2.0.1 123 | */ 124 | @Parameter( property = "scoverage.minimumCoverageBranchPerPackage", defaultValue = "0" ) 125 | private Double minimumCoverageBranchPerPackage; 126 | 127 | /** 128 | * Required minimum per-file statement coverage. 129 | *
130 | *
131 | * See https://github.com/scoverage/sbt-scoverage#minimum-coverage for additional documentation. 132 | *
133 | * 134 | * @since 2.0.1 135 | */ 136 | @Parameter( property = "scoverage.minimumCoverageStmtPerFile", defaultValue = "0" ) 137 | private Double minimumCoverageStmtPerFile; 138 | 139 | /** 140 | * Required minimum per-file branch coverage. 141 | *
142 | *
143 | * See https://github.com/scoverage/sbt-scoverage#minimum-coverage for additional documentation. 144 | *
145 | * 146 | * @since 2.0.1 147 | */ 148 | @Parameter( property = "scoverage.minimumCoverageBranchPerFile", defaultValue = "0" ) 149 | private Double minimumCoverageBranchPerFile; 150 | 151 | /** 152 | * Fail the build if minimum coverage was not reached. 153 | *
154 | *
155 | * See https://github.com/scoverage/sbt-scoverage#minimum-coverage for additional documentation. 156 | *
157 | * 158 | * @since 1.0.0 159 | */ 160 | @Parameter( property = "scoverage.failOnMinimumCoverage", defaultValue = "false" ) 161 | private boolean failOnMinimumCoverage; 162 | 163 | /** 164 | * The file encoding to use when reading Scala sources. 165 | *
166 | * 167 | * @since 1.4.12 168 | */ 169 | @Parameter( property = "encoding", defaultValue = "${project.build.sourceEncoding}" ) 170 | private String encoding; 171 | 172 | /** 173 | * Maven project to interact with. 174 | */ 175 | @Parameter( defaultValue = "${project}", readonly = true, required = true ) 176 | private MavenProject project; 177 | 178 | /** 179 | * All Maven projects in the reactor. 180 | */ 181 | @Parameter( defaultValue = "${reactorProjects}", required = true, readonly = true ) 182 | private List reactorProjects; 183 | 184 | /** 185 | * Checks tests coverage and optionally fails the build if minimum level not reached. 186 | * 187 | * @throws MojoFailureException if coverage is below minimumCoverage and failOnMinimumCoverage option set 188 | */ 189 | @Override 190 | public void execute() throws MojoFailureException 191 | { 192 | if ( "pom".equals( project.getPackaging() ) ) 193 | { 194 | getLog().info( "Skipping SCoverage execution for project with packaging type 'pom'" ); 195 | //for aggragetor mojo - list of submodules: List modules = project.getCollectedProjects(); 196 | return; 197 | } 198 | 199 | if ( skip ) 200 | { 201 | getLog().info( "Skipping Scoverage execution" ); 202 | return; 203 | } 204 | 205 | long ts = System.currentTimeMillis(); 206 | 207 | SCoverageForkedLifecycleConfigurator.afterForkedLifecycleExit( project, reactorProjects ); 208 | 209 | if ( !dataDirectory.exists() || !dataDirectory.isDirectory() ) 210 | { 211 | getLog().info( "Cannot perform check, instrumentation not performed - skipping" ); 212 | return; 213 | } 214 | 215 | File coverageFile = Serializer.coverageFile( dataDirectory ); 216 | if ( !coverageFile.exists() ) 217 | { 218 | getLog().info( "Scoverage data file does not exist. Skipping check" ); 219 | return; 220 | } 221 | if ( !coverageFile.isFile() ) 222 | { 223 | getLog().info( "Scoverage data file is a directory, not a file. Skipping check" ); 224 | return; 225 | } 226 | 227 | Coverage coverage = Serializer.deserialize( coverageFile, project.getBasedir() ); 228 | List measurementFiles = Arrays.asList( IOUtils.findMeasurementFiles( dataDirectory ) ); 229 | scala.collection.Set> measurements = 230 | IOUtils.invoked( CollectionConverters.asScala( measurementFiles ).toSeq(), encoding ); 231 | coverage.apply( measurements ); 232 | 233 | int branchCount = coverage.branchCount(); 234 | int statementCount = coverage.statementCount(); 235 | int invokedBranchesCount = coverage.invokedBranchesCount(); 236 | int invokedStatementCount = coverage.invokedStatementCount(); 237 | 238 | getLog().debug( String.format( "invokedBranchesCount:%d / branchCount:%d, invokedStatementCount:%d / statementCount:%d", 239 | invokedBranchesCount, branchCount, invokedStatementCount, statementCount ) ); 240 | 241 | boolean ok = checkCoverage( getLog(), "Total", coverage, 242 | minimumCoverage, minimumCoverageBranchTotal, true ); 243 | ok = checkCoverage( getLog(), "Package:", coverage.packages(), MeasuredPackage::name, 244 | minimumCoverageStmtPerPackage, minimumCoverageBranchPerPackage ) && ok; 245 | ok = checkCoverage( getLog(), "File:", coverage.files(), MeasuredFile::filename, 246 | minimumCoverageStmtPerFile, minimumCoverageBranchPerFile ) && ok; 247 | 248 | if ( !ok && failOnMinimumCoverage ) 249 | { 250 | throw new MojoFailureException( "Coverage minimum was not reached" ); 251 | } 252 | 253 | long te = System.currentTimeMillis(); 254 | getLog().debug( String.format( "Mojo execution time: %d ms", te - ts ) ); 255 | } 256 | 257 | // Private utility methods 258 | 259 | private static boolean is100( Double d ) 260 | { 261 | return Math.abs( 100 - d ) <= 0.00001d; 262 | } 263 | 264 | private static 265 | boolean checkCoverage( Log logger, String metricPrefix, 266 | scala.collection.Iterable< T > metrics, 267 | Function< T, String > toName, 268 | double minStmt, double minBranch ) 269 | { 270 | return minStmt <= 0 && minBranch <= 0 || checkAll(metrics, cov -> 271 | checkCoverage(logger, metricPrefix + toName.apply(cov), cov, minStmt, minBranch, false) 272 | ); 273 | } 274 | 275 | private static boolean checkCoverage( Log logger, String metric, CoverageMetrics metrics, 276 | double minStmt, double minBranch, boolean logSuccessInfo ) 277 | { 278 | boolean stmt = checkCoverage( logger, "Statement:" + metric, 279 | minStmt, metrics.statementCoveragePercent(), logSuccessInfo ); 280 | boolean branch = checkCoverage( logger, "Branch:" + metric, 281 | minBranch, metrics.branchCoveragePercent(), logSuccessInfo ); 282 | return stmt && branch; 283 | } 284 | 285 | private static boolean checkCoverage( Log logger, String metric, 286 | double minimum, double actual, boolean logSuccessInfo ) 287 | { 288 | if ( minimum <= 0 ) 289 | { 290 | return true; 291 | } 292 | 293 | if ( is100( actual ) ) 294 | { 295 | logSuccess( logger, String.format( "Coverage is 100%%: %s!", metric ), logSuccessInfo ); 296 | return true; 297 | } 298 | 299 | String minimumFormatted = DoubleFormat.twoFractionDigits( minimum ); 300 | String actualFormatted = DoubleFormat.twoFractionDigits( actual ); 301 | boolean ok = minimum <= actual; 302 | 303 | if ( ok ) 304 | { 305 | String message = String.format( "Coverage is above minimum [%s%% >= %s%%]: %s", 306 | actualFormatted, minimumFormatted, metric ); 307 | logSuccess( logger, message, logSuccessInfo ); 308 | } 309 | else 310 | { 311 | String message = String.format( "Coverage is below minimum [%s%% < %s%%]: %s", 312 | actualFormatted, minimumFormatted, metric ); 313 | logger.error( message ); 314 | } 315 | 316 | return ok; 317 | } 318 | 319 | private static void logSuccess( Log logger, String message, boolean logSuccessInfo ) 320 | { 321 | if ( logSuccessInfo ) 322 | { 323 | logger.info( message ); 324 | } 325 | else 326 | { 327 | logger.debug( message ); 328 | } 329 | } 330 | 331 | private static boolean checkAll( scala.collection.Iterable iterable, Predicate predicate ) 332 | { 333 | boolean ok = true; 334 | for ( T elem : CollectionConverters.asJava( iterable ) ) 335 | { 336 | ok = predicate.test( elem ) && ok; 337 | } 338 | return ok; 339 | } 340 | 341 | } 342 | -------------------------------------------------------------------------------- /src/main/java/org/scoverage/plugin/SCoverageCheckOnlyMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2024 Grzegorz Slowikowski (gslowikowski at gmail dot com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, 11 | * software distributed under the License is distributed on an 12 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 13 | * KIND, either express or implied. See the License for the 14 | * specific language governing permissions and limitations 15 | * under the License. 16 | */ 17 | 18 | package org.scoverage.plugin; 19 | 20 | import org.apache.maven.plugins.annotations.Execute; 21 | import org.apache.maven.plugins.annotations.LifecyclePhase; 22 | import org.apache.maven.plugins.annotations.Mojo; 23 | 24 | /** 25 | * Checks if coverage minimum reached without forking {@code scoverage} life cycle. 26 | *
27 | *
28 | * Check is performed using available SCoverage data, 29 | * for example generated by {@link SCoverageCheckMojo} (or {@link SCoverageReportMojo}) 30 | * earlier in the build (or in previous build if it was not cleaned afterwards). 31 | *
32 | * 33 | * @author Grzegorz Slowikowski 34 | * @since 1.0.0 35 | */ 36 | @Mojo( name = "check-only" ) 37 | @Execute( phase = LifecyclePhase.NONE ) 38 | public class SCoverageCheckOnlyMojo 39 | extends SCoverageCheckMojo 40 | { 41 | } -------------------------------------------------------------------------------- /src/main/java/org/scoverage/plugin/SCoverageForkedLifecycleConfigurator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2024 Grzegorz Slowikowski (gslowikowski at gmail dot com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, 11 | * software distributed under the License is distributed on an 12 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 13 | * KIND, either express or implied. See the License for the 14 | * specific language governing permissions and limitations 15 | * under the License. 16 | */ 17 | 18 | package org.scoverage.plugin; 19 | 20 | import java.io.File; 21 | import java.util.List; 22 | import java.util.Map; 23 | 24 | import org.apache.maven.project.MavenProject; 25 | 26 | /** 27 | * Configures project and dependent modules in multi-module project when entering forked {@code scoverage} 28 | * life cycle and restores original configuration after leaving it. 29 | *
30 | * In default life cycle modules use: 31 | *
    32 | *
  • 33 | * {@code ${project.build.directory}/classes} as {@code project.outputDirectory} property value, 34 | *
  • 35 | *
  • 36 | * {@code ${project.build.directory}/${project.finalName}.jar} as {@code project.artifact.file} property value. 37 | *
  • 38 | *
39 | *
40 | * In forked {@code scoverage} life cycle modules use: 41 | *
    42 | *
  • 43 | * {@code ${project.build.directory}/scoverage-classes} as {@code project.outputDirectory} property value, 44 | *
  • 45 | *
  • 46 | * {@code ${project.build.directory}/scoverage-${project.finalName}.jar} as {@code project.artifact.file} property value. 47 | *
  • 48 | *
49 | * 50 | * @author Grzegorz Slowikowski 51 | */ 52 | public class SCoverageForkedLifecycleConfigurator 53 | { 54 | private final static String PROP_ORIG_OUTPUT_DIRECTORY = "_scoverage.original.outputDirectory"; 55 | private final static String PROP_ORIG_ARTIFACT_FILE = "_scoverage.original.artifactFile"; 56 | 57 | private final static String PROP_FORKED_OUTPUT_DIRECTORY = "_scoverage.forked.outputDirectory"; 58 | private final static String PROP_FORKED_ARTIFACT_FILE = "_scoverage.forked.artifactFile"; 59 | 60 | /** 61 | * Configures project and dependent modules in multi-module project when entering forked {@code scoverage} 62 | * life cycle. 63 | * 64 | * @param project Maven project in {@code scoverage} forked life cycle. 65 | * @param reactorProjects all reactor Maven projects. 66 | * @param additionalProjectPropertiesMap additional project properties to set. 67 | */ 68 | public static void afterForkedLifecycleEnter( MavenProject project, List reactorProjects, 69 | Map additionalProjectPropertiesMap ) 70 | { 71 | File classesDirectory = new File( project.getBuild().getOutputDirectory() ); 72 | File scoverageClassesDirectory = 73 | new File( classesDirectory.getParentFile(), "scoverage-" + classesDirectory.getName() ); 74 | 75 | project.getArtifact().setFile( null ); 76 | project.getBuild().setOutputDirectory( scoverageClassesDirectory.getAbsolutePath() ); 77 | 78 | if ( additionalProjectPropertiesMap != null ) 79 | { 80 | for ( Map.Entry entry: additionalProjectPropertiesMap.entrySet() ) 81 | { 82 | project.getProperties().put( entry.getKey(), entry.getValue() ); 83 | } 84 | } 85 | 86 | for ( MavenProject reactorProject : reactorProjects ) 87 | { 88 | if ( reactorProject != project ) 89 | { 90 | if ( reactorProject.getProperties().containsKey( PROP_FORKED_OUTPUT_DIRECTORY ) ) 91 | { 92 | String forkedOutputDirectory = 93 | (String) reactorProject.getProperties().remove/* get */( PROP_FORKED_OUTPUT_DIRECTORY ); 94 | reactorProject.getProperties().put( PROP_ORIG_OUTPUT_DIRECTORY, 95 | reactorProject.getBuild().getOutputDirectory() ); 96 | reactorProject.getBuild().setOutputDirectory( forkedOutputDirectory ); 97 | } 98 | 99 | if ( reactorProject.getProperties().containsKey( PROP_FORKED_ARTIFACT_FILE ) ) 100 | { 101 | String forkedArtifactFilePath = 102 | (String) reactorProject.getProperties().remove/* get */( PROP_FORKED_ARTIFACT_FILE ); 103 | File originalArtifactFile = reactorProject.getArtifact().getFile(); 104 | reactorProject.getProperties().put( PROP_ORIG_ARTIFACT_FILE, 105 | originalArtifactFile == null ? "" 106 | : originalArtifactFile.getAbsolutePath() ); 107 | reactorProject.getArtifact().setFile( "".equals( forkedArtifactFilePath ) ? null 108 | : new File( forkedArtifactFilePath ) ); 109 | } 110 | } 111 | } 112 | } 113 | 114 | /** 115 | * Restores original configuration after leaving forked {@code scoverage} life cycle. 116 | *
117 | * {@code project} is a project in default life cycle, {@code project.getExecutionProject()} 118 | * is a project in just finished forked {@code scoverage} life cycle. 119 | * 120 | * @param project Maven project in default life cycle. 121 | * @param reactorProjects all reactor Maven projects. 122 | */ 123 | public static void afterForkedLifecycleExit( MavenProject project, List reactorProjects ) 124 | { 125 | String forkedOutputDirectory = project.getExecutionProject().getBuild().getOutputDirectory(); 126 | project.getProperties().put( PROP_FORKED_OUTPUT_DIRECTORY, forkedOutputDirectory ); 127 | 128 | File forkedArtifactFile = project.getExecutionProject().getArtifact().getFile(); 129 | project.getProperties().put( PROP_FORKED_ARTIFACT_FILE, 130 | forkedArtifactFile != null ? forkedArtifactFile.getAbsolutePath() : "" ); 131 | 132 | // Restore changed outputDirectory and artifact.file in other reactor projects 133 | for ( MavenProject reactorProject : reactorProjects ) 134 | { 135 | if ( reactorProject != project ) 136 | { 137 | if ( reactorProject.getProperties().containsKey( PROP_ORIG_OUTPUT_DIRECTORY ) ) 138 | { 139 | String originalOutputDirectory = 140 | (String) reactorProject.getProperties().remove( PROP_ORIG_OUTPUT_DIRECTORY ); 141 | forkedOutputDirectory = reactorProject.getBuild().getOutputDirectory(); 142 | 143 | reactorProject.getProperties().put( PROP_FORKED_OUTPUT_DIRECTORY, forkedOutputDirectory ); 144 | reactorProject.getBuild().setOutputDirectory( originalOutputDirectory ); 145 | } 146 | 147 | if ( reactorProject.getProperties().containsKey( PROP_ORIG_ARTIFACT_FILE ) ) 148 | { 149 | String originalArtifactFilePath = 150 | (String) reactorProject.getProperties().remove/* get */( PROP_ORIG_ARTIFACT_FILE ); 151 | forkedArtifactFile = reactorProject.getArtifact().getFile(); 152 | 153 | reactorProject.getProperties().put( PROP_FORKED_ARTIFACT_FILE, 154 | forkedArtifactFile == null ? "" 155 | : forkedArtifactFile.getAbsolutePath() ); 156 | reactorProject.getArtifact().setFile( "".equals( originalArtifactFilePath ) ? null 157 | : new File( originalArtifactFilePath ) ); 158 | } 159 | } 160 | } 161 | } 162 | 163 | } -------------------------------------------------------------------------------- /src/main/java/org/scoverage/plugin/SCoverageIntegrationCheckMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2024 Grzegorz Slowikowski (gslowikowski at gmail dot com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, 11 | * software distributed under the License is distributed on an 12 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 13 | * KIND, either express or implied. See the License for the 14 | * specific language governing permissions and limitations 15 | * under the License. 16 | */ 17 | 18 | package org.scoverage.plugin; 19 | 20 | import org.apache.maven.plugins.annotations.Execute; 21 | import org.apache.maven.plugins.annotations.LifecyclePhase; 22 | import org.apache.maven.plugins.annotations.Mojo; 23 | 24 | /** 25 | * Checks if minimum code coverage by unit and integration tests reached 26 | * in forked {@code scoverage} life cycle. 27 | *
28 | *
29 | * In forked {@code scoverage} life cycle project is compiled with SCoverage instrumentation 30 | * and unit and integration tests are executed before checking. 31 | *
32 | * 33 | * @author Grzegorz Slowikowski 34 | * @since 1.1.0 35 | */ 36 | @Mojo( name = "integration-check" ) 37 | @Execute( lifecycle = "scoverage", phase = LifecyclePhase.VERIFY ) 38 | public class SCoverageIntegrationCheckMojo 39 | extends SCoverageCheckMojo 40 | { 41 | } -------------------------------------------------------------------------------- /src/main/java/org/scoverage/plugin/SCoverageIntegrationReportMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2024 Grzegorz Slowikowski (gslowikowski at gmail dot com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, 11 | * software distributed under the License is distributed on an 12 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 13 | * KIND, either express or implied. See the License for the 14 | * specific language governing permissions and limitations 15 | * under the License. 16 | */ 17 | 18 | package org.scoverage.plugin; 19 | 20 | import org.apache.maven.plugins.annotations.Execute; 21 | import org.apache.maven.plugins.annotations.LifecyclePhase; 22 | import org.apache.maven.plugins.annotations.Mojo; 23 | 24 | /** 25 | * Generates code coverage by unit and integration tests report in forked {@code scoverage} life cycle. 26 | *
27 | *
28 | * In forked {@code scoverage} life cycle project is compiled with SCoverage instrumentation 29 | * and unit and integration tests are executed before report generation. 30 | *
31 | * 32 | * @author Grzegorz Slowikowski 33 | * @since 1.1.0 34 | */ 35 | @Mojo( name = "integration-report", threadSafe = false ) 36 | @Execute( lifecycle = "scoverage", phase = LifecyclePhase.VERIFY ) 37 | public class SCoverageIntegrationReportMojo 38 | extends SCoverageReportMojo 39 | { 40 | } -------------------------------------------------------------------------------- /src/main/java/org/scoverage/plugin/SCoverageIntegrationTestMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2024 Grzegorz Slowikowski (gslowikowski at gmail dot com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, 11 | * software distributed under the License is distributed on an 12 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 13 | * KIND, either express or implied. See the License for the 14 | * specific language governing permissions and limitations 15 | * under the License. 16 | */ 17 | 18 | package org.scoverage.plugin; 19 | 20 | import org.apache.maven.plugin.AbstractMojo; 21 | import org.apache.maven.plugins.annotations.Execute; 22 | import org.apache.maven.plugins.annotations.LifecyclePhase; 23 | import org.apache.maven.plugins.annotations.Mojo; 24 | import org.apache.maven.plugins.annotations.Parameter; 25 | import org.apache.maven.project.MavenProject; 26 | 27 | import java.util.List; 28 | 29 | /** 30 | * Executes forked {@code scoverage} life cycle up to {@code verify} phase. 31 | *
32 | *
33 | * In forked {@code scoverage} life cycle project is compiled with SCoverage instrumentation 34 | * and unit and integration tests are executed. 35 | *
36 | * 37 | * @author Grzegorz Slowikowski 38 | * @since 1.2.0 39 | */ 40 | @Mojo( name = "integration-test", threadSafe = true ) 41 | @Execute( lifecycle = "scoverage", phase = LifecyclePhase.VERIFY ) 42 | public class SCoverageIntegrationTestMojo 43 | extends AbstractMojo 44 | { 45 | 46 | /** 47 | * Allows SCoverage to be skipped. 48 | *
49 | * 50 | * @since 1.0.0 51 | */ 52 | @Parameter( property = "scoverage.skip", defaultValue = "false" ) 53 | private boolean skip; 54 | 55 | /** 56 | * Maven project to interact with. 57 | */ 58 | @Parameter( defaultValue = "${project}", readonly = true, required = true ) 59 | private MavenProject project; 60 | 61 | /** 62 | * All Maven projects in the reactor. 63 | */ 64 | @Parameter( defaultValue = "${reactorProjects}", required = true, readonly = true ) 65 | private List reactorProjects; 66 | 67 | /** 68 | * Executes {@code verify} phase in forked {@code scoverage} life cycle. 69 | */ 70 | @Override 71 | public void execute() 72 | { 73 | if ( "pom".equals( project.getPackaging() ) ) 74 | { 75 | getLog().info( "Skipping SCoverage execution for project with packaging type 'pom'" ); 76 | return; 77 | } 78 | 79 | if ( skip ) 80 | { 81 | getLog().info( "Skipping Scoverage execution" ); 82 | return; 83 | } 84 | 85 | long ts = System.currentTimeMillis(); 86 | 87 | SCoverageForkedLifecycleConfigurator.afterForkedLifecycleExit( project, reactorProjects ); 88 | 89 | long te = System.currentTimeMillis(); 90 | getLog().debug( String.format( "Mojo execution time: %d ms", te - ts ) ); 91 | } 92 | 93 | } 94 | -------------------------------------------------------------------------------- /src/main/java/org/scoverage/plugin/SCoveragePackageMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2024 Grzegorz Slowikowski (gslowikowski at gmail dot com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, 11 | * software distributed under the License is distributed on an 12 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 13 | * KIND, either express or implied. See the License for the 14 | * specific language governing permissions and limitations 15 | * under the License. 16 | */ 17 | 18 | package org.scoverage.plugin; 19 | 20 | import java.util.List; 21 | 22 | import org.apache.maven.plugin.AbstractMojo; 23 | import org.apache.maven.plugins.annotations.Execute; 24 | import org.apache.maven.plugins.annotations.LifecyclePhase; 25 | import org.apache.maven.plugins.annotations.Mojo; 26 | import org.apache.maven.plugins.annotations.Parameter; 27 | import org.apache.maven.project.MavenProject; 28 | 29 | /** 30 | * Creates artifact file containing SCoverage instrumented classes. 31 | *
32 | *
33 | * This file's name has {@code scoverage-} prefix to avoid overwriting original 34 | * (not instrumented) file. 35 | * 36 | * @author Grzegorz Slowikowski 37 | * @since 1.2.0 38 | */ 39 | @Mojo( name = "package", threadSafe = true ) 40 | @Execute( lifecycle = "scoverage", phase = LifecyclePhase.PACKAGE ) 41 | public class SCoveragePackageMojo 42 | extends AbstractMojo 43 | { 44 | 45 | /** 46 | * Allows SCoverage to be skipped. 47 | *
48 | * 49 | * @since 1.0.0 50 | */ 51 | @Parameter( property = "scoverage.skip", defaultValue = "false" ) 52 | private boolean skip; 53 | 54 | /** 55 | * Maven project to interact with. 56 | */ 57 | @Parameter( defaultValue = "${project}", readonly = true, required = true ) 58 | private MavenProject project; 59 | 60 | /** 61 | * All Maven projects in the reactor. 62 | */ 63 | @Parameter( defaultValue = "${reactorProjects}", required = true, readonly = true ) 64 | private List reactorProjects; 65 | 66 | /** 67 | * Creates artifact file containing instrumented classes. 68 | */ 69 | @Override 70 | public void execute() 71 | { 72 | if ( "pom".equals( project.getPackaging() ) ) 73 | { 74 | getLog().info( "Skipping SCoverage execution for project with packaging type 'pom'" ); 75 | return; 76 | } 77 | 78 | if ( skip ) 79 | { 80 | getLog().info( "Skipping Scoverage execution" ); 81 | return; 82 | } 83 | 84 | long ts = System.currentTimeMillis(); 85 | 86 | SCoverageForkedLifecycleConfigurator.afterForkedLifecycleExit( project, reactorProjects ); 87 | 88 | long te = System.currentTimeMillis(); 89 | getLog().debug( String.format( "Mojo execution time: %d ms", te - ts ) ); 90 | } 91 | 92 | } -------------------------------------------------------------------------------- /src/main/java/org/scoverage/plugin/SCoveragePostCompileMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2024 Grzegorz Slowikowski (gslowikowski at gmail dot com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, 11 | * software distributed under the License is distributed on an 12 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 13 | * KIND, either express or implied. See the License for the 14 | * specific language governing permissions and limitations 15 | * under the License. 16 | */ 17 | 18 | package org.scoverage.plugin; 19 | 20 | import java.util.Properties; 21 | 22 | import org.apache.maven.plugin.AbstractMojo; 23 | import org.apache.maven.plugins.annotations.LifecyclePhase; 24 | import org.apache.maven.plugins.annotations.Mojo; 25 | import org.apache.maven.plugins.annotations.Parameter; 26 | import org.apache.maven.project.MavenProject; 27 | 28 | /** 29 | * Restores project original configuration after compilation with SCoverage instrumentation. 30 | *
31 | *
32 | * Removes changes done in project properties by {@link SCoveragePreCompileMojo} before compilation: 33 | *
    34 | *
  • removes added properties
  • 35 | *
  • restores original values of modified properties
  • 36 | *
37 | *
38 | * This is internal mojo, executed in forked {@code scoverage} life cycle. 39 | *
40 | * 41 | * @author Grzegorz Slowikowski 42 | * @since 1.0.0 43 | */ 44 | @Mojo( name = "post-compile", defaultPhase = LifecyclePhase.PROCESS_CLASSES ) 45 | public class SCoveragePostCompileMojo 46 | extends AbstractMojo 47 | { 48 | /** 49 | * Allows SCoverage to be skipped. 50 | *
51 | * 52 | * @since 1.0.0 53 | */ 54 | @Parameter( property = "scoverage.skip", defaultValue = "false" ) 55 | private boolean skip; 56 | 57 | /** 58 | * Maven project to interact with. 59 | */ 60 | @Parameter( defaultValue = "${project}", readonly = true, required = true ) 61 | private MavenProject project; 62 | 63 | /** 64 | * Restores project original configuration after compilation with SCoverage instrumentation. 65 | */ 66 | @Override 67 | public void execute() 68 | { 69 | if ( "pom".equals( project.getPackaging() ) ) 70 | { 71 | return; 72 | } 73 | 74 | if ( skip ) 75 | { 76 | return; 77 | } 78 | 79 | long ts = System.currentTimeMillis(); 80 | 81 | Properties projectProperties = project.getProperties(); 82 | 83 | restoreProperty( projectProperties, "addScalacArgs" ); 84 | restoreProperty( projectProperties, "analysisCacheFile" ); 85 | restoreProperty( projectProperties, "maven.test.failure.ignore" ); 86 | 87 | long te = System.currentTimeMillis(); 88 | getLog().debug( String.format( "Mojo execution time: %d ms", te - ts ) ); 89 | } 90 | 91 | private void restoreProperty( Properties projectProperties, String propertyName ) 92 | { 93 | if ( projectProperties.containsKey( "scoverage.backup." + propertyName ) ) 94 | { 95 | String oldValue = projectProperties.getProperty( "scoverage.backup." + propertyName ); 96 | projectProperties.put( propertyName, oldValue ); 97 | projectProperties.remove( "scoverage.backup." + propertyName ); 98 | } 99 | else 100 | { 101 | projectProperties.remove( propertyName ); 102 | } 103 | } 104 | 105 | } -------------------------------------------------------------------------------- /src/main/java/org/scoverage/plugin/SCoveragePreCompileMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2024 Grzegorz Slowikowski (gslowikowski at gmail dot com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, 11 | * software distributed under the License is distributed on an 12 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 13 | * KIND, either express or implied. See the License for the 14 | * specific language governing permissions and limitations 15 | * under the License. 16 | */ 17 | 18 | package org.scoverage.plugin; 19 | 20 | import java.io.BufferedWriter; 21 | import java.io.File; 22 | import java.io.FileOutputStream; 23 | import java.io.IOException; 24 | import java.io.OutputStreamWriter; 25 | import java.nio.charset.StandardCharsets; 26 | import java.util.*; 27 | import java.util.stream.Collectors; 28 | import javax.inject.Inject; 29 | 30 | import org.apache.maven.execution.MavenSession; 31 | import org.apache.maven.model.Dependency; 32 | import org.apache.maven.plugin.AbstractMojo; 33 | import org.apache.maven.plugin.MojoExecutionException; 34 | import org.apache.maven.plugins.annotations.LifecyclePhase; 35 | import org.apache.maven.plugins.annotations.Mojo; 36 | import org.apache.maven.plugins.annotations.Parameter; 37 | import org.apache.maven.project.MavenProject; 38 | 39 | import org.codehaus.plexus.util.StringUtils; 40 | import org.eclipse.aether.artifact.Artifact; 41 | import org.eclipse.aether.RepositorySystem; 42 | import org.eclipse.aether.RepositorySystemSession; 43 | import org.eclipse.aether.artifact.DefaultArtifact; 44 | import org.eclipse.aether.repository.RemoteRepository; 45 | import org.eclipse.aether.resolution.ArtifactRequest; 46 | import org.eclipse.aether.resolution.ArtifactResolutionException; 47 | import org.eclipse.aether.resolution.ArtifactResult; 48 | 49 | /** 50 | * Configures project for compilation with SCoverage instrumentation. 51 | *
52 | *
53 | * Supported compiler plugins: 54 | * 57 | *
58 | * This is internal mojo, executed in forked {@code scoverage} life cycle. 59 | *
60 | * 61 | * @author Grzegorz Slowikowski 62 | * @since 1.0.0 63 | */ 64 | @Mojo( name = "pre-compile", defaultPhase = LifecyclePhase.GENERATE_RESOURCES ) 65 | public class SCoveragePreCompileMojo 66 | extends AbstractMojo 67 | { 68 | 69 | /** 70 | * Allows SCoverage to be skipped. 71 | *
72 | * 73 | * @since 1.0.0 74 | */ 75 | @Parameter( property = "scoverage.skip", defaultValue = "false" ) 76 | private boolean skip; 77 | 78 | /** 79 | * Scala version used for scalac compiler plugin artifact resolution. 80 | * 81 | * @since 1.0.0 82 | */ 83 | @Parameter( property = "scala.version" ) 84 | private String scalaVersion; 85 | 86 | /** 87 | * Directory where the coverage files should be written. 88 | *
89 | * 90 | * @since 1.0.0 91 | */ 92 | @Parameter( property = "scoverage.dataDirectory", defaultValue = "${project.build.directory}/scoverage-data", required = true, readonly = true ) 93 | private File dataDirectory; 94 | 95 | /** 96 | * Semicolon-separated list of regular expressions for packages to exclude, "(empty)" for default package. 97 | *
98 | *
99 | * Example: 100 | *
101 | * {@code (empty);Reverse.*;.*AuthService.*;models\.data\..*} 102 | *
103 | *
104 | * See https://github.com/scoverage/sbt-scoverage#exclude-classes-and-packages for additional documentation. 105 | *
106 | * 107 | * @since 1.0.0 108 | */ 109 | @Parameter( property = "scoverage.excludedPackages" ) 110 | private String excludedPackages; 111 | 112 | /** 113 | * Semicolon-separated list of regular expressions for source paths to exclude. 114 | *
115 | * 116 | * @since 1.0.0 117 | */ 118 | @Parameter( property = "scoverage.excludedFiles" ) 119 | private String excludedFiles; 120 | 121 | /** 122 | * See https://github.com/scoverage/sbt-scoverage#highlighting. 123 | *
124 | * 125 | * @since 1.0.0 126 | */ 127 | @Parameter( property = "scoverage.highlighting", defaultValue = "true" ) 128 | private boolean highlighting; 129 | 130 | /** 131 | * Force scalac-scoverage-plugin version used. 132 | *
133 | * 134 | * @since 1.0.0 135 | */ 136 | @Parameter( property = "scoverage.scalacPluginVersion", defaultValue = "2.3.0" ) 137 | private String scalacPluginVersion; 138 | 139 | /** 140 | * Semicolon-separated list of project properties set in forked {@code scoverage} life cycle. 141 | *
142 | *
143 | * Example: 144 | *
145 | * {@code prop1=val1;prop2=val2;prop3=val3} 146 | *
147 | * 148 | * @since 1.4.0 149 | */ 150 | @Parameter( property = "scoverage.additionalForkedProjectProperties" ) 151 | private String additionalForkedProjectProperties; 152 | 153 | /** 154 | * Maven project to interact with. 155 | */ 156 | @Parameter( defaultValue = "${project}", readonly = true, required = true ) 157 | private MavenProject project; 158 | 159 | /** 160 | * The current Maven session. 161 | */ 162 | @Parameter( defaultValue = "${session}", readonly = true, required = true ) 163 | private MavenSession session; 164 | 165 | /** 166 | * All Maven projects in the reactor. 167 | */ 168 | @Parameter( defaultValue = "${reactorProjects}", required = true, readonly = true ) 169 | private List reactorProjects; 170 | 171 | /** 172 | * Repository system used to look up artifacts in the remote repository. 173 | */ 174 | @Inject 175 | private RepositorySystem repositorySystem; 176 | 177 | @Parameter( defaultValue = "${repositorySystemSession}", readonly = true ) 178 | protected RepositorySystemSession repoSession; 179 | 180 | @Parameter( defaultValue = "${project.remoteProjectRepositories}", readonly = true ) 181 | protected List remoteRepos; 182 | 183 | /** 184 | * Configures project for compilation with SCoverage instrumentation. 185 | * 186 | * @throws MojoExecutionException if unexpected problem occurs 187 | */ 188 | @Override 189 | public void execute() throws MojoExecutionException 190 | { 191 | if ( "pom".equals( project.getPackaging() ) ) 192 | { 193 | getLog().info( "Skipping SCoverage execution for project with packaging type 'pom'" ); 194 | //for aggregator mojo - list of submodules: List modules = project.getCollectedProjects(); 195 | return; 196 | } 197 | 198 | if ( skip ) 199 | { 200 | getLog().info( "Skipping Scoverage execution as configured" ); 201 | 202 | Properties projectProperties = project.getProperties(); 203 | 204 | // for maven-compiler-plugin (compile), scala-maven-plugin (compile) 205 | setProperty( projectProperties, "maven.main.skip", "true" ); 206 | 207 | // for maven-resources-plugin (testResources), maven-compiler-plugin (testCompile), 208 | // scala-maven-plugin (testCompile), maven-surefire-plugin and scalatest-maven-plugin 209 | setProperty( projectProperties, "maven.test.skip", "true" ); 210 | // for scalatest-maven-plugin and specs2-maven-plugin 211 | setProperty( projectProperties, "skipTests", "true" ); 212 | 213 | return; 214 | } 215 | 216 | long ts = System.currentTimeMillis(); 217 | 218 | ScalaVersion scalaVersion = resolveScalaVersion(); 219 | 220 | if ( scalaVersion != null ) 221 | { 222 | boolean supportedScalaVersion = scalaVersion.isScala2() && scalaVersion.isAtLeast( "2.12.8" ) || 223 | scalaVersion.isAtLeast( "3.2.0" ); 224 | if (!supportedScalaVersion) 225 | { 226 | getLog().warn( String.format( "Skipping SCoverage execution - unsupported Scala version \"%s\". Supported Scala versions are 2.12.8+, 2.13.0+ and 3.2.0+ .", 227 | scalaVersion.full ) ); 228 | return; 229 | } 230 | } 231 | else 232 | { 233 | getLog().warn( "Skipping SCoverage execution - Scala version not set" ); 234 | return; 235 | } 236 | 237 | Map additionalProjectPropertiesMap = null; 238 | if ( additionalForkedProjectProperties != null && !additionalForkedProjectProperties.isEmpty() ) 239 | { 240 | String[] props = additionalForkedProjectProperties.split( ";" ); 241 | additionalProjectPropertiesMap = new HashMap<>(props.length); 242 | for ( String propVal: props ) 243 | { 244 | String[] tmp = propVal.split( "=", 2 ); 245 | if ( tmp.length == 2 ) 246 | { 247 | String propName = tmp[ 0 ].trim(); 248 | String propValue = tmp[ 1 ].trim(); 249 | additionalProjectPropertiesMap.put( propName, propValue ); 250 | } 251 | else 252 | { 253 | getLog().warn( String.format( "Skipping invalid additional forked project property \"%s\", must be in \"key=value\" format", 254 | propVal ) ); 255 | 256 | } 257 | } 258 | } 259 | 260 | SCoverageForkedLifecycleConfigurator.afterForkedLifecycleEnter( project, reactorProjects, additionalProjectPropertiesMap ); 261 | 262 | try 263 | { 264 | boolean scala2 = scalaVersion.isScala2(); 265 | boolean filePackageExclusionSupportingScala3 = 266 | scalaVersion.isAtLeast( "3.4.2" ) || 267 | // backported to Scala 3.3 LTS 268 | ( scalaVersion.full.startsWith( "3.3." ) && scalaVersion.isAtLeast( "3.3.4" ) ); 269 | 270 | List pluginArtifacts = getScoveragePluginArtifacts( scalaVersion ); 271 | if ( scala2 ) // Scala 3 doesn't need scalac-scoverage-runtime 272 | { 273 | addScalacScoverageRuntimeDependencyToClasspath( scalaVersion ); 274 | } 275 | 276 | String arg = ( scala2 ? SCALA2_DATA_DIR_OPTION : SCALA3_COVERAGE_OUT_OPTION ) + dataDirectory.getAbsolutePath(); 277 | String addScalacArgs = arg; 278 | 279 | arg = scala2 ? ( SOURCE_ROOT_OPTION + session.getExecutionRootDirectory() ) : ""; 280 | addScalacArgs = addScalacArgs + PIPE + arg; 281 | 282 | if ( !StringUtils.isEmpty( excludedPackages ) ) 283 | { 284 | if ( scala2 ) { 285 | arg = SCALA2_EXCLUDED_PACKAGES_OPTION + excludedPackages.replace( "(empty)", "" ); 286 | addScalacArgs = addScalacArgs + PIPE + arg; 287 | } else if ( filePackageExclusionSupportingScala3 ) { 288 | String scala3FormatExcludedPackages = excludedPackages.replace( ";", "," ); 289 | arg = SCALA3_EXCLUDED_PACKAGES_OPTION + scala3FormatExcludedPackages; 290 | addScalacArgs = addScalacArgs + PIPE + arg; 291 | } else { 292 | getLog().warn( "Package exclusion is supported for Scala [3.3.4-3.4.0) or 3.4.2+" ); 293 | } 294 | } 295 | 296 | if ( !StringUtils.isEmpty( excludedFiles ) ) 297 | { 298 | if ( scala2 ) { 299 | arg = SCALA2_EXCLUDED_FILES_OPTION + excludedFiles; 300 | addScalacArgs = addScalacArgs + PIPE + arg; 301 | } else if ( filePackageExclusionSupportingScala3 ) { 302 | String scala3FormatExcludedFiles = excludedFiles.replace( ";", "," ); 303 | arg = SCALA3_EXCLUDED_FILES_OPTION + scala3FormatExcludedFiles; 304 | addScalacArgs = addScalacArgs + PIPE + arg; 305 | } else { 306 | getLog().warn( "File exclusion is supported for Scala [3.3.4-3.4.0) or 3.4.2+" ); 307 | } 308 | } 309 | 310 | if ( highlighting && scala2 ) 311 | { 312 | addScalacArgs = addScalacArgs + PIPE + "-Yrangepos"; 313 | } 314 | 315 | if ( scala2 ) { 316 | arg = PLUGIN_OPTION + pluginArtifacts.stream().map(x -> x.getFile().getAbsolutePath()).collect(Collectors.joining(String.valueOf(java.io.File.pathSeparatorChar))); 317 | addScalacArgs = addScalacArgs + PIPE + arg; 318 | } 319 | 320 | Properties projectProperties = project.getProperties(); 321 | 322 | // for scala-maven-plugin (version 3.0.0+) 323 | setProperty( projectProperties, "addScalacArgs", addScalacArgs ); 324 | // for scala-maven-plugin (version 3.1.0+) 325 | setProperty( projectProperties, "analysisCacheFile", 326 | "${project.build.directory}/scoverage-analysis/compile" ); 327 | // for maven-surefire-plugin and scalatest-maven-plugin 328 | setProperty( projectProperties, "maven.test.failure.ignore", "true" ); 329 | 330 | // for maven-jar-plugin 331 | // VERY IMPORTANT! Prevents from overwriting regular project artifact file 332 | // with instrumented one during "integration-check" or "integration-report" execution. 333 | project.getBuild().setFinalName( "scoverage-" + project.getBuild().getFinalName() ); 334 | 335 | saveSourceRootsToFile(); 336 | } 337 | catch ( ArtifactResolutionException | IOException e ) 338 | { 339 | throw new MojoExecutionException( "SCoverage preparation failed", e ); 340 | } 341 | 342 | long te = System.currentTimeMillis(); 343 | getLog().debug( String.format( "Mojo execution time: %d ms", te - ts ) ); 344 | } 345 | 346 | // Private utility methods 347 | 348 | private static final String SCALA_LIBRARY_GROUP_ID = "org.scala-lang"; 349 | private static final String SCALA2_LIBRARY_ARTIFACT_ID = "scala-library"; 350 | private static final String SCALA3_LIBRARY_ARTIFACT_ID = "scala3-library_3"; 351 | 352 | private static final String SCALA2_DATA_DIR_OPTION = "-P:scoverage:dataDir:"; 353 | private static final String SCALA3_COVERAGE_OUT_OPTION = "-coverage-out:"; 354 | private static final String SOURCE_ROOT_OPTION = "-P:scoverage:sourceRoot:"; 355 | private static final String SCALA2_EXCLUDED_PACKAGES_OPTION = "-P:scoverage:excludedPackages:"; 356 | private static final String SCALA3_EXCLUDED_PACKAGES_OPTION = "-coverage-exclude-classlikes:"; 357 | private static final String SCALA2_EXCLUDED_FILES_OPTION = "-P:scoverage:excludedFiles:"; 358 | private static final String SCALA3_EXCLUDED_FILES_OPTION = "-coverage-exclude-files:"; 359 | private static final String PLUGIN_OPTION = "-Xplugin:"; 360 | 361 | private static final char PIPE = '|'; 362 | 363 | private ScalaVersion resolveScalaVersion() 364 | { 365 | String result = scalaVersion; 366 | if ( result == null || result.isEmpty() ) 367 | { 368 | // check project direct dependencies (transitive dependencies cannot be checked in this Maven lifecycle phase) 369 | List dependencies = project.getDependencies(); 370 | for ( Dependency dependency: dependencies ) 371 | { 372 | if ( SCALA_LIBRARY_GROUP_ID.equals( dependency.getGroupId() ) 373 | && ( 374 | SCALA2_LIBRARY_ARTIFACT_ID.equals( dependency.getArtifactId() ) || 375 | SCALA3_LIBRARY_ARTIFACT_ID.equals( dependency.getArtifactId() ) 376 | ) 377 | ) 378 | { 379 | result = dependency.getVersion(); 380 | break; 381 | } 382 | } 383 | } 384 | return result != null ? new ScalaVersion(result) : null; 385 | } 386 | 387 | private void setProperty( Properties projectProperties, String propertyName, String newValue ) 388 | { 389 | if ( projectProperties.containsKey( propertyName ) ) 390 | { 391 | String oldValue = projectProperties.getProperty( propertyName ); 392 | projectProperties.put( "scoverage.backup." + propertyName, oldValue ); 393 | } 394 | else 395 | { 396 | projectProperties.remove( "scoverage.backup." + propertyName ); 397 | } 398 | 399 | if ( newValue != null ) 400 | { 401 | projectProperties.put( propertyName, newValue ); 402 | } 403 | else 404 | { 405 | projectProperties.remove( propertyName ); 406 | } 407 | } 408 | 409 | private String getScalacPluginVersion() { 410 | if ( StringUtils.isEmpty(scalacPluginVersion) ) { 411 | throw new IllegalStateException("scalacPluginVersion is unset."); 412 | } else if ( scalacPluginVersion.startsWith("1.") ) { 413 | throw new IllegalStateException( String.format( "Unsupported scalacPluginVersion \"%s\". Please use scalacPluginVersion 2.0.0+ or use older version of scoverage-maven-plugin", scalacPluginVersion ) ); 414 | } else { 415 | return scalacPluginVersion; 416 | } 417 | } 418 | 419 | private List getScoveragePluginArtifacts(ScalaVersion scalaVersion ) 420 | throws ArtifactResolutionException { 421 | List resolvedArtifacts = new ArrayList<>(); 422 | if ( scalaVersion.isScala2() ) // Scala 3 doesn't need scalac-scoverage-plugin 423 | { 424 | resolvedArtifacts.add(resolveScoverageArtifact("scalac-scoverage-plugin_" + scalaVersion.full )); 425 | } 426 | resolvedArtifacts.add(resolveScoverageArtifact("scalac-scoverage-domain_" + scalaVersion.compatible )); 427 | resolvedArtifacts.add(resolveScoverageArtifact("scalac-scoverage-serializer_" + scalaVersion.compatible )); 428 | return resolvedArtifacts; 429 | } 430 | 431 | /** 432 | * We need to tweak our test classpath for Scoverage. 433 | */ 434 | @SuppressWarnings( "deprecation" ) // didn't find a good way to do this with Aether artifacts 435 | private void addScalacScoverageRuntimeDependencyToClasspath(ScalaVersion resolvedScalaVersion ) 436 | throws ArtifactResolutionException { 437 | 438 | Set set = new LinkedHashSet<>(project.getDependencyArtifacts()); 439 | set.add(toMavenClasspathArtifact( 440 | resolveScoverageArtifact("scalac-scoverage-runtime_" + resolvedScalaVersion.compatible) 441 | )); 442 | project.setDependencyArtifacts( set); 443 | } 444 | 445 | private org.apache.maven.artifact.Artifact toMavenClasspathArtifact( Artifact artifact ) { 446 | org.apache.maven.artifact.handler.DefaultArtifactHandler artifactHandler = 447 | new org.apache.maven.artifact.handler.DefaultArtifactHandler( artifact.getExtension() ); 448 | artifactHandler.setAddedToClasspath(true); 449 | return new org.apache.maven.artifact.DefaultArtifact( 450 | artifact.getGroupId(), 451 | artifact.getArtifactId(), 452 | artifact.getVersion(), 453 | org.apache.maven.artifact.Artifact.SCOPE_COMPILE, 454 | artifact.getExtension(), 455 | artifact.getClassifier(), 456 | artifactHandler 457 | ); 458 | } 459 | 460 | private Artifact resolveScoverageArtifact( String artifactId ) 461 | throws ArtifactResolutionException { 462 | 463 | ArtifactRequest request = new ArtifactRequest(); 464 | request.setArtifact( new DefaultArtifact("org.scoverage", artifactId, "jar", getScalacPluginVersion()) ); 465 | request.setRepositories(remoteRepos); 466 | 467 | ArtifactResult result = repositorySystem.resolveArtifact(repoSession, request); 468 | return result.getArtifact(); 469 | } 470 | 471 | private void saveSourceRootsToFile() throws IOException 472 | { 473 | List sourceRoots = project.getCompileSourceRoots(); 474 | if ( !sourceRoots.isEmpty() ) 475 | { 476 | if ( !dataDirectory.exists() && !dataDirectory.mkdirs() ) 477 | { 478 | throw new IOException( String.format( "Cannot create \"%s\" directory ", 479 | dataDirectory.getAbsolutePath() ) ); 480 | } 481 | File sourceRootsFile = new File( dataDirectory, "source.roots" ); 482 | try ( BufferedWriter writer = new BufferedWriter( 483 | new OutputStreamWriter( new FileOutputStream(sourceRootsFile), StandardCharsets.UTF_8 ))) { 484 | for ( String sourceRoot : sourceRoots ) { 485 | writer.write( sourceRoot ); 486 | writer.newLine(); 487 | } 488 | } 489 | } 490 | } 491 | } 492 | -------------------------------------------------------------------------------- /src/main/java/org/scoverage/plugin/SCoverageReportOnlyMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2024 Grzegorz Slowikowski (gslowikowski at gmail dot com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, 11 | * software distributed under the License is distributed on an 12 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 13 | * KIND, either express or implied. See the License for the 14 | * specific language governing permissions and limitations 15 | * under the License. 16 | */ 17 | 18 | package org.scoverage.plugin; 19 | 20 | import org.apache.maven.plugins.annotations.Execute; 21 | import org.apache.maven.plugins.annotations.LifecyclePhase; 22 | import org.apache.maven.plugins.annotations.Mojo; 23 | 24 | /** 25 | * Generates code coverage report without forking {@code scoverage} life cycle. 26 | *
27 | *
28 | * Report is generated using available coverage data generated by: 29 | * {@link SCoverageCheckMojo}, {@link SCoverageIntegrationCheckMojo}, 30 | * {@link SCoverageReportMojo} or {@link SCoverageIntegrationReportMojo} 31 | * earlier in the build or in previous build if it was not cleaned afterwards. 32 | *
33 | * 34 | * @author Grzegorz Slowikowski 35 | * @since 1.0.0 36 | */ 37 | @Mojo( name = "report-only" ) 38 | @Execute( phase = LifecyclePhase.NONE ) 39 | public class SCoverageReportOnlyMojo 40 | extends SCoverageReportMojo 41 | { 42 | } -------------------------------------------------------------------------------- /src/main/java/org/scoverage/plugin/SCoverageTestMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2024 Grzegorz Slowikowski (gslowikowski at gmail dot com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, 11 | * software distributed under the License is distributed on an 12 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 13 | * KIND, either express or implied. See the License for the 14 | * specific language governing permissions and limitations 15 | * under the License. 16 | */ 17 | 18 | package org.scoverage.plugin; 19 | 20 | import org.apache.maven.plugin.AbstractMojo; 21 | import org.apache.maven.plugins.annotations.Execute; 22 | import org.apache.maven.plugins.annotations.LifecyclePhase; 23 | import org.apache.maven.plugins.annotations.Mojo; 24 | import org.apache.maven.plugins.annotations.Parameter; 25 | import org.apache.maven.project.MavenProject; 26 | 27 | import java.util.List; 28 | 29 | /** 30 | * Executes forked {@code scoverage} life cycle up to {@code test} phase. 31 | *
32 | *
33 | * In forked {@code scoverage} life cycle project is compiled with SCoverage instrumentation 34 | * and unit tests are executed. 35 | *
36 | * 37 | * @author Grzegorz Slowikowski 38 | * @since 1.2.0 39 | */ 40 | @Mojo( name = "test", threadSafe = true ) 41 | @Execute( lifecycle = "scoverage", phase = LifecyclePhase.TEST ) 42 | public class SCoverageTestMojo 43 | extends AbstractMojo 44 | { 45 | 46 | /** 47 | * Allows SCoverage to be skipped. 48 | *
49 | * 50 | * @since 1.0.0 51 | */ 52 | @Parameter( property = "scoverage.skip", defaultValue = "false" ) 53 | private boolean skip; 54 | 55 | /** 56 | * Maven project to interact with. 57 | */ 58 | @Parameter( defaultValue = "${project}", readonly = true, required = true ) 59 | private MavenProject project; 60 | 61 | /** 62 | * All Maven projects in the reactor. 63 | */ 64 | @Parameter( defaultValue = "${reactorProjects}", required = true, readonly = true ) 65 | private List reactorProjects; 66 | 67 | /** 68 | * Executes {@code test} phase in forked {@code scoverage} life cycle. 69 | */ 70 | @Override 71 | public void execute() 72 | { 73 | if ( "pom".equals( project.getPackaging() ) ) 74 | { 75 | getLog().info( "Skipping SCoverage execution for project with packaging type 'pom'" ); 76 | return; 77 | } 78 | 79 | if ( skip ) 80 | { 81 | getLog().info( "Skipping Scoverage execution" ); 82 | return; 83 | } 84 | 85 | long ts = System.currentTimeMillis(); 86 | 87 | SCoverageForkedLifecycleConfigurator.afterForkedLifecycleExit( project, reactorProjects ); 88 | 89 | long te = System.currentTimeMillis(); 90 | getLog().debug( String.format( "Mojo execution time: %d ms", te - ts ) ); 91 | } 92 | 93 | } -------------------------------------------------------------------------------- /src/main/java/org/scoverage/plugin/ScalaVersion.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2024 Grzegorz Slowikowski (gslowikowski at gmail dot com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, 11 | * software distributed under the License is distributed on an 12 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 13 | * KIND, either express or implied. See the License for the 14 | * specific language governing permissions and limitations 15 | * under the License. 16 | */ 17 | 18 | package org.scoverage.plugin; 19 | 20 | import java.util.regex.Matcher; 21 | import java.util.regex.Pattern; 22 | 23 | /** 24 | * Inspired by scala-maven-plugin's VersionNumber.java 25 | */ 26 | public class ScalaVersion { 27 | private static final Pattern regexp = Pattern.compile("(\\d+)\\.(\\d+)(\\.\\d+)?([-\\.].+)?"); 28 | 29 | /** 30 | * The full version number, including the modifier if any. 31 | */ 32 | public String full; 33 | 34 | /** 35 | * The binary compatible version number for this Scala version. 36 | * e.g. for 2.10.0-M1, this would be 2.10.0-M1, for 2.10.0, this would be 2.10, for 3.3.1, this would be 3. 37 | */ 38 | public String compatible; 39 | 40 | /** 41 | * The major Scala version number. e.g. for 2.10.0-M1, this would be 2. 42 | */ 43 | public int major; 44 | 45 | /** 46 | * The minor Scala version number. e.g. for 2.10.0-M1, this would be 10. 47 | */ 48 | public int minor; 49 | 50 | /** 51 | * The bugfix Scala version number. e.g. for 2.10.0-M1, this would be 0. 52 | */ 53 | public int bugfix; 54 | 55 | /** 56 | * The modifier for this Scala version. e.g. for 2.10.0-M1, this would be M1. 57 | */ 58 | public String modifier; 59 | 60 | /** 61 | * Creates a ScalaVersion from a String. 62 | * 63 | * @param s String to parse 64 | */ 65 | public ScalaVersion(String s) { 66 | full = s; 67 | // parse 68 | Matcher match = regexp.matcher(s); 69 | if (!match.find()) { 70 | throw new IllegalArgumentException("Invalid Scala version [" + s + "]. Expected major.minor(.bugfix)(modifier)"); 71 | } 72 | major = Integer.parseInt(match.group(1)); 73 | minor = Integer.parseInt(match.group(2)); 74 | if ((match.group(3) != null) && (match.group(3).length() > 1)) { 75 | bugfix = Integer.parseInt(match.group(3).substring(1)); 76 | } 77 | if ((match.group(4) != null) && (match.group(4).length() > 1)) { 78 | modifier = match.group(4); 79 | } 80 | // compute compatible 81 | compatible = 82 | modifier != null ? full : // non-stable versions are not compatible with anything else 83 | major == 2 ? major + "." + minor : // Scala 2.X.Y is compatible with any Scala 2.X.Z 84 | major + ""; // Scala 3.X is compatible with any Scala 3.Y 85 | } 86 | 87 | /** 88 | * Ignores modifier, so can return `true` for any ScalaVersion with matching major, minor, bugfix. 89 | * 90 | * @param other ScalaVersion to compare to 91 | * @return true if this version is of the same or newer Scala version as the other version 92 | */ 93 | public boolean isAtLeast(ScalaVersion other) { 94 | return major >= other.major && 95 | (major != other.major || minor >= other.minor) && 96 | (major != other.major || minor != other.minor || bugfix >= other.bugfix); 97 | 98 | } 99 | 100 | /** 101 | * Ignores modifier, so can return `true` for any ScalaVersion with matching major, minor, bugfix. 102 | * 103 | * @param scalaVersion to compare to 104 | * @return true if this version is of the same or newer Scala version as the other version 105 | */ 106 | public boolean isAtLeast(String scalaVersion) { 107 | return isAtLeast(new ScalaVersion(scalaVersion)); 108 | } 109 | 110 | 111 | /** 112 | * @return true if this is a Scala 2 version 113 | */ 114 | public boolean isScala2() { 115 | return major == 2; 116 | } 117 | 118 | } -------------------------------------------------------------------------------- /src/main/resources/META-INF/maven/lifecycle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 19 | 20 | 21 | 22 | scoverage 23 | 24 | 25 | generate-resources 26 | 27 | 28 | 29 | pre-compile 30 | 31 | 32 | 33 | 34 | 35 | process-classes 36 | 37 | 38 | 39 | post-compile 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /src/main/resources/scoverage-report.properties: -------------------------------------------------------------------------------- 1 | # Copyright 2014-2024 Grzegorz Slowikowski (gslowikowski at gmail dot com) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, 10 | # software distributed under the License is distributed on an 11 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 12 | # KIND, either express or implied. See the License for the 13 | # specific language governing permissions and limitations 14 | # under the License. 15 | 16 | report.scoverage.name=SCoverage 17 | report.scoverage.description=SCoverage documentation. 18 | -------------------------------------------------------------------------------- /src/site/resources/css/site.css: -------------------------------------------------------------------------------- 1 | #banner { 2 | background-color: #006bbb; 3 | border-radius: 6px 6px 0px 0px; 4 | color: white; 5 | } 6 | 7 | #bannerLeft { 8 | margin-left: 14px; 9 | margin-top: 30px; 10 | } 11 | 12 | #bannerRight > img { 13 | border-radius: 6px 6px 0px 0px; 14 | } 15 | 16 | .breadcrumb { 17 | background-color: #002f51; 18 | border-radius: 0px 0px 4px 4px; 19 | } 20 | 21 | .breadcrumb > li { 22 | color: #ffffff; 23 | text-shadow: none; 24 | } 25 | 26 | .builtBy { 27 | display: none; 28 | } 29 | 30 | pre.prettyprint { 31 | border: 1px solid #e3e3e3; 32 | } 33 | 34 | tt { 35 | background-color: #f5f5f5; 36 | border: 1px solid #e3e3e3; 37 | color: #d14; 38 | } 39 | 40 | .tag { 41 | color: #63a35c; 42 | } 43 | 44 | code, pre { 45 | font-family: Monaco,Menlo,"Courier New",monospace; 46 | } 47 | -------------------------------------------------------------------------------- /src/site/resources/images/my-avatar-80.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scoverage/scoverage-maven-plugin/f8bf24c33876175b6e9e62794b143637a7da809e/src/site/resources/images/my-avatar-80.png -------------------------------------------------------------------------------- /src/site/site.xml: -------------------------------------------------------------------------------- 1 | 17 | 18 | 21 | 22 | 23 | org.apache.maven.skins 24 | maven-fluido-skin 25 | 2.0.0 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | false 37 | true 38 | 39 | span3 40 | span9 41 | 42 | 43 | 44 | 45 | 46 | ]]> 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /src/test/java/org/scoverage/plugin/ScalaVersionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2024 Grzegorz Slowikowski (gslowikowski at gmail dot com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, 11 | * software distributed under the License is distributed on an 12 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 13 | * KIND, either express or implied. See the License for the 14 | * specific language governing permissions and limitations 15 | * under the License. 16 | */ 17 | 18 | package org.scoverage.plugin; 19 | 20 | import org.junit.Test; 21 | 22 | import static org.junit.Assert.*; 23 | 24 | public class ScalaVersionTest { 25 | 26 | @Test 27 | public void testInvalidVersion() { 28 | try { 29 | new ScalaVersion("whatever"); 30 | fail("Should have thrown an exception"); 31 | } catch (IllegalArgumentException e) { 32 | assertEquals("Invalid Scala version [whatever]. Expected major.minor(.bugfix)(modifier)", e.getMessage()); 33 | } 34 | } 35 | 36 | @Test 37 | public void testIsAtLeast() { 38 | assertTrue(new ScalaVersion("2.13.12").isAtLeast("1.0")); 39 | assertTrue(new ScalaVersion("2.12.1").isAtLeast("1.9")); 40 | assertTrue(new ScalaVersion("2.13.10").isAtLeast("2.0")); 41 | assertTrue(new ScalaVersion("2.13.1").isAtLeast("2.13")); 42 | assertTrue(new ScalaVersion("2.10.0").isAtLeast("2.10.0-rc8")); 43 | assertTrue(new ScalaVersion("2.13.1").isAtLeast("2.13.0")); 44 | assertTrue(new ScalaVersion("2.13.12").isAtLeast("2.13.12")); 45 | assertFalse(new ScalaVersion("3.3.1").isAtLeast("3.3.2-rc1")); 46 | assertFalse(new ScalaVersion("2.12.10").isAtLeast("2.13")); 47 | assertFalse(new ScalaVersion("2.13.12").isAtLeast("3.0")); 48 | assertFalse(new ScalaVersion("2.13.12").isAtLeast("3.0.0")); 49 | } 50 | 51 | @Test 52 | public void testFull() { 53 | assertEquals("2.12.2", new ScalaVersion("2.12.2").full); 54 | assertEquals("2.13.12", new ScalaVersion("2.13.12").full); 55 | assertEquals("3.0.0", new ScalaVersion("3.0.0").full); 56 | assertEquals("3.4.0-RC1", new ScalaVersion("3.4.0-RC1").full); 57 | } 58 | 59 | @Test 60 | public void testCompatible() { 61 | assertEquals("2.12", new ScalaVersion("2.12.2").compatible); 62 | assertEquals("2.12", new ScalaVersion("2.12.18").compatible); 63 | assertEquals("2.13", new ScalaVersion("2.13.0").compatible); 64 | assertEquals("2.13", new ScalaVersion("2.13.12").compatible); 65 | assertEquals("3", new ScalaVersion("3.0.0").compatible); 66 | assertEquals("3", new ScalaVersion("3.3.1").compatible); 67 | assertEquals("3", new ScalaVersion("3.4.0").compatible); 68 | assertEquals("3.4.0-RC1", new ScalaVersion("3.4.0-RC1").compatible); 69 | } 70 | 71 | @Test 72 | public void testIsScala2() { 73 | assertTrue(new ScalaVersion("2.12.2").isScala2()); 74 | assertTrue(new ScalaVersion("2.13.12").isScala2()); 75 | assertFalse(new ScalaVersion("3.0.0").isScala2()); 76 | assertFalse(new ScalaVersion("3.4.0-RC1").isScala2()); 77 | assertFalse(new ScalaVersion("1.0.0").isScala2()); 78 | } 79 | 80 | } --------------------------------------------------------------------------------