codacy / codacy-coverage-reporter

Multi-language coverage reporter for Codacy
https://www.codacy.com
Other
135 stars 94 forks source link

Java 9 Support #76

Closed michiwieland closed 6 years ago

michiwieland commented 6 years ago

Operating System

Travis CI / Trusty Ubuntu 14.04.5 LTS

JDK

Oracle JDK9 Java(TM) SE Runtime Environment (build 9.0.1+11)

Expected Behavior

Codacy coverage reporter supports Java 9

Actual Behavior

Codacy coverage reporter does crash with Java 9.

5:37:31,873 %PARSER_ERROR[coloredLevel] com.codacy Parsing coverage data... 
2018-03-16 15:37:32,166 %PARSER_ERROR[coloredLevel] com.codacy Uploading coverage data... 
Exception in thread "main" java.lang.NoClassDefFoundError: javax/activation/MimetypesFileTypeMap
    at rapture.mime.MimeTypes$.<init>(mime.scala:1544)
    at rapture.mime.MimeTypes$.<clinit>(mime.scala)
    at rapture.net.PostType$$anon$14.contentType(net.scala:132)
    at rapture.net.PostType$$anon$14.contentType(net.scala:131)
    at rapture.net.HttpSupport$$anon$1$$anonfun$doHttp$1.apply(http.scala:159)
    at rapture.net.HttpSupport$$anon$1$$anonfun$doHttp$1.apply(http.scala:131)
    at rapture.core.ThrowExceptionsMode.wrap(modes.scala:199)
    at rapture.net.HttpSupport$$anon$1.doHttp(http.scala:131)
    at rapture.net.HttpSupport$Capability$$anonfun$httpPost$1.apply(http.scala:78)
    at rapture.net.HttpSupport$Capability$$anonfun$httpPost$1.apply(http.scala:78)
    at rapture.core.ThrowExceptionsMode.wrap(modes.scala:199)
    at rapture.net.HttpSupport$Capability.httpPost(http.scala:78)
    at com.codacy.api.client.CodacyClient.post(CodacyClient.scala:56)
    at com.codacy.api.service.CoverageServices.sendReport(CoverageServices.scala:20)
    at com.codacy.CodacyCoverageReporter$$anonfun$coverageWithTokenAndCommit$1$$anonfun$apply$2$$anonfun$apply$3.apply(CodacyCoverageReporter.scala:150)
    at com.codacy.CodacyCoverageReporter$$anonfun$coverageWithTokenAndCommit$1$$anonfun$apply$2$$anonfun$apply$3.apply(CodacyCoverageReporter.scala:136)
    at com.codacy.CodacyCoverageReporter$.com$codacy$CodacyCoverageReporter$$transform(CodacyCoverageReporter.scala:186)
    at com.codacy.CodacyCoverageReporter$$anonfun$coverageWithTokenAndCommit$1$$anonfun$apply$2.apply(CodacyCoverageReporter.scala:135)
    at com.codacy.CodacyCoverageReporter$$anonfun$coverageWithTokenAndCommit$1$$anonfun$apply$2.apply(CodacyCoverageReporter.scala:135)
    at com.codacy.parsers.CoverageParserFactory$$anonfun$withCoverageReport$1.apply(CoverageParser.scala:42)
    at com.codacy.parsers.CoverageParserFactory$$anonfun$withCoverageReport$1.apply(CoverageParser.scala:40)
    at scala.Option.map(Option.scala:146)
    at com.codacy.parsers.CoverageParserFactory$.withCoverageReport(CoverageParser.scala:39)
    at com.codacy.CodacyCoverageReporter$$anonfun$coverageWithTokenAndCommit$1.apply(CodacyCoverageReporter.scala:135)
    at com.codacy.CodacyCoverageReporter$$anonfun$coverageWithTokenAndCommit$1.apply(CodacyCoverageReporter.scala:129)
    at com.codacy.api.helpers.FileHelper$$anonfun$withTokenAndCommit$1$$anonfun$apply$2.apply(FileHelper.scala:21)
    at com.codacy.api.helpers.FileHelper$$anonfun$withTokenAndCommit$1$$anonfun$apply$2.apply(FileHelper.scala:19)
    at scala.Option.map(Option.scala:146)
    at com.codacy.api.helpers.FileHelper$$anonfun$withTokenAndCommit$1.apply(FileHelper.scala:19)
    at com.codacy.api.helpers.FileHelper$$anonfun$withTokenAndCommit$1.apply(FileHelper.scala:18)
    at com.codacy.api.helpers.FileHelper$$anonfun$withCommit$2.apply(FileHelper.scala:34)
    at com.codacy.api.helpers.FileHelper$$anonfun$withCommit$2.apply(FileHelper.scala:33)
    at scala.Option.map(Option.scala:146)
    at com.codacy.api.helpers.FileHelper$.withCommit(FileHelper.scala:33)
    at com.codacy.api.helpers.FileHelper$.withTokenAndCommit(FileHelper.scala:18)
    at com.codacy.CodacyCoverageReporter$.coverageWithTokenAndCommit(CodacyCoverageReporter.scala:129)
    at com.codacy.CodacyCoverageReporter$.codacyCoverage(CodacyCoverageReporter.scala:162)
    at com.codacy.CodacyCoverageReporter$.main(CodacyCoverageReporter.scala:89)
    at com.codacy.CodacyCoverageReporter.main(CodacyCoverageReporter.scala)
Caused by: java.lang.ClassNotFoundException: javax.activation.MimetypesFileTypeMap
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:185)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496)
    ... 39 more

Reproducible Test Case

travis.yml

dist: trusty
language: java
jdk:
  - oraclejdk9

# Upload test coverage to codacy
env:
  global:
    CODACY_PROJECT_TOKEN=[your-token]

before_install:
  - sudo apt-get install jq
  - wget -O ~/codacy-coverage-reporter-assembly-latest.jar $(curl https://api.github.com/repos/codacy/codacy-coverage-reporter/releases/latest | jq -r .assets[0].browser_download_url)

after_success:
  - java -jar ~/codacy-coverage-reporter-assembly-latest.jar -l Java -r build/reports/jacoco/jacocoRootReport/jacocoRootReport.xml
rtfpessoa commented 6 years ago

Hi @michiwieland, this library does not support Java 9 yet. I will open an internal ticket and see how we will progress. Will update you here as I know more.

fniephaus commented 6 years ago

In the meantime, you might want to use jdk_switcher on Travis CI.

davidgoate commented 6 years ago

When using Jenkins pipelines I don't think it's quite as easy to run part of the build with one JDK and another JRE/JDK.

We decleartively specify the version like this:

#!/usr/bin/env groovy
pipeline {
    agent {
        label 'cloud-slave'
    }
    tools {
        jdk 'JDK10'
    }
...
}

I'm not sure the TravisCI option works quite as nicely on this type of set up.

rtfpessoa commented 6 years ago

@michiwieland, @fniephaus, @davidgoate as described in https://github.com/codacy/codacy-coverage-reporter/pull/89 we were able to do a quick hack to avoid the issue. Can you try it and see if it works.

Released as version 4.0.2.

fniephaus commented 6 years ago

Seems to be working, thanks!