This article explains how you can make LuciadLightspeed available through Apache Maven. Maven is a development project management and build automation tool. More information is available on the Maven website: http://maven.apache.org/.

## Deploying to a repository

Luciad provides Project Object Model (POM) files for all libraries available in LuciadLightspeed. You can find those POM files in the `build/maven/pom` directory. To deploy them to your repository, run the script `deploy.sh` or `deploy.bat` in the `build/maven` directory. If you prefer to deploy private dependencies only, you can use the script `deploy.private.sh` or `deploy.private.bat` in the `build/maven` directory.

 Private dependencies are: Dependencies that aren’t available in public Maven repositories. Dependencies that are available in public Maven repositories, but have a customized Luciad build, with a Luciad-specific version number.

When you run these scripts, you must give the URL and credentials to your Maven repository. The script then deploys all libraries available in your release.

 The deployment script requires at least Ant 1.9.1. Ant must have access to the Maven Ant tasks library. You can give Ant access to that Maven Tasks library, either by storing it in Ant’s `lib` directory, by including it in the CLASSPATH environment variable, or by supplying it through the `-lib` command line parameter. LuciadLightspeed provides recent versions of the Maven Ant Tasks library in the `build/ant` directory of the LuciadLightspeed installation.
 If you want support for protocols other than `file` and `http`, you can make use of Maven Wagon. See http://maven.apache.org/wagon/ for more information.

The available product tier POM dependencies

Table 1. Overview of available optional components and their POM dependency name
Optional Component Name POM Dependency Name

Aviation Standards

Database Connectors

Defense Standards

Defense Symbology

Graph and Routing Engine

Infrastructure Standards

Maritime Standards

OGC Server

S-63

Terrain Analysis Engine

Weather & Environment Standards

You can put this information in your POM file to add a dependency for the LuciadLightspeed Pro tier:

``````    <dependency>
<version>${luciad.version}</version> <type>pom</type> </dependency>``````  The example uses a placeholder for the LuciadLightspeed version. It’s recommended to define a Maven property for the LuciadLightspeed version as a value placeholder, to prevent an accidental mixing of versions. As a result, you only have to update the version number once, in the properties, when you upgrade to a new LuciadLightspeed version. ### Adding a license LuciadLightspeed license files aren’t automatically uploaded to the repository. You can add license files manually by means of Maven’s `deploy-file` goal, as in the example below. Program: Adding a license ``````mvn deploy:deploy-file \ -DgroupId=com.yourcompany \ # Do not use com.luciad. -DartifactId=luciadlightspeed_development_license \ -Dversion=2021.0-20210404 \ # For instance the date that the license was received. -Dpackaging=jar \ -Dfile=development.jar \ -Durl=yourCompanyRepositoryUrl \ -DrepositoryId=yourCompanyRepositoryId \ # Server Id to map on the <id> under <server> section of # settings.xml. # This parameter will be required for # authentication when using a remote repository. # This parameter can be omitted when using a local repo.``````  If you have more than one application, and each application uses a different Luciad license, you must ensure that the `artifactId` for each of these license files is unique.  If you are using a remote repository, you must authenticate the `deploy:deploy-file` command. To do so, you must define a server in your `settings.xml` with the necessary credentials, and pass the server ID to the command using the `repositoryId` parameter. Here is an example server configuration in `settings.xml`: Program: Settings.xml configuration `````` yourCompanyRepositoryId yourCompanyRepositoryUrl username password `````` Next, in your project’s `pom.xml`, specify: Program: Adding a license `````` <dependency> <groupId>com.yourcompany</groupId> <artifactId>luciadlightspeed_deployment_license</artifactId> <version>${luciad.license.version}</version>
</dependency>``````

### Adding JavaFX dependencies for JDK 11 and above

As of version 11, JavaFX has been removed from the Java Development Kit (JDK). JavaFX is now available as a standalone release. If you use JDK 11 or higher and want to create a JavaFX application, or compile the LuciadLightspeed JavaFX samples, you must add JavaFX dependencies to your project.

In your project’s `pom.xml`, specify:

``````    <dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-base</artifactId>
<version>11</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-swing</artifactId>
<version>11</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>11</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<version>11</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-web</artifactId>
<version>11</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>11</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-media</artifactId>
<version>11</version>
</dependency>``````

### Adding an execution plugin (optional)

If you want to run Lucy from the command line, you can add this plugin configuration to your project’s `pom.xml`. Once you configured this plugin, you can run the LucyMapCentric application using the command `mvn compile exec:java`. Alternatively, you can execute any LuciadLightspeed sample by changing the `mainClass` in this configuration to the main class of the sample you want to execute. For example, you can switch it to `samples.gxy.decoder.MainPanel` to execute the GXY decoder sample.

 For an explanation of the configured system properties, see the IDE integration article.
``````      <plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>java</executable>
<longClasspath>true</longClasspath>
<arguments>
<argument>-Djava.net.useSystemProxies=true</argument>
<argument>-Dsun.awt.noerasebackground=true</argument>
<argument>-Dsun.java2d.opengl=false</argument>
<argument>-Dswing.aatext=true</argument>
<argument>-Dsun.java2d.d3d=false</argument>
<argument>-Djava.library.path=</argument>
<argument>-Xmx2g</argument>
<argument>-classpath</argument>
<classpath/>
<argument>samples.lucy.frontend.mapcentric.Main</argument>
</arguments>
</configuration>
</plugin>``````

The LuciadLightspeed deployment license requires you to obfuscate the class files of the LuciadLightspeed API when you deploy your application. You can achieve this by adding the following plugin configuration that will perform the obfuscation step.

``````      <plugin>
<groupId>com.github.wvengen</groupId>
<artifactId>proguard-maven-plugin</artifactId>
<version>2.2.0</version>
<executions>
<execution>
<id>proguard</id>
<phase>package</phase>
<goals>
<goal>proguard</goal>
</goals>
</execution>
</executions>
<configuration>
<proguardVersion>${proguard.version}</proguardVersion> <proguardInclude>src/proguard/sampleproject.pro</proguardInclude> <outjar>obfuscated/</outjar> <libs> <!-- for Java <= 1.8 --> <lib>${java.home}/lib/rt.jar</lib>
<lib>${java.home}/lib/jce.jar</lib> <lib>${java.home}/lib/jsse.jar</lib>
<lib>${java.home}/lib/ext/jfxrt.jar</lib> <!-- for OpenJDK >= 11.0 --> <!-- remove <lib> elements above and uncomment <lib> elements below --> <!-- <lib>${java.home}/jmods</lib> -->
<!-- <lib>${openjfx.home}/jmods</lib> --> </libs> <assembly> <inclusions> <inclusion> <groupId>com.luciad</groupId> <artifactId>*</artifactId> <filter>!**.pom</filter> </inclusion> </inclusions> </assembly> </configuration> <dependencies> <dependency> <groupId>net.sf.proguard</groupId> <artifactId>proguard-base</artifactId> <version>${proguard.version}</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</plugin>``````

This configuration includes the ProGuard configuration file `src/proguard/sampleproject.lightspeed.pro` from your Maven project root. This file includes the ProGuard configuration files `build/proguard/luciadlightspeed.pro` and `build/proguard/lucy_end_user.pro` of your LuciadLightspeed release. You can also add any custom ProGuard configuration to this file. You could exclude your own code from obfuscation, for example.

Program: ProGuard configuration
``````# Include Lightspeed ProGuard configuration
# Include Lucy ProGuard configuration
-include lucy_end_user.pro
# Include the samples ProGuard configuration if you intend to compile the samples
# -include samples.pro

# -keep class com.example.** {
#  public protected private *;
# }``````

To package your application in an easily distributable archive, you can add the following Assembly plugin to your project’s `pom.xml`.

``````      <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<tarLongFileMode>posix</tarLongFileMode>
<descriptors>
<descriptor>src/assembly/lightspeed.app.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>package-deliverable</id>
<goals>
<goal>single</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>``````

This configuration includes the descriptor `src/assembly/lightspeed.app.xml` from your Maven project root. This file describes that the application must be packaged into a zip archive. It lists a number of static file dependencies (`fileSets`) and Java library dependencies (`dependencySets`) that must be included in the zip.

Expand this section to view the example assembly descriptor file

Program: Assembly descriptor
``````<assembly xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">

<id>app</id>

<formats>
<format>zip</format>
</formats>

<includeBaseDirectory>true</includeBaseDirectory>

<fileSets>
<fileSet>
<!-- This folder should contain all files contained in the config folder of your LuciadLightspeed release. -->
<directory>src/main/resources/config</directory>
<outputDirectory>config</outputDirectory>
<fileMode>0644</fileMode>
</fileSet>
<fileSet>
<!-- This folder should contain a script file that allows to easily start running Lucy MapCentric. -->
<directory>src/main/resources/scripts</directory>
<outputDirectory/>
<fileMode>0755</fileMode>
</fileSet>
<fileSet>
<!-- This folder should contain all obfuscated libraries resulting from the obfuscation step. This folder is configured in the Proguard plugin. -->
<directory>target/obfuscated</directory>
<outputDirectory>lib</outputDirectory>
</fileSet>
</fileSets>

<dependencySets>
<dependencySet>
<useStrictFiltering>false</useStrictFiltering>
<useProjectArtifact>false</useProjectArtifact>
<scope>compile</scope>
<includes>
<include>*:jar:*</include>
</includes>
<excludes>
<!-- Exclude the unobfuscated versions the dependencies that get obfuscated. The obfuscated version will be included in the runtime dependencySet. -->
</excludes>
<outputDirectory>lib</outputDirectory>
</dependencySet>
<dependencySet>
<useStrictFiltering>false</useStrictFiltering>
<scope>runtime</scope>
<includes>
<include>*:jar:*</include>
</includes>
<outputDirectory>lib</outputDirectory>
</dependencySet>
</dependencySets>
</assembly>``````

This assembly descriptor assumes that your application launch scripts are located in the directory `src/main/resources/scripts` of your Maven project. Here are some example script files that you can use to run Lucy MapCentric:

Expand this section to view the example batch script file

Program: A batch script used to run Lucy MapCentric
``````@echo off

REM memory limit
set JAVA_OPTS=%JAVA_OPTS% -Xmx2000m

REM rendering pipeline
set JAVA_OPTS=%JAVA_OPTS% -Dsun.java2d.opengl=false -Dsun.java2d.noddraw=true -Dsun.java2d.d3d=false

REM drawing quality
set JAVA_OPTS=%JAVA_OPTS% -Dsun.awt.noerasebackground=true -Dswing.aatext=true

REM network connectivity
set JAVA_OPTS=%JAVA_OPTS% -Djava.net.useSystemProxies=true

REM user language
set JAVA_OPTS=%JAVA_OPTS% -Duser.language=en

REM launch application
start javaw %JAVA_OPTS% -cp config;lib\* samples.lucy.frontend.mapcentric.Main

@echo on``````

Expand this section to view the example bash script file

Program: A shell script used to run Lucy MapCentric
``````#!/bin/sh

# memory limits and garbage collection settings
JAVA_OPTS="$JAVA_OPTS -Xmx2000m" # rendering pipeline JAVA_OPTS="$JAVA_OPTS -Dsun.java2d.opengl=false -Dsun.java2d.noddraw=true  -Dsun.java2d.d3d=false"

# drawing quality
JAVA_OPTS="$JAVA_OPTS -Dsun.awt.noerasebackground=true -Dswing.aatext=true" # network connectivity JAVA_OPTS="$JAVA_OPTS -Djava.net.useSystemProxies=true"

# improve debugging behavior
JAVA_OPTS="$JAVA_OPTS -Dsun.awt.disablegrab=true" # user language JAVA_OPTS="$JAVA_OPTS -Duser.language=en"

java $JAVA_OPTS -cp config:lib/* samples.lucy.frontend.mapcentric.Main`````` ### Setting up the sample project The `build/maven` directory also contains the script files `setup-sample-project.bat` and `setup-sample-project.sh`. If you run one of these scripts, it sets up a sample Maven project in the directory `build/maven/sampleProject` of your LuciadLightspeed release. This directory contains all sample source and resource files present in your release, and a `pom.xml` file configured to depend on all Luciad components present in your release. In the sample project directory: 1. Run the command `mvn compile` to compile all samples. 2. Run `mvn exec:exec` to start Lucy MapCentric. 3. Run `mvn package` to generate a zip file containing all files necessary to run your application. ### Example POM file This is a complete example of a `pom.xml` file for a project that depends on LuciadLightspeed Pro. Expand this section to view the example POM file Program: A complete example POM file ``````<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.yourcompany</groupId> <artifactId>sample-project</artifactId> <version>1.0-SNAPSHOT</version> <packaging>jar</packaging> <name>sample-project</name> <url>http://maven.apache.org</url> <repositories> <repository> <id>luciad-repo</id> <name>Luciad Maven Repository</name> <url>yourCompanyUrl</url> </repository> <repository> <id>mvn-central</id> <name>Maven Central Repository</name> <layout>default</layout> <url>https://repo1.maven.org/maven2</url> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories> <properties> <luciad.version>2021.0</luciad.version> <luciad.license.version>2021.0-20210404</luciad.license.version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <proguard.version>6.2.2</proguard.version> </properties> <build> <resources> <resource> <directory>src/main/resources</directory> </resource> </resources> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.3</version> <configuration> <source>1.8</source> <target>1.8</target> <fork>true</fork> <encoding>UTF-8</encoding> <meminitial>512m</meminitial> <maxmem>2048m</maxmem> </configuration> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <executions> <execution> <goals> <goal>exec</goal> </goals> </execution> </executions> <configuration> <executable>java</executable> <longClasspath>true</longClasspath> <arguments> <argument>-Djava.net.useSystemProxies=true</argument> <argument>-Dsun.awt.noerasebackground=true</argument> <argument>-Dsun.java2d.opengl=false</argument> <argument>-Dswing.aatext=true</argument> <argument>-Dsun.java2d.d3d=false</argument> <argument>-Djava.library.path=</argument> <argument>-Xmx2g</argument> <argument>-classpath</argument> <classpath/> <argument>samples.lucy.frontend.mapcentric.Main</argument> </arguments> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>3.2.0</version> <configuration> <archive> <manifest> <addClasspath>true</addClasspath> </manifest> </archive> </configuration> </plugin> <plugin> <groupId>com.github.wvengen</groupId> <artifactId>proguard-maven-plugin</artifactId> <version>2.2.0</version> <executions> <execution> <id>proguard</id> <phase>package</phase> <goals> <goal>proguard</goal> </goals> </execution> </executions> <configuration> <proguardVersion>${proguard.version}</proguardVersion>
<proguardInclude>src/proguard/sampleproject.pro</proguardInclude>
<outjar>obfuscated/</outjar>
<libs>
<!-- for Java <= 1.8 -->
<lib>${java.home}/lib/rt.jar</lib> <lib>${java.home}/lib/jce.jar</lib>
<lib>${java.home}/lib/jsse.jar</lib> <lib>${java.home}/lib/ext/jfxrt.jar</lib>
<!-- for OpenJDK >= 11.0 -->
<!-- remove <lib> elements above and uncomment <lib> elements below -->
<!-- <lib>${java.home}/jmods</lib> --> <!-- <lib>${openjfx.home}/jmods</lib> -->
</libs>
<assembly>
<inclusions>
<inclusion>
<artifactId>*</artifactId>
<filter>!**.pom</filter>
</inclusion>
</inclusions>
</assembly>
</configuration>
<dependencies>
<dependency>
<groupId>net.sf.proguard</groupId>
<artifactId>proguard-base</artifactId>
<version>${proguard.version}</version> <scope>runtime</scope> </dependency> </dependencies> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <version>3.1.1</version> <configuration> <tarLongFileMode>posix</tarLongFileMode> <descriptors> <descriptor>src/assembly/lightspeed.app.xml</descriptor> </descriptors> </configuration> <executions> <execution> <id>package-deliverable</id> <goals> <goal>single</goal> </goals> <phase>package</phase> </execution> </executions> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>com.luciad</groupId> <artifactId>luciadlightspeed_pro</artifactId> <version>${luciad.version}</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>com.yourcompany</groupId>
<version>${luciad.license.version}</version> </dependency> <dependency> <groupId>org.openjfx</groupId> <artifactId>javafx-base</artifactId> <version>11</version> </dependency> <dependency> <groupId>org.openjfx</groupId> <artifactId>javafx-swing</artifactId> <version>11</version> </dependency> <dependency> <groupId>org.openjfx</groupId> <artifactId>javafx-controls</artifactId> <version>11</version> </dependency> <dependency> <groupId>org.openjfx</groupId> <artifactId>javafx-graphics</artifactId> <version>11</version> </dependency> <dependency> <groupId>org.openjfx</groupId> <artifactId>javafx-web</artifactId> <version>11</version> </dependency> <dependency> <groupId>org.openjfx</groupId> <artifactId>javafx-fxml</artifactId> <version>11</version> </dependency> <dependency> <groupId>org.openjfx</groupId> <artifactId>javafx-media</artifactId> <version>11</version> </dependency> <!-- Optional components available for Advanced and Pro Tiers --> <!-- <dependency> <groupId>com.luciad</groupId> <artifactId>luciadlightspeed_database_connectors</artifactId> <version>${luciad.version}</version>
<type>pom</type>
</dependency>
-->
<!--
<dependency>
<version>${luciad.version}</version> <type>pom</type> </dependency> --> <!-- <dependency> <groupId>com.luciad</groupId> <artifactId>luciadlightspeed_graph_and_routing_engine</artifactId> <version>${luciad.version}</version>
<type>pom</type>
</dependency>
-->
<!--
<dependency>
<version>${luciad.version}</version> <type>pom</type> </dependency> --> <!-- <dependency> <groupId>com.luciad</groupId> <artifactId>luciadlightspeed_terrain_analysis_engine</artifactId> <version>${luciad.version}</version>
<type>pom</type>
</dependency>
-->
<!--
<dependency>
<version>${luciad.version}</version> <type>pom</type> </dependency> --> <!-- Optional components available for Pro Tier only --> <!-- <dependency> <groupId>com.luciad</groupId> <artifactId>luciadlightspeed_aviation_standards</artifactId> <version>${luciad.version}</version>
<type>pom</type>
</dependency>
-->
<!--
<dependency>
<version>${luciad.version}</version> <type>pom</type> </dependency> --> <!-- <dependency> <groupId>com.luciad</groupId> <artifactId>luciadlightspeed_defense_symbology</artifactId> <version>${luciad.version}</version>
<type>pom</type>
</dependency>
-->
<!--
<dependency>
<version>${luciad.version}</version> <type>pom</type> </dependency> --> <!-- <dependency> <groupId>com.luciad</groupId> <artifactId>luciadlightspeed_maritime_standards</artifactId> <version>${luciad.version}</version>
<type>pom</type>
</dependency>
-->
<!--
<dependency>
<version>${luciad.version}</version> <type>pom</type> </dependency> --> <!-- <dependency> <groupId>com.luciad</groupId> <artifactId>luciadlightspeed_s63</artifactId> <version>${luciad.version}</version>