From e19733932a941fb0e26fa29ee10e974fbf191ea3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Galland?= Date: Tue, 24 Jul 2018 23:28:50 +0200 Subject: [PATCH] [sarlc] Write more details into the options' descriptions. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Galland --- .../modules/configs/CompilerConfigModule.java | 12 ++++---- .../lang/sarlc/modules/configs/Messages.java | 1 - .../modules/configs/SarlcConfigModule.java | 30 +++++++++++++++---- .../configs/ValidatorConfigModule.java | 2 +- .../general/SarlBatchCompilerModule.java | 3 -- .../lang/sarlc/commands/messages.properties | 2 +- .../sarlc/modules/configs/messages.properties | 30 ++++++++++++++----- 7 files changed, 56 insertions(+), 24 deletions(-) diff --git a/products/sarlc/src/main/java/io/sarl/lang/sarlc/modules/configs/CompilerConfigModule.java b/products/sarlc/src/main/java/io/sarl/lang/sarlc/modules/configs/CompilerConfigModule.java index f45b636ce0..9f1d5feac8 100644 --- a/products/sarlc/src/main/java/io/sarl/lang/sarlc/modules/configs/CompilerConfigModule.java +++ b/products/sarlc/src/main/java/io/sarl/lang/sarlc/modules/configs/CompilerConfigModule.java @@ -55,12 +55,14 @@ */ public class CompilerConfigModule extends AbstractModule { + private static final String ENCODING_OPTION = "encoding"; //$NON-NLS-1$ + @Override protected void configure() { VariableDecls.extend(binder()).declareVar(FILE_ENCODING_NAME); extend(binder()).addOption(OptionMetadata.builder( - "encoding", //$NON-NLS-1$ - MessageFormat.format(Messages.CompilerConfigModule_0, Charset.defaultCharset().displayName())) + ENCODING_OPTION, + MessageFormat.format(Messages.CompilerConfigModule_0, ENCODING_OPTION)) .configPath(FILE_ENCODING_NAME) .valueOptional(Messages.CompilerConfigModule_1) .defaultValue(Charset.defaultCharset().displayName()) @@ -68,8 +70,8 @@ protected void configure() { VariableDecls.extend(binder()).declareVar(JAVA_VERSION_NAME); extend(binder()).addOption(OptionMetadata.builder( - "javaversion", //$NON-NLS-1$ - MessageFormat.format(Messages.CompilerConfigModule_2, SARLVersion.MINIMAL_JDK_VERSION)) + "javasource", //$NON-NLS-1$ + Messages.CompilerConfigModule_2) .configPath(JAVA_VERSION_NAME) .valueOptional(Messages.CompilerConfigModule_3) .defaultValue(SARLVersion.MINIMAL_JDK_VERSION) @@ -79,7 +81,7 @@ protected void configure() { final String trueFalseValues = MessageFormat.format(Messages.CompilerConfigModule_5, Boolean.TRUE, Boolean.FALSE); extend(binder()).addOption(OptionMetadata.builder( - "javacompiler", //$NON-NLS-1$ + "enablejavacompiler", //$NON-NLS-1$ MessageFormat.format(Messages.CompilerConfigModule_4, Boolean.TRUE)) .configPath(JAVA_COMPILER_NAME) .valueOptional(trueFalseValues) diff --git a/products/sarlc/src/main/java/io/sarl/lang/sarlc/modules/configs/Messages.java b/products/sarlc/src/main/java/io/sarl/lang/sarlc/modules/configs/Messages.java index b8551f5425..45206092fc 100644 --- a/products/sarlc/src/main/java/io/sarl/lang/sarlc/modules/configs/Messages.java +++ b/products/sarlc/src/main/java/io/sarl/lang/sarlc/modules/configs/Messages.java @@ -41,7 +41,6 @@ public class Messages extends NLS { public static String SarlcConfigModule_4; public static String SarlcConfigModule_5; public static String SarlcConfigModule_6; - public static String SarlcConfigModule_7; public static String SarlcConfigModuleProvider_0; public static String CompilerConfigModule_0; public static String CompilerConfigModule_1; diff --git a/products/sarlc/src/main/java/io/sarl/lang/sarlc/modules/configs/SarlcConfigModule.java b/products/sarlc/src/main/java/io/sarl/lang/sarlc/modules/configs/SarlcConfigModule.java index 22e91c689d..2a47f0cea6 100644 --- a/products/sarlc/src/main/java/io/sarl/lang/sarlc/modules/configs/SarlcConfigModule.java +++ b/products/sarlc/src/main/java/io/sarl/lang/sarlc/modules/configs/SarlcConfigModule.java @@ -28,6 +28,9 @@ import static io.sarl.lang.sarlc.configs.SarlConfig.OUTPUT_PATH_NAME; import static io.sarl.lang.sarlc.configs.SarlConfig.WORKING_PATH_NAME; +import java.io.File; +import java.text.MessageFormat; + import com.google.inject.AbstractModule; import com.google.inject.Injector; import com.google.inject.Provides; @@ -35,7 +38,10 @@ import io.bootique.config.ConfigurationFactory; import io.bootique.meta.application.OptionMetadata; import org.arakhne.afc.bootique.variables.VariableDecls; +import org.arakhne.afc.bootique.variables.VariableNames; +import org.eclipse.core.runtime.Path; +import io.sarl.lang.SARLConfig; import io.sarl.lang.sarlc.Constants; import io.sarl.lang.sarlc.configs.SarlConfig; @@ -50,18 +56,28 @@ */ public class SarlcConfigModule extends AbstractModule { + private static final String CLASSPATH_LONG_OPTION = "classpath"; //$NON-NLS-1$ + + private static final String CLASSPATH_SHORT_OPTION = "cp"; //$NON-NLS-1$ + @Override protected void configure() { VariableDecls.extend(binder()).declareVar(OUTPUT_PATH_NAME); extend(binder()).addOption(OptionMetadata.builder( - Constants.SARL_OUTPUT_DIRECTORY_OPTION, Messages.SarlcConfigModule_0) + Constants.SARL_OUTPUT_DIRECTORY_OPTION, + MessageFormat.format(Messages.SarlcConfigModule_0, Constants.PROGRAM_NAME, + Constants.SARL_OUTPUT_DIRECTORY_OPTION, + Path.fromPortableString(SARLConfig.FOLDER_SOURCE_GENERATED).toFile().getPath())) .configPath(OUTPUT_PATH_NAME) .valueRequired(Messages.SarlcConfigModule_1) .build()); VariableDecls.extend(binder()).declareVar(CLASS_OUTPUT_PATH_NAME); extend(binder()).addOption(OptionMetadata.builder( - Constants.JAVA_OUTPUT_DIRECTORY_OPTION, Messages.SarlcConfigModule_7) + Constants.JAVA_OUTPUT_DIRECTORY_OPTION, + MessageFormat.format(Messages.SarlcConfigModule_6, Constants.PROGRAM_NAME, + Constants.JAVA_OUTPUT_DIRECTORY_OPTION, + Path.fromPortableString(SARLConfig.FOLDER_BIN).toFile().getPath())) .configPath(CLASS_OUTPUT_PATH_NAME) .valueRequired(Messages.SarlcConfigModule_1) .build()); @@ -74,20 +90,24 @@ protected void configure() { .build()); VariableDecls.extend(binder()).declareVar(CLASSPATH_NAME); + final String cpDescription = MessageFormat.format(Messages.SarlcConfigModule_3, + VariableNames.toEnvironmentVariableName(CLASSPATH_NAME), CLASSPATH_SHORT_OPTION, + CLASSPATH_LONG_OPTION); extend(binder()).addOptions(OptionMetadata.builder( - "classpath", Messages.SarlcConfigModule_3) //$NON-NLS-1$ + CLASSPATH_LONG_OPTION, cpDescription) .configPath(CLASSPATH_NAME) .valueRequired(Messages.SarlcConfigModule_4) .build(), OptionMetadata.builder( - "cp", Messages.SarlcConfigModule_5) //$NON-NLS-1$ + CLASSPATH_SHORT_OPTION, cpDescription) .configPath(CLASSPATH_NAME) .valueRequired(Messages.SarlcConfigModule_4) .build()); VariableDecls.extend(binder()).declareVar(BOOT_CLASSPATH_NAME); extend(binder()).addOption(OptionMetadata.builder( - "bootclasspath", Messages.SarlcConfigModule_6) //$NON-NLS-1$ + "bootclasspath", //$NON-NLS-1$ + MessageFormat.format(Messages.SarlcConfigModule_5, File.pathSeparator)) .configPath(BOOT_CLASSPATH_NAME) .valueRequired(Messages.SarlcConfigModule_4) .build()); diff --git a/products/sarlc/src/main/java/io/sarl/lang/sarlc/modules/configs/ValidatorConfigModule.java b/products/sarlc/src/main/java/io/sarl/lang/sarlc/modules/configs/ValidatorConfigModule.java index 0b838197af..ef1bbc9d8b 100644 --- a/products/sarlc/src/main/java/io/sarl/lang/sarlc/modules/configs/ValidatorConfigModule.java +++ b/products/sarlc/src/main/java/io/sarl/lang/sarlc/modules/configs/ValidatorConfigModule.java @@ -56,7 +56,7 @@ protected void configure() { VariableDecls.extend(binder()).declareVar(ALL_ERRORS_NAME); extend(binder()).addOption(OptionMetadata.builder( - "werr", Messages.ValidatorConfigModule_1) //$NON-NLS-1$ + "werror", Messages.ValidatorConfigModule_1) //$NON-NLS-1$ .configPath(ALL_ERRORS_NAME) .build()); } diff --git a/products/sarlc/src/main/java/io/sarl/lang/sarlc/modules/general/SarlBatchCompilerModule.java b/products/sarlc/src/main/java/io/sarl/lang/sarlc/modules/general/SarlBatchCompilerModule.java index 4b5477a9a4..80922f62aa 100644 --- a/products/sarlc/src/main/java/io/sarl/lang/sarlc/modules/general/SarlBatchCompilerModule.java +++ b/products/sarlc/src/main/java/io/sarl/lang/sarlc/modules/general/SarlBatchCompilerModule.java @@ -67,9 +67,6 @@ public SarlBatchCompiler provideSarlBatchCompiler( final SarlBatchCompiler compiler = new SarlBatchCompiler(); injector.injectMembers(compiler); - //final Logger logger = injector.getInstance(Logger.class); - //compiler.setLogger(logger); - if (!Strings.isEmpty(sarlcConfig.getClasspath())) { compiler.setClassPath(sarlcConfig.getClasspath()); } diff --git a/products/sarlc/src/main/resources/io/sarl/lang/sarlc/commands/messages.properties b/products/sarlc/src/main/resources/io/sarl/lang/sarlc/commands/messages.properties index fe7f48ead2..37bbe9ecbe 100644 --- a/products/sarlc/src/main/resources/io/sarl/lang/sarlc/commands/messages.properties +++ b/products/sarlc/src/main/resources/io/sarl/lang/sarlc/commands/messages.properties @@ -1,4 +1,4 @@ CompilerCommand_0 = Run sarlc. CompilerCommand_1 = Not enough arguments. Source folders must be provided as arguments. -VersionCommand_0 = Prints the version of sarlc. +VersionCommand_0 = Prints release information. VersionCommand_1 = SARL Version: {0}\nSARL Specification Version: {1}\nJava Version: {2}\n diff --git a/products/sarlc/src/main/resources/io/sarl/lang/sarlc/modules/configs/messages.properties b/products/sarlc/src/main/resources/io/sarl/lang/sarlc/modules/configs/messages.properties index a55d244448..b3fcbcad23 100644 --- a/products/sarlc/src/main/resources/io/sarl/lang/sarlc/modules/configs/messages.properties +++ b/products/sarlc/src/main/resources/io/sarl/lang/sarlc/modules/configs/messages.properties @@ -1,15 +1,29 @@ -SarlcConfigModule_0 = Output directory in which the Java source files will be generated. +SarlcConfigModule_0 = Sets the destination directory for Java source files that are generated from the SARL files. \ + The directory must already exist because {0} does not create it. If a SARL declaration is part of a package, \ + then {0} puts the Java source file in a subdirectory that reflects the package name and creates directories \ + as needed. If the --{1} option is not specified, then {0} assumes {2}. SarlcConfigModule_1 = directory_name SarlcConfigModule_2 = Directory in which the temporary files will be generated during the compilation process. -SarlcConfigModule_3 = Specify where to find user class files and annotation processors. +SarlcConfigModule_3 = Specifies where to find user class files, and source files. This class path \ + overrides the user class path in the {0} environment variable. If neither {0}, --{1} nor --{2} \ + is specified, then the user class path is built upon the source folders, the generated file folders, \ + and the standard SARL libraries. If a user class path is specified, it must contains the the user libraries \ + and the standard SARL libraries. SarlcConfigModule_4 = path -SarlcConfigModule_5 = Specify where to find user class files and annotation processors. -SarlcConfigModule_6 = Override location of bootstrap class files. -SarlcConfigModule_7 = Output directory in which the Java byte code files will be generated. +SarlcConfigModule_5 = Cross-compiles against the specified set of boot classes. As with the user class path, \ + boot class path entries are separated by colons ({0}) and can be directories, JAR archives, or ZIP archives. +SarlcConfigModule_6 = Sets the destination directory for class files. The directory must already exist \ + because {0} does not create it. If a class is part of a package, then {0} puts the class file in a \ + subdirectory that reflects the package name and creates directories as needed. If the --{1} option is \ + not specified, then {0} assumes {2}. SarlcConfigModuleProvider_0 = The configuration for the sarlc tool. -CompilerConfigModule_0 = Specify the character encoding of the files; default is {0}. +CompilerConfigModule_0 = Sets the source file encoding name, such as EUC-JP and UTF-8. If the \ + --{0} option is not specified, then the platform default converter is used. CompilerConfigModule_1 = encoding -CompilerConfigModule_2 = Generate Java files for a specific Java version; default is {0}. +CompilerConfigModule_2 = Specifies the Java version of Java source code accepted, and \ + of the Java class files for targeting a specified release of the Java virtual machine. \ + Java class files will run on the specified target and on later releases, but not on earlier \ + releases of the Java virtual machine. Valid targets are: 1.8 (or 8). CompilerConfigModule_3 = version CompilerConfigModule_4 = Specify if the Java compiler should be run; default is {0}. CompilerConfigModule_5 = {0}|{1} @@ -23,6 +37,6 @@ CompilerConfigModule_12 = Specify if the clone functions should be generated; de CompilerConfigModule_13 = Specify if the serial identifiers should be generated; default is {0}. CompilerConfigModuleProvider_0 = The configuration for the SARL compiler. ValidatorConfigModule_0 = Specify if all the warnings are ignored. -ValidatorConfigModule_1 = Specify if any warning is assimilated to an error. +ValidatorConfigModule_1 = Terminates compilation when warnings occur. ValidatorConfigModule_2 = Specify if all the warnings are printed out. ValidatorConfigModuleProvider_0 = The configuration for the SARL validator.