Can Maven install my plugin as a system tool? - maven

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.

Related

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

How do I turn Keycloak old version 4.1.0 into 'Standalone server distribution'?

I tried something (readme.md, blog etc).But I don't turn 'standalone server distribution'.
I can give an example. What I want to say:
The following is a 'standalone server distribution' files. This is ready for running.
Picture-1
I need to run old version keycloak (version 4.1.0). This package seem like this :
Picture-2
According to Picture-2, this packages don't ready for running.
How can I ready for running ? Like to Picture-1.
I need your suggestions and suggestions. Can you help me?
Greetings,
That's the source code.
You have to build it by executing the following command from parent directory (you need Java JDK and Maven installed and configured):
mvn -Pdistribution -pl distribution/server-dist -am -Dmaven.test.skip clean install
Resulting release distribution will be in ./distribution/server-dist/target/keycloak-4.1.0.Final.zip archive.
Compiling the sources is described here: https://github.com/keycloak/keycloak/blob/master/docs/building.md
You can download the latest release version 4.X from archive: https://www.keycloak.org/archive/downloads-4.8.3.html

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

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.

Where can I find a tutorial for installing and running cascading.jruby?

I have Hadoop installed and testing fine, however unable to find any instructions for a n00b on
How to setup cascading and cascading.jruby. Where to place the cascading Jars and how to configure jading to build the ruby assemblies correctly?
Is anyone using jenkins to build this automatically?
Edit: more details
I'm trying to build the example word count job from https://github.com/etsy/cascading.jruby
I've installed
hadoop, and run the tests successfully.
installed jruby
gem install cascading.jruby
jade - https://github.com/etsy/jading
installed ant
created the wordcount sample wc.rb
Run jade to compile the wc.rb to a jar
jade wc.rb
I get the following compile error
Buildfile: build.xml does not exist!
Build failed
RuntimeError: Ant retrieve failed
(root) at /usr/bin/hjade:89
Which makes sense looking at the jade code, but this isn't covered in the example usage? What am I missing here?
Sorry for the delay; this is my first answer, here.
The issue you describe, Jading not being able to locate its Ant build script when called from a symlink, is indeed an issue. I'd recommend just adding your Jading clone to your PATH rather than creating symlinks (or submit a pull request to fix the issue!).
To address some of your other concerns, I've created a Getting Started page in the Jading wiki which may be of some help. It walks you through getting up and running with local and remote cascading.jruby jobs without installing anything besides preqs (Java, Ant, JRuby, and the Hadoop client+config). Included now is a full example wordcount script that should function both locally and on a Hadoop cluster, and has been tested on Etsy's own internal cluster.
And backing up further still to address your question about Jenkins, yes, at Etsy we use Jenkins to build and deploy cascading.jruby (and Scalding) to our cluster. However, that build process does not currently use Jading to produce the job jar. Our build predated Jading and Jading was an attempt to release a cleaner version of the process we go through to build that jar. Our build could easily using Jading (and the original examples came from actual uses on our code), but we have slightly different requirements for the artifacts produced by our build.
If you have any other issues with Jading, feel free to submit issues or pull requests to the github project.
If you are using jruby. You must be using bundler as well. In that case you can add cascading.jruby as a dependency in your gemfile.
You could anyways try installing from your project folder as:
gem install 'cascading.jruby'
Hope this Helps.
I've got the working end to end now.
I had created symlinks to the hadoop, jading binaries in /usr/local/bin
The scripts need to be run from their own directories in order to find the supporting files
i.e. the following works: (assuming the cascading.jruby example is in ~/dev/cascading.jruby.demo/wc.rb
cd /usr/local/jading
./jade ~/dev/cascading.jruby.demo/wc.rb
# creates a jade.jar locally in jading folder
cd /usr/local/hadoop
./bin/hadoop jar /usr/local/jading/jade.jar ~/dev/cascading.jruby.demo/wc.rb ~/dev/cascading.jruby.demo/sampledata/in.txt

Resources