Leiningen: Create executable jar to run without java -jar - jar

I'm trying to understand how to package a command line application written in Clojure for distribution. I don't want users to have to use java -jar myproject.jar arg1 arg2 to run the program. PHP has something called "Phar" files, which are basically executable zip files, so they include a shebang that tells POSIX systems how to unpack and run them.
I've seen other Clojure apps that allow the jar file to be set chmod +x and then executed directly. How do they achieve this? Uberjar just seems to make a jar that requires the java -jar prefix.

You can do this using lein-bin.

Ah, I just found the answer to my own question. It's not standard functionality and you basically have to roll your own: https://github.com/tailrecursion/boot/blob/master/Makefile#L21

Related

is there a way to ignore a scenario within the command java -cp karate.ja:?

I'm using a .jar, along with docker and a .sh to do the execution.
I use this command in .sh
java -cp karate.jar:./cases com.intuit.karate.Main "$#"
and I would like to use ~#ignore to not run some scenarios, is it possible?
Karate in version 1.1.0 onwards automatically ignores any scenario tagged as #ignore. Please refer the docs: https://github.com/karatelabs/karate#special-tags

Create questasim/modelsim project from the command line

I'm trying to write a makefile for compiling and simulating some vhdl code.
Is there a way to create a project from linux/windows command line ?
It is straightforward if you open the tool and run "project new" but there's no documentation for doing it from the command line.
I don't know how to use the project command directly from command line. But I've another method to do it. If you are into command line, you might know it already.
Anyway, you can write a .do file which contains the project commands then use vsim -c -do filename.do to execute it.
for example, my filename.do contains "project new . pro_name"
My recommendation would be not to use projects, they will get in the way.
As Rakend already mentioned just use .do files which are simple and you have a full Tcl interpreter to your disposal if you want to do some extra stuff.
If you want to use makefiles then compile your code manually and then run vmake to create the Makefile for you. However, vcom/vlog are quick so .do is all you need.
Good luck,
Hans.

run a "source" bash shell script in qmake

I want to use the intel compiler for Qt, but using the intel compiler implies running the script
$ source /opt/intel/bin/compilervars.sh intel64
Of course, I could add this to ~/.bashrc, but this would not run it in QtCreator, where it still complains about missing icpc. So I want it to be a part of the main mkspec qmake file.
How can I execute that full bash command in qmake?
Short Answer: Using QMAKE_EXTRA_TARGETS and PRE_TARGET_DEPS, you can execute source /opt/intel/bin/compilersvars.sh intel64, but simply sourcing them will not solve your issue.
Long Answer: The QMake file is converted into a Makefile. Make then executes the Makefile. The problem you will run into is that Make executes each command in its own shell. Thus, simply sourcing the script will only affect one command, the command that executes the script.
There are a couple of possible ways to make things work:
Execute the script before starting Qt-Creator. I've actually done this for some projects where I needed to have special environment variables setup. To make my life easier, I created a shell command to setup the environment and then launch Qt-Creator.
Within Qt-Creator, modify the Build Environment for the project I've also used this trick. In your case, simply look at the environment setup by the script and change the "Build Environment" settings under the project tab for your project to match those setup by the script.
It might also be possible to modify QMake's compiler commands, but I am not sure you can make it execute two commands instead of one (source the script then execute the compiler). Further more, this will make the project very un-transportable to other systems.
You can create a shell script that does more or less the following:
#! /usr/bin/env sh
# Remove the script's path from the PATH variable to avoid recursive calls
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export PATH=${PATH/$SCRIPT_DIR:/}
# Set the environment up
source /opt/intel/bin/compilervars.sh intel64
# Call make with the given arguments
make "$#"
Save it into a file named "make" in an empty directory somewhere, make it executable, then change the build environment in QT Creator to prepend PATH with the script's directory:
PATH=[dir-of-make-script]:${Env:PATH}
You can do this either in the project settings or once and for all in the kit settings.
Like this, QT Creator will be fooled into calling your make script which sets up your environment before calling the actual make binary. I use a similar technique under Windows with Linux cross-toolchains and it has been working well so far.

Eclipse Plugin- How to execute UNIX command from eclipse plugin?

I am writing an eclipse plugin that will take input of a file name, pass that to a UNIX command and get the output back (The command is to get file path of entered file name from CVS repository). My basic plugin code is under development, but I am not finding any info on how can I execute UNIX commands from eclipse. Any pointers would be helpful.
Runtime.exec(...) from the Java standard library should do what you need to execute UNIX shell commands that are in your path of the user that is executing eclipse. If you want to call UNIX C libraries API you can use the JNA library.

How to run initialize commands in Octave?

How do you set up Octave software to run initialization commands when it starts? For example, set the prompt (PS1) and cd to the project directory?
Thanks.
I have Octave installed in C:\Octave, so I did what you ask in file at location C:\Octave\3.2.4_gcc-4.4.0\share\octave\site\m\startup. File is called System-wide startup file for Octave and code I put in there is:
PS1('>> ');
addpath('{$path-to-my-octave-files}');
But any code is OK, I guess.
You could
write a script that does the start up routines you want and call octave afterwards
use
octave --persist --eval 'some_code_to_evaluate'
or
set the exec path with
octave --exec-path path_to_your_subprogramms
Personally, I wouldn't want octave to cd to the project directory, since projects directories can change. Furthermore, other features like the --eval command are not that easy to use anymore if you always have some default code running beforehand.

Resources