Snippets

Sebastian Sardina FAQ for using SARL + SWI/JPL Prolog + Maven

Updated by Sebastian Sardina

File SARL-FAQ.markdown Modified

  • Ignore whitespace
  • Hide word diff
 To state the POM to get all sources (and javadocs) of dependencies, check [this post](https://stackoverflow.com/questions/11361331/how-to-download-sources-for-a-jar-with-maven/11361413)
 
 
-
-
-
-
-
+### Error from Google Lirary related to a Java 9 class 
+
+The version of the [maven-compiler-plugin](https://maven.apache.org/plugins/maven-compiler-plugin/) should not be higher than `3.6.2` because the newer versions are using Java 1.9. And, it may cause problems during the compilation process.
+
+In reality, the [maven-compiler-plugin](https://maven.apache.org/plugins/maven-compiler-plugin/) is not mandatory at all in the POM because Maven is supposed to download one when needed for compilation.
+If you encounter strange error related to the use of an Java 9 class from the Google library, then you have to specify the maven-compiler-plugin in order to avoid it:
+
+
+            <plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-compiler-plugin</artifactId>
+				<version>3.6.2</version>
+				<configuration>
+					<source>${compiler.level}</source>
+					<target>${compiler.level}</target>
+					<encoding>${project.build.sourceEncoding}</encoding>
+				</configuration>
+			</plugin>
+
+
+### How to assemble my whole SARL application in a JAR file?
+
+You can use `maven-assembly-plugin` build pluin:
+
+	    <plugin>
+			    <artifactId>maven-assembly-plugin</artifactId>
+			    <version>3.1.0</version>
+			    <configuration>
+			        <archive>
+			            <manifest>
+			                <addClasspath>true</addClasspath>
+			                <mainClass>BootMAS</mainClass>
+			            </manifest>
+			        </archive>
+			        <descriptorRefs>
+			            <descriptorRef>jar-with-dependencies</descriptorRef>
+			        </descriptorRefs>
+			    </configuration>
+			    
+				<!--  EXECUTIONS -->
+			    <executions>
+					<!--  Assemble an application bundle or distribution from an assembly descriptor.  -->
+			        <execution>
+			            <phase>package</phase>
+			            <goals>
+			                <goal>single</goal>
+			            </goals>
+			        </execution>
+			    </executions>
+		    </plugin>
+
+Note that with version `3.1.0`  this may take quite longer to compile, as all dependencies are packaged into a single, often large, JAR file.
 
 
 -----------------------
 # SARL
 
+
+
 ### SARL is similar to Java but has different syntax in many places, how come?
 
 Because it uses and builts on [XTEND](https://www.eclipse.org/xtend/documentation/203_xtend_expressions.html) framework.
Updated by Sebastian Sardina

File SARL-FAQ.markdown Modified

  • Ignore whitespace
  • Hide word diff
 
 If you think a question is worth putting it here, please let me know, I am happy to add it! THANKS!
 
+-----------------------
+## TABLE OF CONTENTS
+
 [TOC]
 
 -----------------------
Updated by Sebastian Sardina

File SARL-FAQ.markdown Modified

  • Ignore whitespace
  • Hide word diff
 
 This is a collection of questions/issues that arose from my teaching of Agent Oriented Programming, where I have assessments in [SARL](http://www.sarl.io/) and [SWI Prolog](http://www.swi-prolog.org/), all packaged with [Apache Maven](https://maven.apache.org/).
 
-[TOC]
+If you think a question is worth putting it here, please let me know, I am happy to add it! THANKS!
 
+[TOC]
 
+-----------------------
 # ECLIPSE
 
 ### How do I make ECLIPSE know about environment variables (e.g., `SARL_VERSION`)?
 
 
 
+-----------------------
 # SWI-PROLOG
 
 
 
 
 
+-----------------------
 # MAVEN
 
 ### How do I tell maven to work offline (not check anything on the internet)?
 
 
 
+-----------------------
 # SARL
 
 ### SARL is similar to Java but has different syntax in many places, how come?
Updated by Sebastian Sardina

File SARL-FAQ.markdown Modified

  • Ignore whitespace
  • Hide word diff
 [TOC]
 
 
-## ECLIPSE
+# ECLIPSE
 
 ### How do I make ECLIPSE know about environment variables (e.g., `SARL_VERSION`)?
 
 If you find another way that ECLIPSE can gather the environment variables (without re-defining them one by one), let me know! 
 
 
-## SWI-PROLOG
+
+
+# SWI-PROLOG
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 
 # MAVEN
 
 
 
 
-## SARL
+
+
+
+
+
+# SARL
 
 ### SARL is similar to Java but has different syntax in many places, how come?
 
Updated by Sebastian Sardina

File SARL-FAQ.markdown Modified

  • Ignore whitespace
  • Hide word diff
 
 ## ECLIPSE
 
+### How do I make ECLIPSE know about environment variables (e.g., `SARL_VERSION`)?
+
+I can imagine there are other ways, but the way I made it work is by starting ECLIPSE from CLI with the variable exported already:
+
+    $ export SARL_ECLIPSE=0.7.2
+    $ ./eclipse-sarl 
+
+If you find another way that ECLIPSE can gather the environment variables (without re-defining them one by one), let me know! 
+
+
 ## SWI-PROLOG
 
 # MAVEN
 
+### How do I tell maven to work offline (not check anything on the internet)?
+
+Use the `-o` option for offline mode (e.g., `mvn -o clean package`): <https://www.packtpub.com/mapt/book/application_development/9781785286124/8/ch08lvl1sec81/working-in-offline-mode>
+
+Note you will still need to build the system online at least one, so that your system has the chance to get all the dependencies and store them under `~/.m2/`
+
+### Why maven is not downloading the sources of dependencies?
+
+ECLPSE IDE seems to download all sources by default. To get the sources via CLI: `mvn dependency:sources`
+
+To state the POM to get all sources (and javadocs) of dependencies, check [this post](https://stackoverflow.com/questions/11361331/how-to-download-sources-for-a-jar-with-maven/11361413)
+
+
+
+
 ## SARL
 
 ### SARL is similar to Java but has different syntax in many places, how come?
  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.