Execution Service

A simple set of classes to execute programmes from the command line, without littering the code with static void main(String[] args). This package addresses the following problem: a package (or a set of packages) contain a number of tools that should be run from outside java, e.g. using a static main() method. Over time, it might (will) be hard to know (or find) all main methods.

License

License

GroupId

GroupId

de.vandermeer
ArtifactId

ArtifactId

execs
Last Version

Last Version

0.4.0
Release Date

Release Date

Type

Type

jar
Description

Description

Execution Service
A simple set of classes to execute programmes from the command line, without littering the code with static void main(String[] args). This package addresses the following problem: a package (or a set of packages) contain a number of tools that should be run from outside java, e.g. using a static main() method. Over time, it might (will) be hard to know (or find) all main methods.
Project URL

Project URL

https://github.com/vdmeer/execs
Source Code Management

Source Code Management

https://github.com/vdmeer/execs

Download execs

How to add to project

<!-- https://jarcasting.com/artifacts/de.vandermeer/execs/ -->
<dependency>
    <groupId>de.vandermeer</groupId>
    <artifactId>execs</artifactId>
    <version>0.4.0</version>
</dependency>
// https://jarcasting.com/artifacts/de.vandermeer/execs/
implementation 'de.vandermeer:execs:0.4.0'
// https://jarcasting.com/artifacts/de.vandermeer/execs/
implementation ("de.vandermeer:execs:0.4.0")
'de.vandermeer:execs:jar:0.4.0'
<dependency org="de.vandermeer" name="execs" rev="0.4.0">
  <artifact name="execs" type="jar" />
</dependency>
@Grapes(
@Grab(group='de.vandermeer', module='execs', version='0.4.0')
)
libraryDependencies += "de.vandermeer" % "execs" % "0.4.0"
[de.vandermeer/execs "0.4.0"]

Dependencies

compile (3)

Group / Artifact Type Version
org.apache.commons : commons-lang3 jar 3.4
commons-cli : commons-cli jar 1.3.1
org.antlr : ST4 jar 4.0.8

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

SKB Execute Service

Current release is 0.4.0. All releases are on Maven Central.

The Problem

When writing applications that consist of a number of programs that can be executed from the command line one will have a lot of static void main() methods. Over time, it can be very hard to remember where they all are, and it is also tedious to write run scripts to start them from the command line. The problem gets worse when code is re-factored. Furthermore, handling options (external configuration parameters, such as via command line arguments) can involve default settings, CLI parameters, property files, other configuration files, database, etc.

This solution

Define an interface with all required functionality to run a program (here called application). Then implement a class that finds implementation of that interface and that provides a single static void main() method to execute each of them. Combine that with a command line parser and a class finder (to search for implementations of the interface in all jars or classes in the class path, at runtime). Finally, add some tools that automate the generation of run scripts for the most common operating systems: Windows, UNIX, and the hybrid Cygwin. To solve the last problem (application option handling), define an integrated model that deals with default values, CLI parameters and other sources.

Developing an application now means to implement classes implementing the executable application interface. If additional functionality is required a class extending the executor. Finally providing the necessary configuration information for the generators and an initialization script for the initial configuration of the application.

Provided functionality

Application Execution

  • Interface for an executable application,

  • An application executor with search and list, search, and help functionality,

  • A generator for a script (batch file or bash script) to run the application executor (including all required information such as class path),

  • A generator for scripts for all registered (static) or found (dynamic) executable applications,

Additionally this package defines required resources: * A bash script for running a generator when installing an application (including rebase if application is moved), * Property files with standard configurations, * String template files for flexible change of generator output.

Class Finder

  • A class finder that searches for implementations of the executable application interface in all jars and class files in the class path (at runtime),

  • A package filter for the class finder to speedup the search,

  • A jar filter for the class finder to speedup the search.

Application Options and CLI Parser

  • An interface defining a flexible Application Option interface that can deal with types (generic), default values, CLI values, property values, and short/long descriptions to generate help screens and documentation

  • An abstract (yet fully features) implementation of the application option interface

  • A CLI parser (base on Apache Commons CLI) that can be used simply with the original options (from Apache Commons) or with application options.

  • A set of pre-defined options for common use cases, e.g.:

    • input and output directory

    • input and output file

    • identifier

    • property file

    • server mode (flag for interactive or background mode)

    • STG file (for string template files)

Versions

Version
0.4.0
0.3.8
0.3.7
0.3.6
0.3.5
0.3.4
0.3.3
0.3.2
0.3.0
0.2.0
0.1.0
0.0.8
0.0.7
0.0.6
0.0.5
0.0.4
0.0.3