Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Gradle? #83

Closed
aadrian opened this issue Jun 3, 2021 · 19 comments
Closed

Support Gradle? #83

aadrian opened this issue Jun 3, 2021 · 19 comments

Comments

@aadrian
Copy link

aadrian commented Jun 3, 2021

Hi

Any chance supporting Gradle too? (since Maven is supported)
https://docs.gradle.org/current/userguide/viewing_debugging_dependencies.html

Gradle is being used with or without a Clojure specific plug-in https://clojurephant.dev/clojurephant/ for Clojure/ClojureScript projects.

Thank you.

@liquidz
Copy link
Owner

liquidz commented Jun 3, 2021

@aadrian Thanks for your suggestion!

Any chance supporting Gradle too? (since Maven is supported)

Yes, I thought about supporting it once, but I didn't use Gradle, so I put it off.
Do you know build.gradle parser library that is often used?

If there is a library which can rewrite build.gradle, we can support upgrading dependencies too.

@aadrian
Copy link
Author

aadrian commented Jun 4, 2021

Do you know build.gradle parser library that is often used?

@liquidz I'm not aware of any 3rd party libraries that could "parse" a build.gradle since that file is not a configuration file but a DSL that gets executed/interpreted by Gradle (and it can contain dynamic parts and modules, or can be scripted).

(So it's important not just what it's declared there, but what gets interpreted/solved when executed - similar to a Maven BOM .)

For that to be correct, I think one would need Gradle itself to get the right list:

  1. Using Gradle as an API (since it's a bunch of JARs. https://docs.gradle.org/current/javadoc/index.html?overview-summary.html ) . I have however no working example for this, but maybe it's quite simple.

  2. Calling Gradle directly from a shell with: %> gradle dependencies and parsing that text output https://docs.gradle.org/current/userguide/viewing_debugging_dependencies.html#example_rendering_the_dependency_report_for_a_custom_configuration . Many do this for almost every project automatically by executing a "gradle depencencies > deps.txt" and to keep track of 3rd party dependency changes by committing that deps.txtto a VCS.

@liquidz
Copy link
Owner

liquidz commented Jun 4, 2021

@aadrian Thanks for your confirmation!

Many do this for almost every project automatically by executing a "gradle depencencies > deps.txt" and to keep track of 3rd party dependency changes by committing that deps.txtto a VCS.

Good to know.
gradle command is needed for Gradle project anyway, so using the results of gradle dependencies seems good for me (however we can't support upgrading)

It looks appropriate to use the following command results, but is it common to specify devRuntimeClasspath ?

$ gradle -q dependencies --configuration devRuntimeClasspath

@aadrian
Copy link
Author

aadrian commented Jun 5, 2021

@liquidz

however we can't support upgrading

That's not a big issue.

Just getting a list of outdated dependencies would be extremely useful.

but is it common to specify devRuntimeClasspath ?

Not in my experience so far, just gradle dependencies since it shows everything needed.

Many just have a Git Hook on Gradle files (build.gradle, settings.gradle, gradle.properties) changes to commit the gradle dependencies > deps.txt file too. This way 3rd party, or transitive, or scope changes are visible in the history very easily.

If you ask if it's common for users to use different dependency scopes with Gradle, than yes, but most users prefer the Maven scopes https://www.baeldung.com/maven-dependency-scopes, since all artifact repos are Maven repos.

@liquidz
Copy link
Owner

liquidz commented Jun 5, 2021

@aadrian Thanks!

Not in my experience so far, just gradle dependencies since it shows everything needed.

OK.
gradle dependencies outputs a lot of information, so I was hoping to filter it if I could.

I'll try to use gradle dependencies simply.

liquidz added a commit that referenced this issue Jun 7, 2021
@liquidz
Copy link
Owner

liquidz commented Jun 7, 2021

@aadrian I'm trying to support Gradle in feature/gradle branch.

Seems to be good for now :)
screen_shot_2021-06-08 6 31 57

@aadrian
Copy link
Author

aadrian commented Jun 8, 2021

...support Gradle in feature/gradle branch.

@liquidz wow ! This looks great!

liquidz added a commit that referenced this issue Jun 18, 2021
liquidz added a commit that referenced this issue Jun 18, 2021
@liquidz
Copy link
Owner

liquidz commented Jun 21, 2021

@aadrian Sorry for late action.
I've supported Gradle in feature/gradle branch.
Could you try this branch?

  • run make uberjar to generate target/antq-standalone.jar
  • run java -jar /path/to/your/antq/repo/target/antq-standalone.jar in your project directory

BTW, do you know how to print repositories which is defined in build.gradle via gradle command?
Currently, I cannot supporting custom repositories in build.gradle.

@aadrian
Copy link
Author

aadrian commented Jun 22, 2021

do you know how to print repositories which is defined in build.gradle via gradle command?

@liquidz When having more complex projects and using more than one repo, some add this task:

task listrepos {
    doLast {
        println "Repositories:"
        project.repositories.each { println "Name: " + it.name + "; url: " + it.url }
   }
}

so that one can call just gradle listrepos from the CLI.

@liquidz
Copy link
Owner

liquidz commented Jun 22, 2021

@aadrian Thanks!
Hmm, there is no way without updating build.gradle after all.
It may be good to put it together as a setup steps.

@liquidz
Copy link
Owner

liquidz commented Jun 25, 2021

@aadrian Could you review setting up steps?
https://github.com/liquidz/antq/blob/feature/gradle/doc/gradle.adoc

If you OK, I'll merge #91 and release :)

@liquidz
Copy link
Owner

liquidz commented Jul 9, 2021

@aadrian ping :)

@aadrian
Copy link
Author

aadrian commented Jul 10, 2021

ping

@liquidz I'm sorry - I missed the changes to this issue (and to the other issues where I'm involved :( ).
GitHub seems to have changed the UI: there's no more "Recent Activity" detailed pane on the main page (only "All Activity") :( .

Could you review setting up steps?

The steps look OK. to me.

I've tried them again however (with Gradle 6.x) but unfortunately now I'm getting:

Process 'command 'xxx.java'' finished with non-zero exit value 1

for Java 8 (on all OSes: Windows/Mac/Linux)

@liquidz
Copy link
Owner

liquidz commented Jul 10, 2021

@aadrian

Process 'command 'xxx.java'' finished with non-zero exit value 1

Ah, sorry.
This is because build.gradle is referring the latest release.

runtimeOnly 'com.github.liquidz:antq:latest.release'

You should see the following message.

> Task :outdated
No project file

feature/gradle branch is not released and deplyed yet.

Could you try the following step to use local JAR file?

  • In antq project
    • make uberjar to generate target/antq-standalone.jar
  • In gradle project
    • mkdir libs
    • cp -pi /path/to/antq/project/target/antq-standalone.jar libs
    • Update build.gradle to use runtimeOnly files('libs/antq-standalone.jar') instead of runtimeOnly 'com.github.liquidz:antq:latest.release'
    • Then execute gradle outdated

@aadrian
Copy link
Author

aadrian commented Jul 11, 2021

Could you try the following step to use local JAR file?
make uberjar to generate target/antq-standalone.jar

@liquidz I suppose you mean to do that for the "feature" branch.
The master branch unfortunately fails to compile at all with Linux and OSX too:

...
Downloading: org/apache/logging/log4j/log4j-api/2.14.1/log4j-api-2.14.1.jar from central
Downloading: org/clojure/java.classpath/1.0.0/java.classpath-1.0.0.jar from central
Syntax error compiling at (hf/depstar/aot.clj:116:23).
No such var: t/create-basis

Full report at:
/tmp/clojure-1401688395185842351.edn
make: *** [Makefile:29: target/antq-standalone.jar] Error 1

Then execute gradle outdated

This kind of works, but it still has issues. E.g. for a new project created with gradle init --type=java-application , If I add what you mentioned in the wiki (+ the locally created JAR), I'm getting:

> Task :app:outdated
git ls-remote failed on: https://github.com/junit-team/junit4/tree/master/
The tag for current version is not found: https://github.com/junit-team/junit4/tree/master/
Diff is not supported for https://github.spockframework.org/spock/

|        :file |                          :name |       :current |           :latest |
|--------------+--------------------------------+----------------+-------------------|
| build.gradle |         com.google.guava/guava |       29.0-jre |        30.1.1-jre |
|              |                    junit/junit |           4.13 |            4.13.2 |
|              | org.codehaus.groovy/groovy-all |         2.5.13 |             3.0.8 |
|              |  org.spockframework/spock-core | 1.3-groovy-2.5 | 2.0-M5-groovy-3.0 |

> Task :app:outdated FAILED

FAILURE: Build failed with an exception.

@liquidz
Copy link
Owner

liquidz commented Jul 11, 2021

@aadrian Thanks for your confirmation!

I suppose you mean to do that for the "feature" branch.

Right.

The master branch unfortunately fails to compile at all with Linux and OSX too:

It's a problem in the latest version of depstar.
So I had fix to use a specific version of depstar in feature branch. (0e22d9f)

This kind of works, but it still has issues. E.g. for a new project created with gradle init --type=java-application , If I add what you mentioned in the wiki (+ the locally created JAR), I'm getting:

It seems work as expected for me.
What is your expected behaviors?

FYI, here is output in my environment.

$ gradle --version

------------------------------------------------------------
Gradle 7.0.2
------------------------------------------------------------
...

$ gradle outdated

> Task :app:outdated FAILED

|        :file |                  :name | :current |    :latest |
|--------------+------------------------+----------+------------|
| build.gradle | com.google.guava/guava | 30.0-jre | 30.1.1-jre |
|              |            junit/junit |   4.13.1 |     4.13.2 |

Available diffs:
- https://github.com/junit-team/junit4/compare/r4.13.1...r4.13.2

FAILURE: Build failed with an exception.

There is no available diff URL for guava, because the pom file doesn't have scm tag.

@aadrian
Copy link
Author

aadrian commented Jul 12, 2021

It seems work as expected for me.

I understand.

What is your expected behaviors?

To have no error message when:

  • there's no error in the Gradle file
  • or the build process or
  • with the Internet/proxy connection

so, to have return code 0 for a script that behaves as expected.

There is no available diff URL for guava, because the pom file doesn't have scm tag.

I see.
For such cases indeed, a tool can't do much: maybe at most, just prepare a "text template" so that the user fills a bug request with that project for "missing scm tag for published artifact" :) .

@liquidz
Copy link
Owner

liquidz commented Jul 12, 2021

@aadrian

so, to have return code 0 for a script that behaves as expected.

antq is a tool to detect outdated dependencies, so returning code 0 means "there are no outdated dependencies".
I have no plan to change this specification for now.

For such cases indeed, a tool can't do much: maybe at most, just prepare a "text template" so that the user fills a bug request with that project for "missing scm tag for published artifact" :) .

scm tag is optional, and antq just refers to it, so I cannot say it is a bug 😓
The diff URL is a useful feature, but it is not a main feature, so only showing what can be shown is the current stance.

@liquidz
Copy link
Owner

liquidz commented Jul 14, 2021

@aadrian I've cut a release #95
Thanks for your suggestion!

@liquidz liquidz closed this as completed Jul 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants