GVM installed gradle is not recognized in Linux terminal - gradle

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.

Related

protoc-gen-go specific version require

I need a pre build project and I need a version of protoc-gen-go v1.25.0-devel but I am unable to find command etc to install It , till now I tried to do something like this :
go get -u google.golang.org/protobuf/cmd/protoc-gen-go#v1.25.0-devel
and I am getting this ERROR invalid version: unknown revision cmd/protoc-gen-go/v1.25.0-devel
Is there any way to get this version ?
If you're following this post to create a sample service, you don't need the specific version 1.25.0-devel that appears in the generated files. You should use the latest stable version (currently v1.26.0). Since it is an minor version upgrade, there should be no breaking changes between versions. One thing that you may need to make the examples in the post to work is that you should set the package for the generated code. You can set it in the .proto file as an option, for example option go_package = grpc-example/generated/protos/calc or as a command line argument for the protoc command, for example protoc ...OTHER_OPTS --go_opt=Mprotos/calc.proto=grpc-example/generated/protos/calc.
If you are sure that you absolutely need the specific version v1.25.0-devel you can install the plugin pointing to a specific commit (as that version is not currently available as a tag/branch name). If you're using go 1.16.x you can use go install google.golang.org/grpc/cmd/protoc-gen-go-grpc#a9513eb pointing at this commit. For older go versions, use go get

Gradle init isn't interactive

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

Is there a robust way to set MAVEN_HOME in my ~/.zshrc without specifying the version number? (MacOS)

Context: I install maven with brew install maven
In my ~/.zshrc I have:
# Maven (mvn --version)
export MAVEN_HOME="$HOME/usr/local/Cellar/maven/3.6.3"
export PATH=$MAVEN_HOME/bin:$PATH
Is there a way to set my MAVEN_HOME in a way that allows me to not have to increment it when Maven is upgraded to 3.6.4?
It is somewhat tedious to have to go into my config file and update it every time I update Maven! :)
This would also help an onboarding/setup script that could download maven and programmatically set up a ~/.zshrc or ~/.bashrc config
What i have done to solve this problem is to create a symbolic link that points to maven installation version.
ln -s maven_3.6.4_path maven_slink
And set the MAVEN_HOME=maven_slink in configuration file. And every time i need to change maven version all i have to do is drop maven_slink and create a new maven_slink that points to the maven installation. I don't need to go change configuration files every time I install a new version of maven.
Per #chepner: /usr/local/bin/mvn is a symlink to the latest installed version when installed via homebrew.
I changed export MAVEN_HOME="/usr/local/Cellar/maven/3.6.3/mvn" to export MAVEN_HOME="/usr/local/bin/mvn" in my ~/.zshrc config and everything is good to go.
I work on windows and i have created folder dev-env and the path of this folder i have added in PATH variable.
I have installed the version of java jdk8, jdk9, jdk11, jdk13.
I have created bat files and place them in dev-env : jdk8.bat ,jdk9.bat, jdk9.bat, jdk11.bat and jdk13.bat.
Inside a bat files I do the switch of version of java.
#echo off
set JAVA_HOME=path to jdk version
set PATH = %JAVA_HOME%\bin+PATH
java -version
Same thing in maven . I created different bat files maven3.bat, maven36.bat.
#echo off
set MAVAEN_HOME=path to jdk version
set PATH = %MAVEN_HOME%\bin+PATH
mvn -version
So , If i want to switch from one version to another. I open the cmd and the run the bat file that has the version that i want.

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

Can Maven install my plugin as a system tool?

I want my plugin, which is placed in the Maven Central repo, to be installed as a system tool. I.e. to create a shortcut to a jar's executable class when obtaining it from the repo.
So I need something very similar to a nice Ruby's gem tool. Like when I type
sudo gem install capistrano
I instantly get 'cap' tool on the command line. Is there any way to achieve similar behaviour in Java?
You could distribute a shell script, using Maven, but there would be no mechanism to make it executable.
My suggested work-around on unix systems would be an alias:
alias ivy='java -jar $HOME/.m2/repository/org/apache/ivy/ivy/2.2.0/ivy-2.2.0.jar $*'
enabling you to execute the jar as follows:
$ ivy -version
Ivy 2.2.0 - 20100923230623 :: http://ant.apache.org/ivy/
I have developed such tool here.

Resources