• Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • coverage-model
    • None

      I am writing unit tests for my Jenkins pipelines, involving some custom logic for retrieving/handling the coverage results. For this, I rely on the coverage-model module:

       

      dependencies {
          // ...
          implementation 'edu.hm.hafner:coverage-model:0.46.0'
          // ...
      }

      Using

       

      import edu.hm.hafner.coverage.Coverage.CoverageBuilder

      now to implement something similar to the original pipeline with

       

          private Optional<Value> convertToCoverage(final Fraction fraction, final Metric metric) {
              return Optional.ofNullable(
                  new CoverageBuilder().withMetric(metric)
                      .withCovered(fraction.getNumerator())
                      .withTotal(fraction.getDenominator())
                      .build()
              )
          }

       

      I am observing issues about edu.hm.hafner.util.Ensure not being available. The Gradle dependency tree does not report a suitable dependency as well.

      Trying to find a standalone package for this turned out to not be easy: I could either use codingstyle-pom which does not seem to make much sense for a standalone use case or retrieve my own copy from either https://github.com/uhafner/codingstyle/blob/main/src/main/java/edu/hm/hafner/util/Ensure.java or https://github.com/uhafner/config/blob/master/src/main/java/edu/hm/hafner/util/Ensure.java, which does not feel correct either and introduces further dependencies which do not seem to be necessary.

      At the moment, I am using a local copy of Ensure.java without external dependencies, but this does not feel correct. In my opinion, edu.hm.hafner.util should be distributed as a regular package for further re-use to allow clean library usage.

       

       

          [JENKINS-73663] Dependencies are missing in released artifact

          Ulli Hafner added a comment -

          Does Gadle not pick up the transitive dependencies? In Maven I get:

           ~/g/w/coverage-model      mvn dependency:tree -Dscope=compile                          5.4s  Wed Aug 21 14:06:55 2024
          [INFO] Scanning for projects...
          [INFO] Inspecting build with total of 1 modules...
          [INFO] Installing Nexus Staging features:
          [INFO]   ... total of 1 executions of maven-deploy-plugin replaced with nexus-staging-maven-plugin
          [WARNING] The requested profile "no-ui-tests-on-mac" could not be activated because it does not exist.
          [WARNING] The requested profile "ui-tests-locally" could not be activated because it does not exist.
          [INFO] 
          [INFO] --------------------< edu.hm.hafner:coverage-model >--------------------
          [INFO] Building Code Coverage Model and Parsers 0.47.0-SNAPSHOT
          [INFO]   from pom.xml
          [INFO] --------------------------------[ jar ]---------------------------------
          [INFO] 
          [INFO] --- dependency:3.6.1:tree (default-cli) @ coverage-model ---
          [INFO] edu.hm.hafner:coverage-model:jar:0.47.0-SNAPSHOT
          [INFO] +- edu.hm.hafner:codingstyle:jar:4.10.0:compile
          [INFO] +- com.github.spotbugs:spotbugs-annotations:jar:4.8.5:compile
          [INFO] +- com.google.errorprone:error_prone_annotations:jar:2.28.0:compile
          [INFO] +- org.apache.commons:commons-lang3:jar:3.14.0:compile
          [INFO] +- commons-io:commons-io:jar:2.16.1:compile
          [INFO] \- one.util:streamex:jar:0.8.2:compile
          
          

          Ulli Hafner added a comment - Does Gadle not pick up the transitive dependencies? In Maven I get: ~/g/w/coverage-model     mvn dependency:tree -Dscope=compile 5.4s  Wed Aug 21 14:06:55 2024 [INFO] Scanning for projects... [INFO] Inspecting build with total of 1 modules... [INFO] Installing Nexus Staging features: [INFO] ... total of 1 executions of maven-deploy-plugin replaced with nexus-staging-maven-plugin [WARNING] The requested profile "no-ui-tests-on-mac" could not be activated because it does not exist. [WARNING] The requested profile "ui-tests-locally" could not be activated because it does not exist. [INFO] [INFO] --------------------< edu.hm.hafner:coverage-model >-------------------- [INFO] Building Code Coverage Model and Parsers 0.47.0-SNAPSHOT [INFO] from pom.xml [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- dependency:3.6.1:tree (default-cli) @ coverage-model --- [INFO] edu.hm.hafner:coverage-model:jar:0.47.0-SNAPSHOT [INFO] +- edu.hm.hafner:codingstyle:jar:4.10.0:compile [INFO] +- com.github.spotbugs:spotbugs-annotations:jar:4.8.5:compile [INFO] +- com.google.errorprone:error_prone_annotations:jar:2.28.0:compile [INFO] +- org.apache.commons:commons-lang3:jar:3.14.0:compile [INFO] +- commons-io:commons-io:jar:2.16.1:compile [INFO] \- one.util:streamex:jar:0.8.2:compile

          Stefan added a comment - - edited

          It does not seem to be the case. I have added a very basic example project at https://github.com/stefan6419846/JENKINS-73663 which does not define any source sets, but where running ./gradlew dependencies shows that coverage-model does not seem to have any dependencies in Gradle, while the Groovy dependency has dependencies (see dependencies.txt):

           

          ...
          |    +--- org.apache.groovy:groovy-xml:4.0.22
          |    |    +--- org.apache.groovy:groovy-bom:4.0.22 (*)
          |    |    \--- org.apache.groovy:groovy:4.0.22 (*)
          |    \--- org.apache.groovy:groovy-yaml:4.0.22
          |         +--- org.apache.groovy:groovy-bom:4.0.22 (*)
          |         \--- org.apache.groovy:groovy:4.0.22 (*)
          \--- edu.hm.hafner:coverage-model:0.46.0
          

           

          There clearly are no references to codingstyle, although I am not sure why.

          Just for the record (not shown in the above example): I had to declare the dependency on commons-lang3 manually as well:

          implementation 'org.apache.commons:commons-lang3:3.16.0'

          Stefan added a comment - - edited It does not seem to be the case. I have added a very basic example project at https://github.com/stefan6419846/JENKINS-73663 which does not define any source sets, but where running ./gradlew dependencies shows that coverage-model does not seem to have any dependencies in Gradle, while the Groovy dependency has dependencies (see dependencies.txt ):   ... |    +--- org.apache.groovy:groovy-xml:4.0.22 |    |    +--- org.apache.groovy:groovy-bom:4.0.22 (*) |    |    \--- org.apache.groovy:groovy:4.0.22 (*) |    \--- org.apache.groovy:groovy-yaml:4.0.22 |         +--- org.apache.groovy:groovy-bom:4.0.22 (*) |         \--- org.apache.groovy:groovy:4.0.22 (*) \--- edu.hm.hafner:coverage-model:0.46.0   There clearly are no references to codingstyle , although I am not sure why. Just for the record (not shown in the above example): I had to declare the dependency on commons-lang3 manually as well: implementation 'org.apache.commons:commons-lang3:3.16.0'

          Ulli Hafner added a comment -

          You are right, I just checked https://central.sonatype.com/artifact/edu.hm.hafner/coverage-model/0.46.0/versions and all dependencies seem to be removed in the deployed artifact. Somehow I broke the pom.xml structrure during the release process... 

          Ulli Hafner added a comment - You are right, I just checked https://central.sonatype.com/artifact/edu.hm.hafner/coverage-model/0.46.0/versions and all dependencies seem to be removed in the deployed artifact. Somehow I broke the pom.xml structrure during the release process... 

            drulli Ulli Hafner
            stefan6419846 Stefan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: