typelead / gradle-eta

Gradle plugin for the Eta programming language
BSD 3-Clause "New" or "Revised" License
30 stars 7 forks source link

gradle-eta is broken for Gradle >= 5.1 #43

Open rahulmutt opened 5 years ago

graeme-lockley commented 5 years ago

@rahulmutt just finding my way around ETA and having great fun. Could this issue be causing building (for example) the simple example within this repo from failing when attempting to build with Gradle 5.4.1? The error I am seeing is

Task :compileTestEta FAILED file or directory '/Users/graemelockley/Projects/gradle-eta/examples/simple/src/test/eta', not found Caching disabled for task ':compileTestEta' because: Build cache is disabled Task ':compileTestEta' is not up-to-date because: Task.upToDateWhen is false. :compileTestEta (Thread[Execution worker for ':' Thread 4,5,main]) completed. Took 0.004 secs.

FAILURE: Build failed with an exception.

Incidentally this is when I attempt

./gradlew build

or

./gradlew test

rahulmutt commented 5 years ago

I got the following:

* What went wrong:
Execution failed for task ':compileTestEta'.
> java.lang.UnsupportedOperationException (no error message)

Is that the same error you're getting?

graeme-lockley commented 5 years ago

Nope that wasn't the error that I got. The following is a off of a clean clone:

Graemes-iMac-2:gradle-eta graemelockley$ pwd /Users/graemelockley/Projects/gradle-eta Graemes-iMac-2:gradle-eta graemelockley$ cd examples/simple/ Graemes-iMac-2:simple graemelockley$ ./gradlew run

FAILURE: Build failed with an exception.

  • What went wrong: Could not create service of type ScriptPluginFactory using BuildScopeServices.createScriptPluginFactory().

    Could not create service of type PluginResolutionStrategyInternal using BuildScopeServices.createPluginResolutionStrategy().

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 0s Graemes-iMac-2:simple graemelockley$ ./gradlew --info run Initialized native services in: /Users/graemelockley/.gradle/native The client will now receive all logging from the daemon (pid: 5033). The daemon log file: /Users/graemelockley/.gradle/daemon/4.7/daemon-5033.out.log Starting 6th build in daemon [uptime: 12 mins 23.779 secs, performance: 98%] Using 8 worker leases.

FAILURE: Build failed with an exception.

  • What went wrong: Could not create service of type ScriptPluginFactory using BuildScopeServices.createScriptPluginFactory().

    Could not create service of type PluginResolutionStrategyInternal using BuildScopeServices.createPluginResolutionStrategy().

  • Try: Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 0s

Incidentally on the above quote I have not attempted to run "gradle wrapper" so it is running on 4.7. When I do upgrade it works again. Again the quote below off of my terminal:

Graemes-iMac-2:simple graemelockley$ ./gradlew --version WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedClass (file:/Users/graemelockley/.gradle/wrapper/dists/gradle-4.7-bin/73xux3q4721jgr4pjvqf9o30/gradle-4.7/lib/groovy-all-2.4.12.jar) to method java.lang.Object.finalize() WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.reflection.CachedClass WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release


Gradle 4.7

Build time: 2018-04-18 09:09:12 UTC Revision: b9a962bf70638332300e7f810689cb2febbd4a6c

Groovy: 2.4.12 Ant: Apache Ant(TM) version 1.9.9 compiled on February 2 2017 JVM: 12 (Oracle Corporation 12+33) OS: Mac OS X 10.14.4 x86_64

Graemes-iMac-2:simple graemelockley$ gradle wrapper Starting a Gradle Daemon (subsequent builds will be faster)

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0. Use '--warning-mode all' to show the individual deprecation warnings. See https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 3s 1 actionable task: 1 executed Graemes-iMac-2:simple graemelockley$ ./gradlew --version


Gradle 5.4.1

Build time: 2019-04-26 08:14:42 UTC Revision: 261d171646b36a6a28d5a19a69676cd098a4c19d

Kotlin: 1.3.21 Groovy: 2.5.4 Ant: Apache Ant(TM) version 1.9.13 compiled on July 10 2018 JVM: 12 (Oracle Corporation 12+33) OS: Mac OS X 10.14.4 x86_64

Graemes-iMac-2:simple graemelockley$ Graemes-iMac-2:simple graemelockley$ ./gradlew run

/Users/graemelockley/Projects/gradle-eta/examples/simple/eta/Main.hs:3:20: warning: [-Wunused-binds (in -Wextra)] Defined but not used: data constructor ‘PrintStream’ | 3 | data PrintStream = PrintStream @java.io.PrintStream | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Task :run Hello World!

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0. Use '--warning-mode all' to show the individual deprecation warnings. See https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 6s 5 actionable tasks: 4 executed, 1 up-to-date

Not sure how to proceed or assist you guys from here.

graeme-lockley commented 5 years ago

BTW the upgrading of the wrapper on the within the test sample makes no difference - sample still fails.

rahulmutt commented 5 years ago

Ok I think there are several issues here that occur at different JDK versions + different Gradle versions. I'll see if I can do a setup that tests this properly.

rahulmutt commented 5 years ago

@graeme-lockley I just released v0.8.1 which should fix the issues you're facing. On my system, Gradle 5.4.1 with JDK 12 seems to be working. Can you try again and let me know it goes?

argideritzalpea commented 5 years ago

I am able to build at the top level with Gradle 5.4.1, however, when I add "apply plugin: 'eta-android'" to my app/build.gradle, I receive these errors:

Unable to find method 'com.android.build.gradle.internal.api.DefaultAndroidSourceSet.getDisplayName()Ljava/lang/String;'.
Possible causes for this unexpected error include:
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)

Cause 1: org.gradle.api.GradleScriptException: A problem occurred evaluating project ':app'.
Caused by: java.lang.NoSuchMethodError: com.android.build.gradle.internal.api.DefaultAndroidSourceSet.getDisplayName()Ljava/lang/String;
Cause 2: java.lang.IllegalStateException: compileSdkVersion is not specified.
rahulmutt commented 5 years ago

@argideritzalpea This seems specific to the eta-android plugin. Perhaps there was a breaking change in the upstream android gradle plugin whose internal APIs we were using. I'll look into it and do another release, thanks for checking!

argideritzalpea commented 5 years ago

Thank you @rahulmutt ! Can't wait to get it working...

lingnand commented 5 years ago

I'm facing the same issue; the 'latest' set of plugins I can get working together is:

Anything higher runs into one of the problems outlined in the discussion.

Although it works, it's not great as it's missing all the updates and bug fixes in later versions of gradle-eta. So it's pretty common to run into some hard-to-scrutinize exit error 1 / 2 at build phase, especially when I need to modify some dependencies...

nganhkhoa commented 5 years ago

Using getStringName in eta-android

Should this be changed to getName, Android Gradle does not use getStringName anymore.

Here is what I found: android source gradle-3.4.0 branch

nganhkhoa commented 5 years ago

Gradle v4+ and v5 deprecates a lots, in v4, the methods still exist, but are purged in v5. The current source can be fix by changing getStringName to getName (of DefaultAndroidSourceSet android gradle build tools), getClassesDir() to getClassesDirs().getSingleFile() (of SourceSetOutput) and rewrite the OverridingProperty (implemented from interface Property<T>).

Also in newInstance method, null parameter is forbiden, #45. I couldn't find the source in Gradle but we cannot use null to init DefaultEtaSourceSet. Using java.util.Optional could make the build.

    public DefaultEtaSourceSet(Optional<SourceSet> sourceSet,
                               String name,
                               String displayName,
                               SourceDirectorySetFactory sourceDirectorySetFactory) {
        this.sourceSet = sourceSet.isPresent() ? sourceSet.get() : null;
        /// ...
    }

There are many more deprecated methods, but fixing these passes the compile error, gradle configure build.

However I cannot get the build to successfully loaded on Gradle Android project. The error code return is always No value has been specified for this provider., #38. Even with the latest Gradle version 5.6.3, the message is still unclear.

nganhkhoa commented 4 years ago

So the news is I got Android Studio to pass the build after register the resolvedEta provider with this:

        // EtaExtension.java
        resolvedEta.set(new ResolvedExecutable(
            parseStringProperty(project, "etlasPath"),
            parseStringProperty(project, "etlasVersion")
        ));

But I think my project configuration is wrong because I got:

[C:\Users\nganhkhoa\.gradle\caches\etlas\1.3.0.0\etlas.exe, --select-eta=0.7.2b1, deps, lib:app-debug] failed with ExitCode 1

I don't know why app-debug is there but I would like some advices to get this working and make a pull request after some code cleaning.

jneira commented 4 years ago

Great news! could you share your project configuration (ideally a link to the project) and the entire log produced by gradle -d -s?