Where to put wrapper scripts in Buildr? - scala

I'm developing a set of command line tools in Scala, using Apache Buildr as my build system. I'd like to include a wrapper script for each tool. Something like this:
#!/bin/sh
scala myclass $#
These scripts should be installed alongside my jar when I type buildr install. Is there a special directory Buildr recognizes for wrapper scripts like this? If not, how can I make Buildr install the scripts? I've tried putting the scripts in src/main/resources, but this packages them inside the jar, which is not what I want.

As commented, there are ways to make this happen by creating a separate packaging to encompass the scripts and the tool. Here is an example that bundles a jar and a set of scripts to run the jar with parameters.

Related

Run gatling project from an executable jar

I have a small Gatling project which I would like to package through sbt and then run on different Linux/Windows machines with different JVM parameters. I tried already the sbt package command but that didn't work out. Anyone has done something similar before?
Package doesn't include the dependencies of your project.
You need something like sbt-assembly, sbt-pack or sbt-native-packager.
Then you can start your tests from within a main method (depending on the type of your package, e.g. java -jar fat-jar-name.jar).

Best method to export the Eclipse project as exe file

I have a selenium project in eclipse that i want to distribute to manual testers with no Eclipse or Java knowledge. Hence i am looking to distribute it to them as executable files so that they dont need to use eclipse to run them. Can any one suggest the best way to do this without having to install any 3rd party extensions?
P.S : My organisation doesnt allow me to install 3rd party extensions on Eclipse. It will require a lot of approvals. Hence i am wondering if there is any method available inside Eclipse itself?
I've done it some years ago, in my eclipse version:
file -> export -> java -> Runnable jar file
If you want an exe file you can use: Launch4J
Export your project as jar file and create a .bat file which will include all the necessary libraries in your classpath with your project and then make a call to the underlying script (in case if you are using testng then testng has option to make command line calls)
else use Maven
EDIT:
Something on below lines:
1. Create run.bat file
2. Content of the bat file:
JAVA_HOME={Path to your JDK}
CLASSPATH=%PATH%;{All the dependent jar files of your project as well as you project}
{Call to your Junit Script from command line} Something like this Run JUnit from command line
3. Run your batch file (run.bat)
I may not have provided the exact code but thats where you should be heading if you wish to run your JUnit tests from command line.
NOTE / FYI : Maven does not require any installation or approval..You just download the zip and unzip it and set environment variable and thats it.

Running multiple applications with sbt

I have my directory structure set up as such.
src/main/scala/main/Main.scala
src/main/scala/scripts/MainScript.scala
The script is a background job that will be running.
I've used sbt-assembly before to package up the main file into a jar to be deployed but I'm not sure how to create the two separate jars with sbt-assembly or sbt-native-packager. How would I go about doing that and what would be the best approach for this problem?
I would be looking to do something similar to this.
java -jar main.jar $PORT
java -jar scriptMain.jar
One way to solve this only with native-packager would be the following.
Put all your main classes in src/main/scala
Define a mainClass in Compile := Some("foo.bar.Main") that should run as default
add additional scripts in src/universal/bin that you would like to provide. These scripts can call the main script generated by native-packager and set the -main parameter to the class you want to call.
Now you have an output package (e.g. a zip, rpm, deb) that has the following structure. Assuming your app is called myApp and you provided to other bin scripts called otherApp1 / otherApp2
lib/ (jars live here)
conf/ (configuration files here, if any)
bin/
myApp
otherApp1
otherApp2
Unfortunately I have no example for the script (my bash-foo isn't good enough for instant magic on SO). In the end the scripts (otherApp1,otherApp2) should just pass the parameters they receive to the native-packager script (myApp).
There is an issue #633 that provides an automated way to generate scripts like this.
hope that helps,
Muki

How to tell eclipse to run a perl script and pass parameters to it before building my project?

I have a project in eclipse I would like to run a perl script before every build on eclipse
but I want to pass the perl script parameters, in detail I want to pass it the names/paths of all the files in the project
(this script add things to make makefile)
Thank you
As a general direction: You would use building systems like Ant or Maven to realise this in Eclipse.
For Ant: http://ant.apache.org/faq.html#shell-redirect-2

groovy eclipse and scripts that aren't classes

The groovy eclipse tutorial launches off in the direction of making a class.
If I just want to make a script, what do I do? Just make a file in some folder that is named 'something.groovy' and expect eclipse to be willing to run it?
In the new Groovy Class Wizard, there is a checkbox to create a script instead of a class:
Alternatively, you can create a regular class and delete all the contents except for the package statement. That is a script.
A couple of points, though. The script should be in a source folder with a proper package statement if not in the default package. If not, you will not have any editing support for your script.
I'm not familiar with the groovy plugin for eclipse but there should be no problem creating a simple groovy script and running it from Command line or from Eclipse.
Save the following as hello.groovy somewhere:
System.out.println("Hello Groovy");
Create a Java run configuration it with the groovy jar in the classpath and main method is in groovy.lang.GroovyShell. Pass the script name as an argument (You can use ${resource_loc}) to make it a generic run configuration and it will work fine.
Edit: You can also find instructions on running groovy scripts on the Groovy website