microsoft / azure-pipelines-tasks

Tasks for Azure Pipelines
https://aka.ms/tfbuild
MIT License
3.5k stars 2.61k forks source link

[enhancement]: Support Java21 in Maven-Build task #19131

Open aurifi opened 1 year ago

aurifi commented 1 year ago

Task name

Maven

Describe your feature request here

As Java 21 is now released as LTS the Maven task should support that version. The last supported version seems to be Java 17. Additionally it might be an idea to not have the possible versions defined as a list, as this requires updates every time a new version is released.

DmitriiBobreshev commented 1 year ago

Hi @szczepad, thanks for the feedback! We'll try to add a new version in the future once we have enough time.

ogbesgt commented 12 months ago

Hi I have this issue today, Java 21 not installed on Azure DevOps pipeline. Got it resolved by using the installer. Thanks to Stackover flow.

` - bash: 'wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/java/21/latest/jdk-21_linux-x64_bin.tar.gz ' displayName: 'Download Java21'

for windows you can use this reference

Heatmanofurioso commented 11 months ago

Hi team,

Any idea on when might this feature get pushed? Would be great to push for adoption of the latest LTS.

hungchu0912 commented 10 months ago

Hello, is there any update on this feature?

martinvisser commented 9 months ago

Hi @szczepad, thanks for the feedback! We'll try to add a new version in the future once we have enough time.

Really appreciate it if this can be looked at

Heatmanofurioso commented 9 months ago

Hi team,

Any reason these issues don't get any attention? It should be a really low effort task, especially considering how Java has been evolving, and should ensure that the community is up to date with standards and technology

TotallyMehis commented 9 months ago

Looking forward to this being resolved.

svitlychnyi commented 9 months ago

Looks like it's already implemented in current version, but not yet documented.

  - task: Maven@3
    displayName: Backend Tests
    inputs:
      mavenPomFile: 'pom.xml'
      mavenOptions: '-Xmx3072m'
      javaHomeOption: 'JDKVersion'
      jdkVersionOption: '1.21'
      jdkArchitectureOption: 'x64'
      publishJUnitResults: true
      mavenAuthenticateFeed: true
      goals: 'clean test'
GustavoOS commented 9 months ago

Looks like it's already implemented in current version, but not yet documented.

  - task: Maven@3
    displayName: Backend Tests
    inputs:
      mavenPomFile: 'pom.xml'
      mavenOptions: '-Xmx3072m'
      javaHomeOption: 'JDKVersion'
      jdkVersionOption: '1.21'
      jdkArchitectureOption: 'x64'
      publishJUnitResults: true
      mavenAuthenticateFeed: true
      goals: 'clean test'

@DmitriiBobreshev would you confirm this for us, please?

TotallyMehis commented 8 months ago

Looks like it's already implemented in current version, but not yet documented.

  - task: Maven@3
    displayName: Backend Tests
    inputs:
      mavenPomFile: 'pom.xml'
      mavenOptions: '-Xmx3072m'
      javaHomeOption: 'JDKVersion'
      jdkVersionOption: '1.21'
      jdkArchitectureOption: 'x64'
      publishJUnitResults: true
      mavenAuthenticateFeed: true
      goals: 'clean test'

Tried this and it seems to work.

Only caveat being that JaCoCo's code coverage seems to be broken so we can't use this just yet.

java.lang.instrument.IllegalClassFormatException: Error while instrumenting com/example/test.
    at org.jacoco.agent.rt.internal_3570298.CoverageTransformer.transform(CoverageTransformer.java:94)
    at java.instrument/java.lang.instrument.ClassFileTransformer.transform(ClassFileTransformer.java:244)
    at java.instrument/sun.instrument.TransformerManager.transform(TransformerManager.java:188)
    at java.instrument/sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:610)
    at java.base/java.lang.ClassLoader.defineClass1(Native Method)
    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1027)
    at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
    at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:862)
    at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:760)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:681)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:639)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526)
    at org.apache.maven.surefire.api.util.DefaultScanResult.loadClass(DefaultScanResult.java:115)
    at org.apache.maven.surefire.api.util.DefaultScanResult.applyFilter(DefaultScanResult.java:85)
    at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.scanClasspath(JUnitPlatformProvider.java:142)
    at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invoke(JUnitPlatformProvider.java:122)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:385)
    at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:162)
    at org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:507)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:495)
Caused by: java.io.IOException: Error while instrumenting com/example/test.
    at org.jacoco.agent.rt.internal_3570298.core.instr.Instrumenter.instrumentError(Instrumenter.java:160)
    at org.jacoco.agent.rt.internal_3570298.core.instr.Instrumenter.instrument(Instrumenter.java:110)
    at org.jacoco.agent.rt.internal_3570298.CoverageTransformer.transform(CoverageTransformer.java:92)
    ... 20 more
Caused by: java.lang.IllegalArgumentException: Unsupported class file major version 65
    at org.jacoco.agent.rt.internal_3570298.asm.ClassReader.<init>(ClassReader.java:196)
    at org.jacoco.agent.rt.internal_3570298.asm.ClassReader.<init>(ClassReader.java:177)
    at org.jacoco.agent.rt.internal_3570298.asm.ClassReader.<init>(ClassReader.java:163)
    at org.jacoco.agent.rt.internal_3570298.core.internal.instr.InstrSupport.classReaderFor(InstrSupport.java:280)
    at org.jacoco.agent.rt.internal_3570298.core.instr.Instrumenter.instrument(Instrumenter.java:76)
    at org.jacoco.agent.rt.internal_3570298.core.instr.Instrumenter.instrument(Instrumenter.java:108)
    ... 21 more
Fradantim commented 8 months ago

Tried this and it seems to work.

Only caveat being that JaCoCo's code coverage seems to be broken so we can't use this just yet.

https://github.com/microsoft/azure-pipelines-tasks/issues/19400 bumps jacoco to 0.8.11 in task Maven@4, making it compatible with Java 21.

Also asking for this feature please.

JWATSU commented 8 months ago

We also have an issue with jacoco not working with java 21 with the Maven@4 task.

Heatmanofurioso commented 8 months ago

@JWATSU The PR Fradantim mentioned was only merged 19 hours ago. When did you last test it?

Fradantim commented 8 months ago

@Heatmanofurioso https://github.com/microsoft/azure-pipelines-tasks/issues/19400 was merged on Dec 20, 2023, jwatsu has to use Maven@4 instead of Maven@3

JWATSU commented 8 months ago

@Heatmanofurioso @Fradantim I use Maven@4 but the Jacoco version still isn't updated. Might it be because we are using Azure DevOps Server and it's lagging behind? How can we check this?

Heatmanofurioso commented 8 months ago

@Fradantim I understood that he's using Maven@4.

@JWATSU We're using it as well, hence my questions. I want to attempt the migration without needing custom pipelines, but seems they haven't released it there yet.

According to their release notes, it isn't there yet. https://learn.microsoft.com/en-us/azure/devops/release-notes/features-timeline-released

ivanduplenskikh commented 8 months ago

@JWATSU jacoco v0.8.11 for Java 21 is available in Maven >=4.234.0. The previous versions of Maven task weren't updated. Could you please check that your Maven task version is >=4.234.0?

romchellis commented 5 months ago

I'm also affected, there is no java21 option available :(

ajburley commented 1 month ago

@ivanduplenskikh I'm experiencing the same issue. In Azure DevOps, there is no option to specify the exact version, like 4.234.0. It just lets you select 4.x, 3.x, 2.x or 1.x. I have selected 4.x, but the option to select JDK 21 is still not there, and the latest one shown is JDK 17. I have to select "default" to use JDK 21, which is fine for now, but when another JDK version is released in the future it will automatically switch to use that one, which is not desired.