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

Default dependencies for Groovy Script #1151

Closed
linux-china opened this issue Dec 24, 2021 · 4 comments
Closed

Default dependencies for Groovy Script #1151

linux-china opened this issue Dec 24, 2021 · 4 comments
Labels
ideas Some idea/suggestion around jbang behavior/feature set

Comments

@linux-china
Copy link
Contributor

Now JBang Groovy just bundles with org.apache.groovy:groovy:version dependency, but it's not enough because most Groovy developers use org.apache.groovy:groovy-all:version to include all dependencies for Groovy Script code.

According to https://lists.apache.org/thread/2hps5gt689g6w063ol4ghr17vymvy49m Some dependencies should be added for JBang script to make life easy.

The following dependencies will be included for JBang Groovy script by default.

  • groovy
  • groovy-ant
  • groovy-astbuilder - 3.0
  • groovy-cli-commons
  • groovy-cli-picocli
  • groovy-datetime
  • groovy-dateutil
  • groovy-jaxb
  • groovy-json
  • groovy-ginq - 4.0
  • groovy-macro
  • groovy-nio
  • groovy-sql
  • groovy-templates
  • groovy-toml - 4.0
  • groovy-xml
  • groovy-yaml

Other dependencies, such as groovy-servlet, groovy-swing etc will be introduced by //DEPS.

@linux-china linux-china added the ideas Some idea/suggestion around jbang behavior/feature set label Dec 24, 2021
@maxandersen
Copy link
Collaborator

Why would we want these to be added by default ? Not every groovy file needs all those dependencies.

@linux-china
Copy link
Contributor Author

I have this question too. For most Groovy developers just choose org.codehaus.groovy:groovy-all:3.0.9 for their application, not to select every dependency because it's default option by Gradle.

If you use gradle init to create Groovy app, and org.codehaus.groovy:groovy-all:3.0.9 is included by default. Yes, most Groovy projects are built by Gradle. I think this is the reason why most Groovy developers don't like to add groovy-xml, groovy-json, groovy-sql etc.

dependencies {
    // Use the latest Groovy version for building this library
    implementation 'org.codehaus.groovy:groovy-all:3.0.9'

    // This dependency is used by the application.
    implementation 'com.google.guava:guava:30.1.1-jre'
}

From Groovy's dependencies list, and most dependencies are small except groovy-3.0.9.jar, and it's still ok to include these dependencies.

7.6 MB  groovy-3.0.9.jar
 85 KB  groovy-ant-3.0.9.jar
 10 KB  groovy-astbuilder-3.0.9.jar
 63 KB  groovy-cli-picocli-3.0.9.jar
1.5 MB  groovy-console-3.0.9.jar
 19 KB  groovy-datetime-3.0.9.jar
123 KB  groovy-docgenerator-3.0.9.jar
162 KB  groovy-groovydoc-3.0.9.jar
977 KB  groovy-groovysh-3.0.9.jar
134 KB  groovy-jmx-3.0.9.jar
130 KB  groovy-json-3.0.9.jar
 21 KB  groovy-jsr223-3.0.9.jar
231 KB  groovy-macro-3.0.9.jar
 33 KB  groovy-nio-3.0.9.jar
 26 KB  groovy-servlet-3.0.9.jar
 81 KB  groovy-sql-3.0.9.jar
420 KB  groovy-swing-3.0.9.jar
 95 KB  groovy-templates-3.0.9.jar
120 KB  groovy-test-3.0.9.jar
 13 KB  groovy-test-junit5-3.0.9.jar
9.5 KB  groovy-testng-3.0.9.jar
289 KB  groovy-xml-3.0.9.jar

For JBang Groovy script, I think we can add some useful dependencies for Groovy developer, and not to throw ClassNotFoundException then ask him to add dependencies. For junior developers, they event don't know how to choose the dependency for absent class because they always use Groovy SDK and groovy-all.

Maybe we can ask some senior groovy developers to confirm this issue.

@maxandersen
Copy link
Collaborator

same arguments against this as #1160 but even more so for groovy, at least using
org.codehaus.groovy:groovy-all:3.0.9 since this has a massive dependency set and its just not right. Yes, you can use it in default getting started templates if you want to but its honestly bad practice to add this.

In addition, I have a big issue with build.gradle projects that use it like:
implementation 'org.codehaus.groovy:groovy-all:3.0.9' - that dependency is a .pom file not a .jar meaning when you deploy a project that uses this it is only usable from gradle - not maven nor jbang as the generated pom.xml is invalid.

See #1065 and related issues. It is a mess caused by gradle / groovy community IMO. It can be fixed if gradle would actually generate the proper corresponding pom.xml - not something I see (at least for now) a way JBang can really remedy.

And about senior groovy I'll just let this tweet stand on its own: https://twitter.com/aalmiray/status/1474061356483727369 :)

@linux-china
Copy link
Contributor Author

I agree. Now I think groovy-version.jar is enough JBang Groovy script, and of course every Groovy script needs this jar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ideas Some idea/suggestion around jbang behavior/feature set
Projects
None yet
Development

No branches or pull requests

2 participants