Loading LICENSE 0 → 100644 +23 −0 Original line number Diff line number Diff line Copyright 2020 ETSI Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. No newline at end of file README.md +16 −1 Original line number Diff line number Diff line # Description # SAREF Pipeline This project integrates the SAREF development and documentation generation pipeline Sources of the SAREF pipeline as specified in Technical Specification: ETSI TS 103 673 V1.1.1: "SmartM2M; SAREF Development Framework and Workflow, Streamlining the Development of SAREF and its Extensions" The SAREF pipeline is part of the SAREF Development Framework https://portal.etsi.org/STF/STFs/STF-HomePages/STF578 [Download the latest build here](https://gitlab.emse.fr/saref/saref-pipeline/-/jobs/artifacts/master/raw/target/saref-pipeline.jar?job=build) This SAREF-Pipeline may be run: - by double-clicking the JAR file to starting the graphical user interface - or using the command line interface, run `java -jar saref-pipeline.jar help` to get started pom.xml +42 −21 Original line number Diff line number Diff line Loading @@ -170,32 +170,17 @@ <version>1.4.5.519</version> </dependency> <dependency> <groupId>org.openjfx</groupId> <artifactId>javafx-controls</artifactId> <version>11</version> </dependency> </dependencies> <build> <finalName>${project.artifactId}</finalName> <plugins> <plugin> <artifactId>maven-assembly-plugin</artifactId> <version>3.2.0</version> <configuration> <finalName>static</finalName> <appendAssemblyId>false</appendAssemblyId> <descriptors> <descriptor>src/main/static/assembly.xml</descriptor> </descriptors> <outputDirectory>${project.build.outputDirectory}</outputDirectory> </configuration> <executions> <execution> <id>static</id> <phase>process-resources</phase> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> Loading Loading @@ -247,5 +232,41 @@ </configuration> </plugin> </plugins> <pluginManagement> <plugins> <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself. --> <plugin> <groupId>org.eclipse.m2e</groupId> <artifactId>lifecycle-mapping</artifactId> <version>1.0.0</version> <configuration> <lifecycleMappingMetadata> <pluginExecutions> <pluginExecution> <pluginExecutionFilter> <groupId> org.apache.maven.plugins </groupId> <artifactId> maven-assembly-plugin </artifactId> <versionRange> [3.2.0,) </versionRange> <goals> <goal>single</goal> </goals> </pluginExecutionFilter> <action> <ignore></ignore> </action> </pluginExecution> </pluginExecutions> </lifecycleMappingMetadata> </configuration> </plugin> </plugins> </pluginManagement> </build> </project> run.shdeleted 100644 → 0 +0 −1 Original line number Diff line number Diff line mvn exec:java -Dexec.args="-d ../saref-core" src/main/java/fr/emse/gitlab/saref/CLIExecution.java 0 → 100644 +175 −0 Original line number Diff line number Diff line /* * Copyright 2020 ETSI * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. */ package fr.emse.gitlab.saref; import java.io.Console; import java.io.File; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.Arrays; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.DefaultParser; import org.apache.commons.cli.HelpFormatter; import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; import org.apache.commons.io.IOUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import fr.emse.gitlab.saref.SAREFPipeline.Mode; /** * * @author Maxime Lefrançois, Omar Qawasmeh * */ public class CLIExecution implements SAREFCredentialsProvider { private static final Logger LOG = LoggerFactory.getLogger(CLIExecution.class); private static final String ARG_IGNORE_EXAMPLES = "e"; private static final String ARG_IGNORE_EXAMPLES_LONG = "no-examples"; private static final String ARG_IGNORE_EXAMPLES_MAN = "Do not check examples"; private static final String ARG_IGNORE_SITE = "s"; private static final String ARG_IGNORE_SITE_LONG = "no-site"; private static final String ARG_IGNORE_SITE_MAN = "Do not generate the static portal"; private static final String ARG_IGNORE_TERMS = "t"; private static final String ARG_IGNORE_TERMS_LONG = "no-terms"; private static final String ARG_IGNORE_TERMS_MAN = "Do not generate the static portal for terms"; private static final Options OPTIONS = new Options() .addOption(ARG_IGNORE_EXAMPLES, ARG_IGNORE_EXAMPLES_LONG, false, ARG_IGNORE_EXAMPLES_MAN) .addOption(ARG_IGNORE_TERMS, ARG_IGNORE_TERMS_LONG, false, ARG_IGNORE_TERMS_MAN) .addOption(ARG_IGNORE_SITE, ARG_IGNORE_SITE_LONG, false, ARG_IGNORE_SITE_MAN); private static final Console console = System.console(); public SAREFPipeline getSAREFPipeline(String[] args) throws RuntimeException { if (args.length == 0) { displayHelp(-1); } final Mode mode; final boolean ignoreExamples; final boolean ignoreTerms; final boolean ignoreSite; final File directory; try { switch (args[0]) { case "develop": mode = Mode.DEVELOP; break; case "portal": mode = Mode.PORTAL; break; case "release": mode = Mode.RELEASE; break; case "clean": mode = Mode.CLEAN; break; case "help": displayHelp(0); throw new RuntimeException(); default: LOG.error(String.format("<mode> %s is invalid. Valid modes are develop, portal, release, help.", args[0])); displayHelp(-1); throw new RuntimeException(); } DefaultParser commandLineParser = new DefaultParser(); String[] options = Arrays.copyOfRange(args, 1, args.length); CommandLine cl = commandLineParser.parse(OPTIONS, options, true); String dirName = ""; if(!cl.getArgList().isEmpty()) { dirName = cl.getArgList().get(0); } directory = new File(dirName).getCanonicalFile(); if (!directory.isDirectory()) { LOG.error("The directory does not exist " + directory); System.exit(-1); } ignoreExamples = cl.hasOption(ARG_IGNORE_EXAMPLES); ignoreTerms = cl.hasOption(ARG_IGNORE_TERMS); ignoreSite = cl.hasOption(ARG_IGNORE_SITE); return new SAREFPipeline(this, directory, mode, ignoreExamples, ignoreTerms, ignoreSite); } catch (IOException | ParseException ex) { LOG.debug("Exception while parsing arguments", ex); throw new RuntimeException(); } } private void displayHelp(int returnCode) { try { String helpHeader = IOUtils.toString( CLIExecution.class.getClassLoader().getResourceAsStream("cli/helpHeader.txt"), StandardCharsets.UTF_8); String helpCmdLineSyntax = IOUtils.toString( CLIExecution.class.getClassLoader().getResourceAsStream("cli/helpCmdLineSyntax.txt"), StandardCharsets.UTF_8); String helpFooter = IOUtils.toString( CLIExecution.class.getClassLoader().getResourceAsStream("cli/helpFooter.txt"), StandardCharsets.UTF_8); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(helpCmdLineSyntax, helpHeader, OPTIONS, helpFooter); System.exit(returnCode); } catch (IOException ex) { LOG.debug("Exception while displaying help", ex); throw new RuntimeException(); } } @Override public String getUsername(String hostName) { if (console != null) { return console.readLine(SAREF.getMessage(MESSAGE.account_name.toString(), hostName)); } else if (System.getenv("GITLAB_CI") != null) { LOG.info("using username 'gitlab-ci-token'"); return "gitlab-ci-token"; } else { LOG.warn(SAREF.getMessage(MESSAGE.account_name_empty.toString(), hostName)); return ""; } } @Override public char[] getPassword(String hostName) { if (console != null) { return console.readPassword(SAREF.getMessage(MESSAGE.account_password.toString(), hostName)); } else if (System.getenv("GITLAB_CI") != null) { return System.getenv("CI_JOB_TOKEN").toCharArray(); } else { LOG.warn(SAREF.getMessage(MESSAGE.account_password_empty.toString(), hostName)); return "".toCharArray(); } } } Loading
LICENSE 0 → 100644 +23 −0 Original line number Diff line number Diff line Copyright 2020 ETSI Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. No newline at end of file
README.md +16 −1 Original line number Diff line number Diff line # Description # SAREF Pipeline This project integrates the SAREF development and documentation generation pipeline Sources of the SAREF pipeline as specified in Technical Specification: ETSI TS 103 673 V1.1.1: "SmartM2M; SAREF Development Framework and Workflow, Streamlining the Development of SAREF and its Extensions" The SAREF pipeline is part of the SAREF Development Framework https://portal.etsi.org/STF/STFs/STF-HomePages/STF578 [Download the latest build here](https://gitlab.emse.fr/saref/saref-pipeline/-/jobs/artifacts/master/raw/target/saref-pipeline.jar?job=build) This SAREF-Pipeline may be run: - by double-clicking the JAR file to starting the graphical user interface - or using the command line interface, run `java -jar saref-pipeline.jar help` to get started
pom.xml +42 −21 Original line number Diff line number Diff line Loading @@ -170,32 +170,17 @@ <version>1.4.5.519</version> </dependency> <dependency> <groupId>org.openjfx</groupId> <artifactId>javafx-controls</artifactId> <version>11</version> </dependency> </dependencies> <build> <finalName>${project.artifactId}</finalName> <plugins> <plugin> <artifactId>maven-assembly-plugin</artifactId> <version>3.2.0</version> <configuration> <finalName>static</finalName> <appendAssemblyId>false</appendAssemblyId> <descriptors> <descriptor>src/main/static/assembly.xml</descriptor> </descriptors> <outputDirectory>${project.build.outputDirectory}</outputDirectory> </configuration> <executions> <execution> <id>static</id> <phase>process-resources</phase> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> Loading Loading @@ -247,5 +232,41 @@ </configuration> </plugin> </plugins> <pluginManagement> <plugins> <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself. --> <plugin> <groupId>org.eclipse.m2e</groupId> <artifactId>lifecycle-mapping</artifactId> <version>1.0.0</version> <configuration> <lifecycleMappingMetadata> <pluginExecutions> <pluginExecution> <pluginExecutionFilter> <groupId> org.apache.maven.plugins </groupId> <artifactId> maven-assembly-plugin </artifactId> <versionRange> [3.2.0,) </versionRange> <goals> <goal>single</goal> </goals> </pluginExecutionFilter> <action> <ignore></ignore> </action> </pluginExecution> </pluginExecutions> </lifecycleMappingMetadata> </configuration> </plugin> </plugins> </pluginManagement> </build> </project>
run.shdeleted 100644 → 0 +0 −1 Original line number Diff line number Diff line mvn exec:java -Dexec.args="-d ../saref-core"
src/main/java/fr/emse/gitlab/saref/CLIExecution.java 0 → 100644 +175 −0 Original line number Diff line number Diff line /* * Copyright 2020 ETSI * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. */ package fr.emse.gitlab.saref; import java.io.Console; import java.io.File; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.Arrays; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.DefaultParser; import org.apache.commons.cli.HelpFormatter; import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; import org.apache.commons.io.IOUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import fr.emse.gitlab.saref.SAREFPipeline.Mode; /** * * @author Maxime Lefrançois, Omar Qawasmeh * */ public class CLIExecution implements SAREFCredentialsProvider { private static final Logger LOG = LoggerFactory.getLogger(CLIExecution.class); private static final String ARG_IGNORE_EXAMPLES = "e"; private static final String ARG_IGNORE_EXAMPLES_LONG = "no-examples"; private static final String ARG_IGNORE_EXAMPLES_MAN = "Do not check examples"; private static final String ARG_IGNORE_SITE = "s"; private static final String ARG_IGNORE_SITE_LONG = "no-site"; private static final String ARG_IGNORE_SITE_MAN = "Do not generate the static portal"; private static final String ARG_IGNORE_TERMS = "t"; private static final String ARG_IGNORE_TERMS_LONG = "no-terms"; private static final String ARG_IGNORE_TERMS_MAN = "Do not generate the static portal for terms"; private static final Options OPTIONS = new Options() .addOption(ARG_IGNORE_EXAMPLES, ARG_IGNORE_EXAMPLES_LONG, false, ARG_IGNORE_EXAMPLES_MAN) .addOption(ARG_IGNORE_TERMS, ARG_IGNORE_TERMS_LONG, false, ARG_IGNORE_TERMS_MAN) .addOption(ARG_IGNORE_SITE, ARG_IGNORE_SITE_LONG, false, ARG_IGNORE_SITE_MAN); private static final Console console = System.console(); public SAREFPipeline getSAREFPipeline(String[] args) throws RuntimeException { if (args.length == 0) { displayHelp(-1); } final Mode mode; final boolean ignoreExamples; final boolean ignoreTerms; final boolean ignoreSite; final File directory; try { switch (args[0]) { case "develop": mode = Mode.DEVELOP; break; case "portal": mode = Mode.PORTAL; break; case "release": mode = Mode.RELEASE; break; case "clean": mode = Mode.CLEAN; break; case "help": displayHelp(0); throw new RuntimeException(); default: LOG.error(String.format("<mode> %s is invalid. Valid modes are develop, portal, release, help.", args[0])); displayHelp(-1); throw new RuntimeException(); } DefaultParser commandLineParser = new DefaultParser(); String[] options = Arrays.copyOfRange(args, 1, args.length); CommandLine cl = commandLineParser.parse(OPTIONS, options, true); String dirName = ""; if(!cl.getArgList().isEmpty()) { dirName = cl.getArgList().get(0); } directory = new File(dirName).getCanonicalFile(); if (!directory.isDirectory()) { LOG.error("The directory does not exist " + directory); System.exit(-1); } ignoreExamples = cl.hasOption(ARG_IGNORE_EXAMPLES); ignoreTerms = cl.hasOption(ARG_IGNORE_TERMS); ignoreSite = cl.hasOption(ARG_IGNORE_SITE); return new SAREFPipeline(this, directory, mode, ignoreExamples, ignoreTerms, ignoreSite); } catch (IOException | ParseException ex) { LOG.debug("Exception while parsing arguments", ex); throw new RuntimeException(); } } private void displayHelp(int returnCode) { try { String helpHeader = IOUtils.toString( CLIExecution.class.getClassLoader().getResourceAsStream("cli/helpHeader.txt"), StandardCharsets.UTF_8); String helpCmdLineSyntax = IOUtils.toString( CLIExecution.class.getClassLoader().getResourceAsStream("cli/helpCmdLineSyntax.txt"), StandardCharsets.UTF_8); String helpFooter = IOUtils.toString( CLIExecution.class.getClassLoader().getResourceAsStream("cli/helpFooter.txt"), StandardCharsets.UTF_8); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(helpCmdLineSyntax, helpHeader, OPTIONS, helpFooter); System.exit(returnCode); } catch (IOException ex) { LOG.debug("Exception while displaying help", ex); throw new RuntimeException(); } } @Override public String getUsername(String hostName) { if (console != null) { return console.readLine(SAREF.getMessage(MESSAGE.account_name.toString(), hostName)); } else if (System.getenv("GITLAB_CI") != null) { LOG.info("using username 'gitlab-ci-token'"); return "gitlab-ci-token"; } else { LOG.warn(SAREF.getMessage(MESSAGE.account_name_empty.toString(), hostName)); return ""; } } @Override public char[] getPassword(String hostName) { if (console != null) { return console.readPassword(SAREF.getMessage(MESSAGE.account_password.toString(), hostName)); } else if (System.getenv("GITLAB_CI") != null) { return System.getenv("CI_JOB_TOKEN").toCharArray(); } else { LOG.warn(SAREF.getMessage(MESSAGE.account_password_empty.toString(), hostName)); return "".toCharArray(); } } }