Added the jclouds maven pom

Added the maven pom sample and descriptive text
required by jclouds.

Change-Id: Ifb3569efb3e8de801dbb07553e67c186ec22c4f1
This commit is contained in:
Martin Paulo 2016-07-18 15:13:12 +10:00
parent 1d488ce0a9
commit 1520f952a5
3 changed files with 97 additions and 3 deletions

View File

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>openstack.demo.app</groupId>
<artifactId>faafo_infrastructure</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<jclouds.version>1.9.2</jclouds.version>
</properties>
<dependencies>
<!-- the jclouds code -->
<dependency>
<groupId>org.apache.jclouds</groupId>
<artifactId>jclouds-all</artifactId>
<version>${jclouds.version}</version>
</dependency>
<!-- Some of the examples introduce the logging module -->
<dependency>
<groupId>org.apache.jclouds.driver</groupId>
<artifactId>jclouds-slf4j</artifactId>
<version>${jclouds.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.13</version>
</dependency>
</dependencies>
<build>
<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>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -151,9 +151,53 @@ To interact with the cloud, you must also have
`jClouds 1.8 or higher installed <https://jclouds.apache.org/start/install>`_.
.. warning::
Our code samples use
`Java 8 <http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html>`_.
This document has not yet been completed for the jclouds SDK.
We have created a Maven POM file to help you get started.
If you do not know Maven then the `Maven home site <https://maven.apache.org/what-is-maven.html>`_
is a good place to learn more.
**pom.xml:**
.. literalinclude:: ../samples/jclouds/pom.xml
:language: xml
Place the above pom.xml into the root directory of your project. Then create the nested
subdirectory tree :code:`src` -> :code:`main` -> :code:`java`.
Place the Java code samples that you copy from this book into the folder named ":code:`java`".
So, for example, the file named :code:`GettingStarted.java` from the end of this chapter
would be located as follows:
.. figure:: images/jclouds/screenshot_maven_layout.png
:width: 328px
:align: center
:height: 179px
:alt: Screenshot of the Maven project directory structure
:figclass: align-center
To use Maven to compile a downloaded sample, with the command prompt located in the same
directory as the :code:`pom.xml` file, enter:
.. code-block:: bash
mvn compile
Maven will download and install any dependencies required for compilation, then execute
the Java compiler. All files in the :code:`java` subdirectory will be compiled.
To use Maven to run each downloaded sample, with the command prompt located in the same
directory as the :code:`pom.xml` file, enter:
.. code-block:: bash
# In the sample below replace GettingStarted with the name of the class you want to run
mvn exec:java -Dexec.mainClass="GettingStarted"
Maven will download and install any further dependencies required and then run the chosen
class.
.. only:: libcloud
@ -1750,6 +1794,8 @@ information, the flavor ID, and image ID.
.. only:: jclouds
**GettingStarted.java:**
.. literalinclude:: ../samples/jclouds/GettingStarted.java
:language: java

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB