Gradle init isn't interactive - gradle

I am using gradle through command line for the first time. I am running the latest version of Ubuntu. My professor's instructions indicate that upon typing "gradle init" I should be prompted to say what type of project it is as well as the language, etc. Mine simply skips all of that and says "build successful" afterwards, my professors' file ends up with the proper directory structure and mine only has the basic root folders. From the quick searches I've done, I see that there is a difference between interactive and non-interactive responses, but I can't find anything regarding how to make it interactive.

My issue was I installed gradle with sudo apt install gradle which installs a very old version. Instead you can install sdk and then run sdk install gradle

If it says something along the lines of:
> Task :init SKIPPED
The build file 'build.gradle' already exists. Skipping build initialization.
BUILD SUCCESSFUL in 5s
Then it means you already have a Gradle build structure present. In order to initialize a new one, the directory you run it in must be empty.

I had this problem, too. Seems to be a bug.
You can tell gradle non-interactively what type to create, for example:
gradle init --type java-library
Other build types

Related

Install Kubectl Plugin on Windows

Question: What are the steps to install a kubectl plugin on Windows?
I have written a plugin standalone binary that I would like to invoke from within kubectl (following the instructions in https://kubernetes.io/docs/tasks/extend-kubectl/kubectl-plugins/)
The documentation for installation states to perform the following steps:
"A plugin is nothing more than a standalone executable file, whose name begins with kubectl-. To install a plugin, simply move this executable file to anywhere on your PATH."
This works fine on Mac and Linux, but performing those instructions on Windows does not seem to work. Running "kubectl plugin list" does not list my plugin and I cannot invoke it from within kubectl. I even tried adding my binary to the .kube directory autogenerated by kubectl, and it does not detect the plugin.
Several discussions on github reference this issue, without providing a response of how to install a kubectl plugin on Windows (ex: https://github.com/kubernetes/kubernetes/issues/73289). And after performing a lengthy google/stackoverflow search, there don't seem to be any tutorials/solutions that I (or my teammates) could locate. Any help would be much appreciated! Thank you.
In my case I don't have an issue with installing a plugin on Windows 10 machine (by simply including it on my PATH). Here is the output of 'kubectl plugin list':
c:\opt\bin>kubectl plugin list
The following kubectl-compatible plugins are available:
c:\opt\bin\kubectl-getbuildver.bat
- warning: c:\opt\bin\kubectl-getbuildver.bat identified as a kubectl plugin, but it is not executable
c:\opt\bin\kubectl-hello.exe
c:\opt\bin\kubectl-helloworld.p6
- warning: c:\opt\bin\kubectl-helloworld.p6 identified as a kubectl plugin, but it is not executable
error: 2 plugin warnings were found
Instead I'm encountering a known github issue: 'not supported by windows' error, while invoking my plugin with kubectl (v1.13.4).
c:\opt\bin>kubectl hello
not supported by windows
c:\opt\bin>kubectl-hello.exe
Tuesday
*kubectl-hello.exe - is console application written in csharp. I tried also to use Windows batch file and Perl6 program as plugins, but none of these worked out on Windows.
I think only .exe file extensions are considered as executables by kubectl when it searches for plugins in the $PATH when running in Windows environment.
I tested by creating a simple HelloWorld App as a single file executable, added it to my system's $PATH and it got picked up and executed correctly.
kubectl krew like brew to manage the kubectl plugin. You can try it. It supports Window.
https://github.com/kubernetes-sigs/krew

bazel build gives "Argument list too long" error

Trying to build go application using bazel. It fails due to multiple packages and source files present within the application.
OS: Mac OS (High Sierra)
Bazel version : 0.11.1 (homebrew)
Go rules: 0.11.0
Defined local_repository in WORKSPACE to get external dependencies
Running following command
bazel build //go-app
leads to error
Action failed to execute: java.io.IOException: Cannot run program
"/usr/bin/sandbox-exec" (in directory
"/TEMP_DIR/PATH"):
error=7, Argument list too long
Target //go-app:go-app failed to build
I came across https://docs.bazel.build/versions/master/skylark/lib/Args.html#use_param_file and thought it would fix my issue. Could anyone point me in the direction of how and where to implement this in my BUILD file and make it work? Thanks.
I think it's not in your BUILD file but rather in rules_go.
I'd recommend opening them an issue since AFAIK this is something the rule implementation needs to support.
For example in rules_scala we write the arguments to a file and then pass that file to the worker exactly like how you mention above.
https://github.com/bazelbuild/rules_scala/blob/master/scala/private/rule_impls.bzl#L274

Cannot execute Git commands from Gradle build script on Windows 10

I have recently forked and cloned a repositroy from GitHub that uses Gradle, but I am unable to execute any Gradle tasks.
It fails on:
def process = 'git rev-parse --short HEAD'.execute()
with:
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\Joseph\Desktop\Minecraft\ObsidianSuite\ForgeGradle\ForgeGradle\build.gradle' line: 286
* What went wrong:
A problem occurred evaluating root project 'ForgeGradle'.
> Cannot run program "git": CreateProcess error=2, The system cannot find the file specified
I am running Windows 10, and have Git working with MinGW. I have set the path variable to include (C:\Program Files\Git\cmd) such that I can run Git from command prompt. The Git command that is called by the build.gradle file executes fine if I run it from the command line, it is just not working when run through the Gradle wrapper.
Any help or advice would be much appreciated; I am able to answer any questions that might help work out what the issue is. Thanks.
EDIT: I normally use Git by running git-bash in the relevant folder rather than git from command prompt.
I have found a solution, it doesn't provide an answer to why it wasn't working originally, but gives a work around.
I followed this answer to install GitHub for Windows and changed the old Git path variable to the one the tutorial suggested. Although I don't want to use the GitHub software (I like doing everything via git-bash), at least Gradle is happy with it now.
Not sure if this is the same problem.
I am using Android studio here. When gradlew build is executed, def process = 'git rev-parse --short HEAD'.execute() returns empty, but there is no problem in local execution.
Solution:
The solution is: modify the jdk path used by gradlew, use java jdk. (Do not use the sdk that comes with android studio)
Screenshot:
enter image description here
Please, don't call executables from Java/Groovy/Gradle/etc. There are many java/groovy libraries to deal with Git repositories, including Gradle plugins

go 1.5 : Is "go install" behaviour changed? Removing stale executables?

Till Go 1.4.2 when i run go install after running go build, i could find binary file in my current folder. Hence following Linux command was working
$ go build && go install && ./executable
But after installing go 1.5, when i run same command i get,
-bash: ./executable: No such file or directory
and when i checked, there is no executable to find. Did go install behavior changed in Go 1.5?
Yes, the behaviour has changed in Go 1.5:
If 'go install' (with no arguments, meaning the current directory) succeeds, remove the executable written by 'go build', if present. This avoids leaving a stale binary behind during a sequence like:
go build
<test, mostly works, make small change>
go install
Before this CL, the current directory still has the stale binary from 'go build'. If $PATH contains dot, running the name of the program will find this stale binary instead of the new, installed one.
I can't find anything mentioning that in the release notes though. Might be a documentation issue.
It seems like the solution is to use the binary that go install has produced.
EDIT: Here is the issue on the Go issue tracker if you want to follow on updates. Should be fixed by 1.5.1.

GVM installed gradle is not recognized in Linux terminal

Recently installed gradle via gvm and $ gradle build throws the following error message.
If 'gradle' is not a typo you can use command-not-found to lookup the package that contains it, like this: cnf gradle
Obviously, class path issues, So I have tried echo $GRADLE_HOME outputs
/home/karthikeyan/.gvm/gradle/current
But the actual binary is at /home/karthikeyan/.gvm/gradle/2.3/bin (exporting this to path variable,works). What if I am switching between the versions? Is there any general solution ?
You should always use $GRADLE_HOME which points to $HOME/.gvm/gradle/current/- so if not $GRADLE_HOME use the latter path.
If there's a need to switch between versions use the following command:
gvm use gradle <version>
The ../current/ path is a symlink that points the version of gradle being in use. It's done in the following way to ease the usage - just add ../current path to $PATH and it's done, instead of switching the versions manually every time new version is installed.

Resources