Skip to content

Commit

Permalink
Fix build failure
Browse files Browse the repository at this point in the history
  • Loading branch information
daniellansun committed Dec 22, 2023
1 parent b897cb2 commit 6e8b11f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -269,4 +269,7 @@ tasks.named("dependencyUpdates")?.configure {

artifacts {
grapesRuntimeElements file: jar.archiveFile.get().asFile, type: 'jar'
xstreamAstRuntimeElements file: jar.archiveFile.get().asFile, type: 'jar'
gparsRuntimeElements file: jar.archiveFile.get().asFile, type: 'jar'
loggingRuntimeElements file: jar.archiveFile.get().asFile, type: 'jar'
}

19 comments on commit 6e8b11f

@daniellansun
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ysb33r @aalmiray

When I tried to bump gradle to 8.5, asciidoctor gradle plugin came across the following error.
Could you tell me how to fix or workaround? Thanks in advance.

/cc @paulk-asert @melix @Goooler

Error: Exception in thread "main" java.io.InvalidClassException: precompiled_OrgApacheGroovyAsciidoctor$_run_closure5$_closure20; local class incompatible: stream classdesc serialVersionUID = 4477335110646737576, local class serialVersionUID = -4624[195](https://github.com/apache/groovy/actions/runs/7303097289/job/19910219335#step:6:196)846785189806
	at java.base/java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:597)
	at java.base/java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:[205](https://github.com/apache/groovy/actions/runs/7303097289/job/19910219335#step:6:206)1)
	at java.base/java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1898)
	at java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:[222](https://github.com/apache/groovy/actions/runs/7303097289/job/19910219335#step:6:223)4)
	at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1733)
	at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:509)
	at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:467)
	at java.base/java.util.ArrayList.readObject(ArrayList.java:899)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at java.base/java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1100)
	at java.base/java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2423)
	at java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:[225](https://github.com/apache/groovy/actions/runs/7303097289/job/19910219335#step:6:226)7)
	at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1733)
	at java.base/java.io.ObjectInputStream$FieldValues.<init>(ObjectInputStream.java:2606)
	at java.base/java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2457)
	at java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2257)
	at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1733)
	at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:509)
	at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:467)
	at java.base/java.util.ArrayList.readObject(ArrayList.java:899)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at java.base/java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1100)
	at java.base/java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2423)
	at java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2257)
	at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1733)
	at java.base/java.io.ObjectInputStream$FieldValues.<init>(ObjectInputStream.java:2606)
	at java.base/java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2457)
	at java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2257)
	at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1733)
	at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:509)
	at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:467)
	at org.asciidoctor.gradle.remote.AsciidoctorJavaExec$_main_closure1$_closure7.doCall(AsciidoctorJavaExec.groovy:45)
	at org.asciidoctor.gradle.remote.AsciidoctorJavaExec$_main_closure1$_closure7.call(AsciidoctorJavaExec.groovy)
	at org.codehaus.groovy.runtime.IOGroovyMethods.withCloseable(IOGroovyMethods.java:1607)
	at org.asciidoctor.gradle.remote.AsciidoctorJavaExec$_main_closure1.doCall(AsciidoctorJavaExec.groovy:44)
	at org.asciidoctor.gradle.remote.AsciidoctorJavaExec$_main_closure1.call(AsciidoctorJavaExec.groovy)
	at org.codehaus.groovy.runtime.IOGroovyMethods.withStream(IOGroovyMethods.java:1184)
	at org.codehaus.groovy.runtime.ResourceGroovyMethods.withInputStream(ResourceGroovyMethods.java:1882)
	at org.asciidoctor.gradle.remote.AsciidoctorJavaExec.main(AsciidoctorJavaExec.groovy:43)

> Task :groovy-ant:asciidoctor FAILED

@Goooler
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No idea about this, I'll try to adopt asciidoctor-gradle-plugin for Gradle 8.

@paulk-asert
Copy link
Contributor

@paulk-asert paulk-asert commented on 6e8b11f Dec 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ysb33r
Copy link
Contributor

@ysb33r ysb33r commented on 6e8b11f Dec 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am working on trying to have asciidoctor-gradle 4.0 (not the alpha version) ready for release by EOW.

The existing code base is not Gradle 8 compatible and there are many things that still need testing.

@ysb33r
Copy link
Contributor

@ysb33r ysb33r commented on 6e8b11f Jan 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@daniellansun
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ysb33r I bumped asciidoctor gradle plugin to 4.0.0( cb332ef ), but the issue still happened( https://github.com/apache/groovy/actions/runs/7424783243/job/20205107427#step:6:243 ), could you take a look?

> Task :groovy-binary:distSrc
Error: Exception in thread "main" java.io.InvalidClassException: precompiled_OrgApacheGroovyAsciidoctor$_run_closure4$_closure19; local class incompatible: stream classdesc serialVersionUID = 1251694026305095019, local class serialVersionUID = -6305391430266673269
	at java.base/java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:597)

	at java.base/java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:2051)
	at java.base/java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1898)
	at java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2224)
	at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1733)
	at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:509)
	at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:467)
	at java.base/java.util.ArrayList.readObject(ArrayList.java:899)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at java.base/java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1100)
	at java.base/java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:[242](https://github.com/apache/groovy/actions/runs/7424783243/job/20205107427#step:6:243)3)
	at java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2257)
	at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1733)
	at java.base/java.io.ObjectInputStream$FieldValues.<init>(ObjectInputStream.java:2606)
	at java.base/java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:[245](https://github.com/apache/groovy/actions/runs/7424783243/job/20205107427#step:6:246)7)
	at java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2257)
	at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1733)
	at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:509)
	at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:467)
	at java.base/java.util.ArrayList.readObject(ArrayList.java:899)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at java.base/java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1100)
	at java.base/java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2423)
	at java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2[257](https://github.com/apache/groovy/actions/runs/7424783243/job/20205107427#step:6:258))
	at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1733)
	at java.base/java.io.ObjectInputStream$FieldValues.<init>(ObjectInputStream.java:2606)
	at java.base/java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2457)
	at java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2257)
	at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1733)
	at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:509)
	at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:467)
	at org.asciidoctor.gradle.remote.AsciidoctorJavaExec$_main_closure1$_closure6.doCall(AsciidoctorJavaExec.groovy:45)
	at org.asciidoctor.gradle.remote.AsciidoctorJavaExec$_main_closure1$_closure6.call(AsciidoctorJavaExec.groovy)
	at org.codehaus.groovy.runtime.IOGroovyMethods.withCloseable(IOGroovyMethods.java:1607)
	at org.asciidoctor.gradle.remote.AsciidoctorJavaExec$_main_closure1.doCall(AsciidoctorJavaExec.groovy:44)
	at org.asciidoctor.gradle.remote.AsciidoctorJavaExec$_main_closure1.call(AsciidoctorJavaExec.groovy)
	at org.codehaus.groovy.runtime.IOGroovyMethods.withStream(IOGroovyMethods.java:1184)
	at org.codehaus.groovy.runtime.ResourceGroovyMethods.withInputStream(ResourceGroovyMethods.java:1882)
	at org.asciidoctor.gradle.remote.AsciidoctorJavaExec.main(AsciidoctorJavaExec.groovy:43)
> Task :groovy-ant:asciidoctor

> Task :groovy-ant:asciidoctor FAILED

@ysb33r
Copy link
Contributor

@ysb33r ysb33r commented on 6e8b11f Jan 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@daniellansun I ran :groovy-ant:asciidoctor locally and it passes.

FYI this is the build I had

------------------------------------------------------------
Gradle 8.1.1
------------------------------------------------------------

Build time:   2023-04-21 12:31:26 UTC
Revision:     1cf537a851c635c364a4214885f8b9798051175b

Kotlin:       1.8.10
Groovy:       3.0.15
Ant:          Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM:          11.0.18 (Amazon.com Inc. 11.0.18+10-LTS)
OS:           Linux 6.6.7-200.fc39.x86_64 amd64

I wonder if this is a GH Actions env issue.

@daniellansun
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ysb33r I'm trying to bump Gradle to 8.5, but task :groovy-ant:asciidoctor always fail even if asciidoctor gradle plugin is 4.0.0 now.

@ysb33r
Copy link
Contributor

@ysb33r ysb33r commented on 6e8b11f Jan 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@daniellansun I managed to reproduce locally with JDK17 & Gradle 8.5. (I notice it does work on Gradle 8.1). I'll do some digging to see if I can see what I can discover that the issue is,

@ysb33r
Copy link
Contributor

@ysb33r ysb33r commented on 6e8b11f Jan 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@daniellansun As I don't know the Groovy build, can yopu tell me whether somewhere you declare some asciidoctor extensions using closures?

@ysb33r
Copy link
Contributor

@ysb33r ysb33r commented on 6e8b11f Jan 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I have gathered so far.

It seems to be related to ./build-logic/src/main/groovy/org.apache.groovy-asciidoctor.gradle, possible this block of code

    docExtensions {
        def baseUrls = [
                jdk: 'https://docs.oracle.com/en/java/javase/11/docs/api/index.html',
                gjdk: "https://docs.groovy-lang.org/${vers}/html/groovy-jdk/index.html",
                gapi: "https://docs.groovy-lang.org/${vers}/html/gapi/index.html",
                gapid: "https://docs.groovy-lang.org/${vers}/html/gapi/",
        ]
        baseUrls.each { macroName, baseURL ->
            inline_macro(name: macroName) {
                parent, target, attributes ->
                    def (className, anchor) = target.split('#') as List
                    def base = className == 'index' ?
                            baseURL : baseURL + '?' + className.replace('.', '/') + '.html' + (anchor ? '#' + anchor : '')
                    createPhraseNode(parent, 'anchor', attributes.text ?: target, attributes, [type: ':link', target: base])
            }
        }
    }

docExtensions will cause the dehydration and serialization of that closure. The issue actually happens during the serialization process.

The issue starts with Gradle 8.4. It cannot be the version of Groovy, because 3.0.17 is present in both 8.3 & 8.4. It is possible that there has been a slight change in how Gradle handles something here. At this point I don't know what.

@daniellansun
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ysb33r Thanks a lot for your looking into the issue 🙂

docExtensions will cause the dehydration and serialization of that closure. The issue actually happens during the serialization process.
The issue starts with Gradle 8.4.

@blindpirate Do you have any idea to workaround the serialization issue? /cc @melix

@ysb33r
Copy link
Contributor

@ysb33r ysb33r commented on 6e8b11f Jan 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To add more context, I added that docExtensions snippet to a test in the asciidoctor-gradle and the serialization issues does not occur.

@ysb33r
Copy link
Contributor

@ysb33r ysb33r commented on 6e8b11f Jan 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a workaround though.

If you put the extensions in a subproject, you can add the project dependecy to docExtensions. That would prevent Gradle from instrumenting the closures.

In concept you can do this

asciidoctor-extensions/build.gradle

plugins {
    id 'groovy'
}


dependencies {
    compileOnly "org.codehaus.groovy:groovy:1.2.3.4" // As this is the Groovy project, you'll know best how to provide this dependency
    compileOnly "org.asciidoctor:asciidoctorj:2.5.7" // Decide which which version of asciidoctorj to use
    compileOnly "org.asciidoctor:asciidoctorj-groovy-dsl:2.0.2" 
}

./build-logic/src/main/groovy/org.apache.groovy-asciidoctor.gradle

asciidoctorj {
  docExtensions ':asciidoctor-extensions'
 modules.groovyDsl.use()
}

@daniellansun
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ysb33r
I have not fully understood, but I am trying to fix the build according to your suggestion:
6aaa012

@ysb33r
Copy link
Contributor

@ysb33r ysb33r commented on 6e8b11f Jan 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ysb33r I have not fully understood, but I am trying to fix the build according to your suggestion: 6aaa012

@daniellansun You should create the extensions as a normal groovy library. Do not place the extensions as a closure in the build script.

See this example subproject https://github.com/asciidoctor/asciidoctor-gradle-plugin/tree/master/jvm/src/gradleTest/extension-in-subproject/extension and then the subproject from which it is used https://github.com/asciidoctor/asciidoctor-gradle-plugin/blob/master/jvm/src/gradleTest/extension-in-subproject/docs-using-project-direct/build.gradle

@ysb33r
Copy link
Contributor

@ysb33r ysb33r commented on 6e8b11f Jan 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦‍♂️ @daniellansun I completely forgot that it is possible to use a File or a String instance. There is no need to do a subproject.

Just try this

    asciidoctorj {
         [
                jdk: 'https://docs.oracle.com/en/java/javase/11/docs/api/index.html',
                gjdk: "https://docs.groovy-lang.org/${vers}/html/groovy-jdk/index.html",
                gapi: "https://docs.groovy-lang.org/${vers}/html/gapi/index.html",
                gapid: "https://docs.groovy-lang.org/${vers}/html/gapi/",
        ].each { macroName, baseURL ->
           docExtensions """
            inline_macro(name: ${macroName}) {
                parent, target, attributes ->
                    def (className, anchor) = target.split('#') as List
                    def base = className == 'index' ?
                            baseURL : ${baseURL} + '?' + className.replace('.', '/') + '.html' + (anchor ? '#' + anchor : '')
                    createPhraseNode(parent, 'anchor', attributes.text ?: target, attributes, [type: ':link', target: base])
            }
           """.toString()
        }
    }

@daniellansun
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ysb33r Thanks a lot for your help! The build is green on my local machine.
Here is the final commit: 31953c2

@ysb33r
Copy link
Contributor

@ysb33r ysb33r commented on 6e8b11f Jan 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

This work has lead to some improvements in Asciidoctor Glradle plugin. We'll probably release a 4.0.1 shortly, which will remove the need to use .toString(). However we'll probably not support closure-based extensions on Gradle 8.4+ any time soon. The fix for that is too tricky.

Please sign in to comment.