diff --git a/docs/io.sarl.docs.suite/src/test/java/io/sarl/docs/gettingstarted/CreateFirstProject.spec b/docs/io.sarl.docs.suite/src/test/java/io/sarl/docs/gettingstarted/CreateFirstProject.spec index 446196f180..0ac258551b 100644 --- a/docs/io.sarl.docs.suite/src/test/java/io/sarl/docs/gettingstarted/CreateFirstProject.spec +++ b/docs/io.sarl.docs.suite/src/test/java/io/sarl/docs/gettingstarted/CreateFirstProject.spec @@ -186,20 +186,17 @@ describe "Create First Project" { "%sarlmavenrepository%" should beURL "!file" } - /* For executing your SARL program, you must select a + /* For executing your SARL program, you must use a * [runtime environment](%website%/runtime/index.html). * *

The runtime environment that is recommended by the developers of SARL * is [Janus](http://www.janusproject.io). * - *

If you want to embed the runtime environment inside the Jar files - * of your SARL application, it is recommended to put it in the - * Maven dependencies. + *

In several specific cases, you may want to include the runtime environment into the Maven dependencies + * of your project. In this case, you could replace the Maven dependency to the SARL sdk (as defined in + * the previous section) by a Maven dependency to the runtime environment. + * The * - * You could remove the dependencies to the - * SARL artifacts in the previous Maven configuration. Indeed, the Janus platform depends - * already on. You will obtain the SARL artifacts by transitivity. - * *

Replace the version number (`%janusversion%`) of the [Janus platform](http://www.janusproject.io) * with the one you want to use. You could search on the * [Maven Central Repository](http://search.maven.org) for @@ -215,6 +212,23 @@ describe "Create First Project" { * %janusversion% * * ... + * + * + * ... + * + * io.sarl.maven + * sarl-maven-plugin + * ${sarl.version} + * true + * + * %compilerlevel% + * %compilerlevel% + * %encoding% + * + * + * + * + * ... * * ... * @@ -222,17 +236,6 @@ describe "Create First Project" { * io.janusproject.kernel * ${janus.version} * - * - * io.sarl.maven - * io.sarl.maven.sdk - * ${sarl.version} - * - * - * com.google.guava - * guava - * - * - * * ... * * ... @@ -242,9 +245,8 @@ describe "Create First Project" { * `io.sarl.maven.sdk` and `io.janusproject.kernel` in your * POM file, you must be sure that the imported version * of the Google Guava library is the one provided by the Janus - * platform. For ensuring this, you must exclude the Guava - * library from the transitive dependencies of - * `io.sarl.maven.sdk` + * platform. For ensuring this, you must specify the version of the Guava + * library by defining it in the "dependencyManagement" section of your pom file. * * @filter(.*) */ diff --git a/docs/io.sarl.docs.suite/src/test/java/io/sarl/docs/gettingstarted/RunSARLAgentCLI.spec b/docs/io.sarl.docs.suite/src/test/java/io/sarl/docs/gettingstarted/RunSARLAgentCLI.spec index 0ae7f8d5a5..27536259b8 100644 --- a/docs/io.sarl.docs.suite/src/test/java/io/sarl/docs/gettingstarted/RunSARLAgentCLI.spec +++ b/docs/io.sarl.docs.suite/src/test/java/io/sarl/docs/gettingstarted/RunSARLAgentCLI.spec @@ -23,10 +23,10 @@ package io.sarl.docs.gettingstarted import com.google.inject.Inject import io.sarl.docs.utils.SARLParser import io.sarl.docs.utils.SARLSpecCreator -import io.sarl.lang.sarl.SarlAgent import org.jnario.runner.CreateWith import static extension io.sarl.docs.utils.SpecificationTools.* +import static extension org.junit.Assume.assumeFalse /* @outline * @@ -34,124 +34,186 @@ import static extension io.sarl.docs.utils.SpecificationTools.* * environment. * This document explains how to launch an agent on * the [Janus platform](http://www.janusproject.io) from the command line. + * + *

Three methods could be used for launching an agent with Janus:

*/ @CreateWith(SARLSpecCreator) describe "Run SARL Agent from the Command Line" { @Inject extension SARLParser - /* The Janus platform provides a `Boot` class. - * For launching the platform, you must execute this - * boot class in a Java Virtual Machine. - * - *

The typical command line is: - * - * java -cp app.jar io.janusproject.Boot - * - * - *

The option `-cp` specifies the Jar file that contains - * the compiled classes. The given `app.jar` - * file is a Jar file that is containing the Janus - * platform, the SARL libraries, and the application classes. - * The last argument is the fully qualified name of - * the booting class of Janus: `io.janusproject.Boot` - * - * @filter(.*) + /* The SARL project provides a command-line tool for launching agents on the + * Janus runtime environment. */ - fact "Boot of Janus" { - true - } + describe "Use the janus command-line tool" { - /* The example given in the previous section causes an error. - * Indeed, it is mandatory to specify the fully qualified name - * of the agent to launch: - * - * java -cp app.jar io.janusproject.Boot myapp.MyAgent - * - * - * The Janus - * platform allows to start only one agent from the command line. - * If you want to start a collection of agents, you must select - * one of the following approaches: - * - * * launch a separate Janus platform for each agent, or - * * launch an agent that is spawning the other agents. - * - * - * @filter(.*) - */ - fact "Specify the Agent to Launch" { - true - } + /* + * You could download this command line tool, named "janus" on the [downloading page of SARL](%website%/download.html). + * + * @filter(.*) + */ + fact "Download the janus command-line tool" { + // The checks are valid only if the macro replacements were done. + // The replacements are done by Maven. + // So, Eclipse Junit tools do not make the replacements. + System.getProperty("sun.java.command", "").startsWith("org.eclipse.jdt.internal.junit.").assumeFalse + // + "%website%" should beURL "!file" + } + + /* + * For launching an agent, you must launch the command-line tool with the fully-qualified + * name of the agent as parameter (`myapp.MyAgent` in the following example). + * + * janus myapp.MyAgent + * + *

The janus command-line tool provides options that will enable you to tune the launching + * configuration: + * + * janus --help + * + * @filter(.*) + */ + fact "Launching the agent" { + true + } + + } - /* It is possible to give arguments to the launched agent. - * Indeed, all the arguments given on the command line - * are put in the `parameters` attribute of the `Initialize` event. - * This event is fired when the launched agent is started. + /* */ - describe "Command Line Parameters" { + describe "Use the standard java method" { - /* The following example gives the values `FirstParam` and - * `SecondParam` to the launched agent: + /* The Janus platform provides a `Boot` class. + * For launching the platform, you must execute this + * boot class in a Java Virtual Machine. + * + *

The typical command line is: + * + * java -cp app.jar io.janusproject.Boot + * + * + *

The option `-cp` specifies the Jar file that contains + * the compiled classes. The given `app.jar` + * file is a Jar file that is containing the Janus + * platform, the SARL libraries, and the application classes. + * The last argument is the fully qualified name of + * the booting class of Janus: `io.janusproject.Boot` * - * java -cp app.jar io.janusproject.Boot myapp.MyAgent FirstParam SecondParam + * @filter(.*) + */ + fact "Boot of Janus" { + true + } + + /* The example given in the previous section causes an error. + * Indeed, it is mandatory to specify the fully qualified name + * of the agent to launch: + * + * java -cp app.jar io.janusproject.Boot myapp.MyAgent + * + * + * The Janus + * platform allows to start only one agent from the command line. + * If you want to start a collection of agents, you must select + * one of the following approaches:

+ * + * @filter(.*) + */ + fact "Specify the Agent to Launch" { + true + } + + /* In the previous section, we assume that all the application binary files are + * contained into the `app.jar` file. + * + *

You may replace the `app.jar` in the previous command lines by the classpath + * that is containing all the jar files required for running your application, including + * the Janus jar file(s): + * + * java -cp /path/to/myapplication.jar:/path/to/io.janusproject.kernel--with-dependencies.jar io.janusproject.Boot myapp.MyAgent + * + *

The `io.janusproject.kernel--with-dependencies.jar` file may be dowloaded from the [Janus website](http://www.janusproject.io/) + * + *

You may also create the `app.jar` file with Maven by using the assembly plugin for creating a jar file with all the dependencies inside. + * + * @filter(.*) + */ + fact "What is app.jar?" { + "http://www.janusproject.io/" should beURL _ + } + + /* The Janus platform provides a collection of command line options. + * For obtaining the list of these options, you should type: + * + * java -cp app.jar io.janusproject.Boot --help * * * @filter(.*) */ - fact "Give Parameters to the Agent" { + fact "Janus Command Line Options" { true } - - /* For retrieving the values passed on the command line, - * you must handle the `Initialize` event, as illustrated - * by the following example: + + } + + /* + */ + describe "Use Maven ExecutionPlugin" { + + /* Maven provides a plugin for launching an application after automatically building + * the application's classpath. This plugin may be used for launching an agent. + * + *

Based on the fact that the Janus platform provides a `Boot` class for launching itself, + * you may use the Maven execution plugin for classing this booting class. + * + *

The typical command line is: + * + * mvn exec:java -Dexec.mainClass="io.janusproject.Boot" + * * - * @filter(.* = '''|'''|.parseSuccessfully.*) + *

The option `-Dexec.mainClass` specifies the fully qualified name of + * the booting class of Janus: `io.janusproject.Boot` + * + * @filter(.*) */ - fact "Retrieve the Command Line Parameters in the Agent" { - val model = ''' - agent MyAgent { - uses Logging - on Initialize { - println("Command line parameters: " - +occurrence.parameters) - } - } - '''.parseSuccessfully( - "package io.sarl.docs.gettingstarted.runsarlagent - import io.sarl.core.Logging - import io.sarl.core.Initialize", - // TEXT - "" - ) - - model => [ - it should havePackage "io.sarl.docs.gettingstarted.runsarlagent" - it should haveNbImports 2 - it should importClass "io.sarl.core.Logging" - it should importClass "io.sarl.core.Initialize" - it should haveNbElements 1 - ] - - model.xtendTypes.get(0) => [ - it should beAgent "MyAgent" - it should extend _ - it should haveNbElements 2 - (it as SarlAgent).members.get(0) => [ - it should beCapacityUse "io.sarl.core.Logging" - ] - (it as SarlAgent).members.get(1) => [ - it should beBehaviorUnit "io.sarl.core.Initialize" - it should beGuardedWith _ - ] - ] - } + fact "Boot of Janus" { + true + } + + /* The example given in the previous section causes an error. + * Indeed, it is mandatory to specify the fully qualified name + * of the agent to launch: + * + * mvn exec:java -Dexec.mainClass="io.janusproject.Boot" -Dexec.args=myapp.MyAgent + * + * + * The Janus + * platform allows to start only one agent from the command line. + * If you want to start a collection of agents, you must select + * one of the following approaches:

+ * + * @filter(.*) + */ + fact "Specify the Agent to Launch" { + true + } /* The Janus platform provides a collection of command line options. * For obtaining the list of these options, you should type: * - * java -cp app.jar io.janusproject.Boot --help + * mvn exec:java -Dexec.mainClass="io.janusproject.Boot" -Dexec.args=--help * * * @filter(.*) @@ -161,7 +223,7 @@ describe "Run SARL Agent from the Command Line" { } } - + /* * In the next section, we will learn how to launch your SARL project from * a Java program. diff --git a/docs/io.sarl.docs.suite/src/test/java/io/sarl/docs/gettingstarted/RunSARLAgentEclipse.spec b/docs/io.sarl.docs.suite/src/test/java/io/sarl/docs/gettingstarted/RunSARLAgentEclipse.spec index 2814aa47d2..29d5fc8303 100644 --- a/docs/io.sarl.docs.suite/src/test/java/io/sarl/docs/gettingstarted/RunSARLAgentEclipse.spec +++ b/docs/io.sarl.docs.suite/src/test/java/io/sarl/docs/gettingstarted/RunSARLAgentEclipse.spec @@ -33,10 +33,10 @@ import static extension org.junit.Assume.* * *

For running an agent, you must launch this agent on the runtime * environment. - * This document explains how to launch an agent on - * the [Janus platform](http://www.janusproject.io) inside the Eclipse IDE. + * In this document, we assume that the runtime environment is + * the [Janus platform](http://www.janusproject.io). * - *

Two major methods are available for launching a SARL application: + *

Two major methods are available for launching a SARL application inside the SARL Eclipse IDE: * * * Use a [SARL launch configuration](#Create_a_Sarl_Launch_Configuration). * * Use a [Java launch configuration](#Create_a_Java_Launch_Configuration). @@ -48,8 +48,8 @@ describe "Run SARL Agent in the Eclipse IDE" { @Inject extension SARLParser - /* For launching the SARL agents on the Janus runtime environment inside - * the Eclipse IDE, you must define a *Run Configuration*. + /* For launching the SARL agents on the runtime environment inside + * the SARL Eclipse IDE, you must define a *Run Configuration*. * * If your project is Maven-based, you could not use this * method for launching your application. You must use the @@ -88,6 +88,8 @@ describe "Run SARL Agent in the Eclipse IDE" { * *

![Agent to Launch](./EclipseRunConfiguration_0_1.png) * + *

At the bottom of this page, you may change configuration options for the runtime environment. + * * @filter(.*) */ fact "Specify the agent to execute" { @@ -97,13 +99,12 @@ describe "Run SARL Agent in the Eclipse IDE" { /* For running your agent, you must specify a SARL runtime environment. * In this tutorial, we assume that you want to use the [Janus platform](http://www.janusproject.io). * - *

First, **you could download the - * [Janus runtime environment](%janusmavenrepository%/last-janus-release.jar)**. - * - *

For adding the down-loaded file of Janus, you add a **SARL runtime environment** (or SRE) in + *

If you don't want to use the Janus platform, you must download the + * runtime environment that you want to use, and install it in the SARL Eclipse environment as follow. + * You add a **SARL runtime environment** (or SRE) in * the *Runtime environment* tab. You should click on the **Installed SREs** button for * managing the installed runtime environments (or open the corresponding preference page). - * After adding the Janus JAR file, you obtain a dialog box similar to: + * After adding the SRE's JAR file, you obtain a dialog box similar to: * * *

![Add Janus](./EclipseRunConfiguration_0_2.png) @@ -125,12 +126,14 @@ describe "Run SARL Agent in the Eclipse IDE" { * are put in the `parameters` attribute of the `Initialize` event. * This event is fired when the launched agent is started. * - *

The following example gives the values `First`, `Argument`, - * `Second`, and `Argument` to the launched agent: + *

The following example gives the values `FirstArgument` and + * `SecondArgument` to the launched agent: * * *

![Program Arguments](./EclipseRunConfiguration_0_3.png) * + *

On this page, you could also specify the parameters to give to the SARL runtime environment or + * to the Java virtual machine. * * @filter(.*) */ @@ -142,6 +145,9 @@ describe "Run SARL Agent in the Eclipse IDE" { /* For launching the SARL agents on the Janus runtime environment inside * the Eclipse IDE, you must define a *Run Configuration*. + * + *

This section is dedicated to the definition of a launcher for Java application (the standard and classical + * launching configuration in the Eclipse community). */ describe "Create a Java Launch Configuration" { @@ -165,21 +171,21 @@ describe "Run SARL Agent in the Eclipse IDE" { /* For running your agent with the Janus runtime environment, * you must add the Janus library in the class path. * - *

First, **you must download the - * [Janus runtime environment](%janusmavenrepository%/last-janus-release.jar)**. - * - *

For adding the downloaded file of Janus, you must **add an external JAR** in - * the *Classpath* tab. After adding the Janus JAR file, you obtain a - * dialog box similar to: - * + *

For adding the Janus library, select the **Classpath** tab, and **User Entries**. + * Click on the **Advanced** button. You will be able to select the type of classpath + * entry to add. Select "Add Library". + * + *

![Add Library in the classpath](./EclipseRunConfiguration_1_1.png) * - *

![Add Janus](./EclipseRunConfiguration_1_1.png) + * Then, you are able to select the library for the Janus runtime environment. * + *

![Add Janus Library](./EclipseRunConfiguration_1_2.png) * * @filter(.*) */ fact "Add the Janus runtime environment" { "EclipseRunConfiguration_1_1.png" should beAccessibleFrom this + "EclipseRunConfiguration_1_2.png" should beAccessibleFrom this // The checks are valid only if the macro replacements were done. // The replacements are done by Maven. // So, Eclipse Junit tools do not make the replacements. @@ -192,13 +198,13 @@ describe "Run SARL Agent in the Eclipse IDE" { * The main class **must always be** `io.janusproject.Boot`. * * - *

![Janus Boot Class](./EclipseRunConfiguration_1_2.png) + *

![Janus Boot Class](./EclipseRunConfiguration_1_3.png) * * * @filter(.*) */ fact "Specify the Janus Boot agent" { - "EclipseRunConfiguration_1_2.png" should beAccessibleFrom this + "EclipseRunConfiguration_1_3.png" should beAccessibleFrom this } /* The last step is the specification of the agent to launch. @@ -211,13 +217,13 @@ describe "Run SARL Agent in the Eclipse IDE" { * of the agent that must be launched. * * - *

![Agent to Launch](./EclipseRunConfiguration_1_3.png) + *

![Agent to Launch](./EclipseRunConfiguration_1_4.png) * * * @filter(.*) */ fact "Specify the agent to execute" { - "EclipseRunConfiguration_1_3.png" should beAccessibleFrom this + "EclipseRunConfiguration_1_4.png" should beAccessibleFrom this } /* It is possible to give arguments to the launched agent. @@ -229,13 +235,13 @@ describe "Run SARL Agent in the Eclipse IDE" { * `SecondParam` to the launched agent: * * - *

![Program Arguments](./EclipseRunConfiguration_1_4.png) + *

![Program Arguments](./EclipseRunConfiguration_1_5.png) * * * @filter(.*) */ fact "Give parameters to the Agent" { - "EclipseRunConfiguration_1_4.png" should beAccessibleFrom this + "EclipseRunConfiguration_1_5.png" should beAccessibleFrom this } } diff --git a/docs/io.sarl.docs.suite/src/test/resources/io/sarl/docs/gettingstarted/EclipseRunConfiguration_0_0.png b/docs/io.sarl.docs.suite/src/test/resources/io/sarl/docs/gettingstarted/EclipseRunConfiguration_0_0.png index 3b8a3042cf..654717e6e8 100644 Binary files a/docs/io.sarl.docs.suite/src/test/resources/io/sarl/docs/gettingstarted/EclipseRunConfiguration_0_0.png and b/docs/io.sarl.docs.suite/src/test/resources/io/sarl/docs/gettingstarted/EclipseRunConfiguration_0_0.png differ diff --git a/docs/io.sarl.docs.suite/src/test/resources/io/sarl/docs/gettingstarted/EclipseRunConfiguration_0_1.png b/docs/io.sarl.docs.suite/src/test/resources/io/sarl/docs/gettingstarted/EclipseRunConfiguration_0_1.png index 1c5df975c8..06f7ec06d0 100644 Binary files a/docs/io.sarl.docs.suite/src/test/resources/io/sarl/docs/gettingstarted/EclipseRunConfiguration_0_1.png and b/docs/io.sarl.docs.suite/src/test/resources/io/sarl/docs/gettingstarted/EclipseRunConfiguration_0_1.png differ diff --git a/docs/io.sarl.docs.suite/src/test/resources/io/sarl/docs/gettingstarted/EclipseRunConfiguration_0_2.png b/docs/io.sarl.docs.suite/src/test/resources/io/sarl/docs/gettingstarted/EclipseRunConfiguration_0_2.png index 040bfb2dd8..ff6313f9af 100644 Binary files a/docs/io.sarl.docs.suite/src/test/resources/io/sarl/docs/gettingstarted/EclipseRunConfiguration_0_2.png and b/docs/io.sarl.docs.suite/src/test/resources/io/sarl/docs/gettingstarted/EclipseRunConfiguration_0_2.png differ diff --git a/docs/io.sarl.docs.suite/src/test/resources/io/sarl/docs/gettingstarted/EclipseRunConfiguration_0_3.png b/docs/io.sarl.docs.suite/src/test/resources/io/sarl/docs/gettingstarted/EclipseRunConfiguration_0_3.png index 1c9728e38a..f0ef02ab5c 100644 Binary files a/docs/io.sarl.docs.suite/src/test/resources/io/sarl/docs/gettingstarted/EclipseRunConfiguration_0_3.png and b/docs/io.sarl.docs.suite/src/test/resources/io/sarl/docs/gettingstarted/EclipseRunConfiguration_0_3.png differ diff --git a/docs/io.sarl.docs.suite/src/test/resources/io/sarl/docs/gettingstarted/EclipseRunConfiguration_1_1.png b/docs/io.sarl.docs.suite/src/test/resources/io/sarl/docs/gettingstarted/EclipseRunConfiguration_1_1.png index d8556e688e..57aac29821 100644 Binary files a/docs/io.sarl.docs.suite/src/test/resources/io/sarl/docs/gettingstarted/EclipseRunConfiguration_1_1.png and b/docs/io.sarl.docs.suite/src/test/resources/io/sarl/docs/gettingstarted/EclipseRunConfiguration_1_1.png differ diff --git a/docs/io.sarl.docs.suite/src/test/resources/io/sarl/docs/gettingstarted/EclipseRunConfiguration_1_2.png b/docs/io.sarl.docs.suite/src/test/resources/io/sarl/docs/gettingstarted/EclipseRunConfiguration_1_2.png index 652a503391..ca73d44a08 100644 Binary files a/docs/io.sarl.docs.suite/src/test/resources/io/sarl/docs/gettingstarted/EclipseRunConfiguration_1_2.png and b/docs/io.sarl.docs.suite/src/test/resources/io/sarl/docs/gettingstarted/EclipseRunConfiguration_1_2.png differ diff --git a/docs/io.sarl.docs.suite/src/test/resources/io/sarl/docs/gettingstarted/EclipseRunConfiguration_1_3.png b/docs/io.sarl.docs.suite/src/test/resources/io/sarl/docs/gettingstarted/EclipseRunConfiguration_1_3.png index ce7d3a0de6..652a503391 100644 Binary files a/docs/io.sarl.docs.suite/src/test/resources/io/sarl/docs/gettingstarted/EclipseRunConfiguration_1_3.png and b/docs/io.sarl.docs.suite/src/test/resources/io/sarl/docs/gettingstarted/EclipseRunConfiguration_1_3.png differ diff --git a/docs/io.sarl.docs.suite/src/test/resources/io/sarl/docs/gettingstarted/EclipseRunConfiguration_1_4.png b/docs/io.sarl.docs.suite/src/test/resources/io/sarl/docs/gettingstarted/EclipseRunConfiguration_1_4.png index cd791100d4..ce7d3a0de6 100644 Binary files a/docs/io.sarl.docs.suite/src/test/resources/io/sarl/docs/gettingstarted/EclipseRunConfiguration_1_4.png and b/docs/io.sarl.docs.suite/src/test/resources/io/sarl/docs/gettingstarted/EclipseRunConfiguration_1_4.png differ diff --git a/docs/io.sarl.docs.suite/src/test/resources/io/sarl/docs/gettingstarted/EclipseRunConfiguration_1_5.png b/docs/io.sarl.docs.suite/src/test/resources/io/sarl/docs/gettingstarted/EclipseRunConfiguration_1_5.png new file mode 100644 index 0000000000..cd791100d4 Binary files /dev/null and b/docs/io.sarl.docs.suite/src/test/resources/io/sarl/docs/gettingstarted/EclipseRunConfiguration_1_5.png differ