groovy binary edition vs groovy-all-jar - shell

When I want to download groovy from here http://groovy-lang.org/download.html I get the "binary release". This means I have a directory structure with a lib and bin and an embeddable folder. In the bin folder there is a groovy shell script that let's me execute my own groovy sourcefiles. This groovy shell script uses the jarsin the lib directory. I however want it to use the jars in the groovy-all-jar in the embeddable directory. The reason is, that I dont want all the jars in the jar directory in my classpath as I need to use different versions.
How can I make the groovy shell script using the groovy-all-jar?

groovy-all is usually for applications that want to support Groovy. So you just put it in your classpath.
If you want to use something like GroovyConsole from groovy-all using the shell scripts, you will have to edit the startGroovy. I suggest doing the following... remove everything in lib. Then find the line where STARTER_CLASSPATH is frist set and change it to use your groovy-all. I have not tested it, but that should work.
Since groovy-all contains only asm, commons-cli and antlr (in a jarjared version) anything that needs for example Jline (the shell console) will not work

Related

Bash autocompletion does not fill out names of Java classes in the current directory

I am using Linux command line to execute my java code. Thus, I used javacommand to execute .class file. But What makes me confused is that autocompletion using the tab key does not extend to the names of classes (which need to be given without extensions).
That is to say, if I'm in a directory with HelloWorld.java and HelloWorld.class, and I type java H and press the tab key, I intend the command to be replaced with java HelloWorld.
How can this be resolved?
To run java from bash you need to do the following
java -cp <classpath> com.package1.package2.MyClass
If your question is why when you click tab bash suggests something like
java -cp <classpath> MyClass.class
Then this is because to start java you need to provide full class name not filename. And bash suggests existing filenames, it knows nothing about java classes and how they are mapped to files.
You don't have to add .class when you run java User.class: just run java User.

How Do You Specify Where The Gradle Wrapper Installs Gradle?

I have an off the shelf application that ships a version of gradle with it. It also has scripts that are hard coded to set GRADLE_HOME to this location.
I want to zip up this dir, put it in nexus and replace it with the gradle wrapper.
How do I configure the gradle wrapper to download this zip from nexus and extract it to a specific location in the project?
EDIT: In the gradle-wrapper.properties I have
distributionPath=wrapper/gradle
However, I end up with it being unzipped to
...\wrapper\gradle\gradle-2.3-bin\8gn7esgljqyucijpbynjk93oc\gradle-2.3
How do I get it to unzip to the path I specified and not to the subdirs?
The location to which Gradle gets unpacked is a combination of the distributionBase and distributionPath properties in gradle-wrapper.properties file. The location specified by distributionPath will always be considered as relative to distributionBase. The only available values for distributionPath are GRADLE_USER_HOME and PROJECT. Even when using PROJECT the wrapper will still generate the folder structure you see above.
If you want to control this more precisely I'd suggest not relying on the wrapper to do this and instead add a task to your build specifically for this purpose.

How can I make “gradle --console=rich” the default?

Along the lines of this answer (which works for me, BTW) and the javadocs, I tried
gradle.startParameter.consoleOutput = org.gradle.api.logging.configuration.ConsoleOutput.Rich
in my ~/.gradle/init.gradle. However, I still need --console=rich to get color output. Why?
Tested with Gradle 2.14.1 and 3.2.1.
Terminal is cygwin urxvt with TERM variable set to rxvt-unicode-256color.
Since Gradle 4.3 you can use org.gradle.console property in gradle.properties:
org.gradle.console=rich
A new console verbose mode will print outcomes of all tasks (like UP-TO-DATE) like Gradle 3.5 and earlier did. You can set this via --console=verbose or by a new Gradle property org.gradle.console=(plain rich verbose).
I am not sure if you can force the rich console from a gradle script, as the detection happens likely before the script is interpreted.
NativeServices class provides the integration with the console. If you look at the source code, there are two messages possibly printed in log:
Native-platform terminal integration is not available. Continuing with fallback.
Unable to load from native-platform backed ConsoleDetector. Continuing with fallback.
The latter might give you more information why. Try running the gradle script with --debug. You will likely find out that you are missing a native library that is either not available in cygwin or it is, but is not on library path.
I believe it works when you specify the rich console from the command line, because gradle forces the colours even though the console doesn't indicate it supports them.
Does it work if you don't use the cygwin console in Windows native command line or maybe GitBash?
There is a workaround how you can make this work. You can create an alias in cygwin that will always add the --console=rich.
If you are using gradle wrapper, you can edit the gradlew script and add the command line parameter. To make it automated, you can change the wrapper task to alter your script in the doLast part.
Create a file called gradle.properties inside your ~/.gradle/ folder.
Inside gradle.properties, add the line org.gradle.console=rich.
Each builds will run under --console=rich automatically because the new gradle.properties will be merged with the gradle.properties of your project.
If your project's gradle.properties contains the same tag as the local file, your project's will be used overriding the local file's
If you are on Linux/Mac set
alias gradle='gradle --console rich'
in your ~/.bashrc.
In Gradle Wrapper, add the following line:
org.gradle.console=rich
to ./gradle.properties in the root folder, where the gradlew script is located.

maven, ant, or gradle plugin to execute cygwin cygpath?

Does anyone know of a maven, ant, or gradle plugin that supports invoking cygpath? The cygpath utilities knows how to convert Windows filesystem paths (c:\dev) to cygwin/unix style file paths (/cygdrive/c/dev).
I've searched the internet but didn't find anything. The closest is this jenkins plugin (https://wiki.jenkins-ci.org/display/jenkins/cygpath+plugin).
Context:
I'm trying to automate creating an omniORB maven artifact from the omniORB source tarball. One of the first things I have to do is patch the omniORB source with filesystem paths that match our development environment. On every developer's machine we have an environment variable the specifies the location of their maven repo e.g. c:\mvrepo. The omniORB Windows binaries are built with cygwin. I need to set the omniORB makefile to locate some dependencies from c:\mvnrepo\some-dependency but with a cywin-style path /cygdrive/mvnrepo/some-depenendency.
I cant vouch for it a I haven't used it or looked at it closely but here is a gradle plugin that might be of use: https://github.com/derianto/Gradle-Cygwin-Toolkit-Plugin
In any case, since gradle scripts are written in groovy it should be fairly easy to just code your own solution into your build script if you have to.

how do I import my intellij project settings on a groovy script in terminal

I have a single script in a project in intellij that I want to run in my mac terminal. I can run the script but I am getting errors where it can't find the JAR files I added as a module. There are a lot of dependencies, so I was wondering how can I add my intellij project settings to calling my groovy script. Right now all I have is this:
groovy CreateReport.groovy
Turns out all you need to do is dump your libraries into the GROOVY_HOME/lib directory, where GROOVY_HOME is where you have defined your groovy environment variables to be.
http://dustinwhitney.blogspot.com/2008/03/groovy-classpath.html

Resources