Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "BaSyx / Download / Java Setup"

m (Updates content to reflect the most recent build)
(Clean and update information about Java SDK setup)
Line 1: Line 1:
 
= How to build the BaSyx Java SDK =
 
= How to build the BaSyx Java SDK =
  
The BaSyx Java SDK is using maven to generate and control its building process.
+
The BaSyx Java SDK is using Maven to generate and control its building process.
This article will detail on how to build the Java SDK from a fresh checkout.
+
 
 +
This article will detail on how to set up the Java SDK from a new checkout.
  
 
== Requirements ==
 
== Requirements ==
Line 12: Line 13:
  
 
== Getting started ==
 
== Getting started ==
Check out BaSyx from the command line with
+
# Check out BaSyx from the command line with "git clone https://git.eclipse.org/r/basyx/basyx"
 
+
# Start Eclipse and import the projects as maven projects (File -> Import -> Maven -> Existing Maven Projects -> Browse to the BaSyx directory)
git clone https://git.eclipse.org/r/basyx/basyx
+
# Select (at least) the following Projects and click "Finish":
 
+
into some directory of your choice. Now start Eclipse, open File -> Import, choose Maven -> Existing Maven Projects, and click "Next". Now click "Browse", and navigate to the directory where BaSyx was checked out to.
+
 
+
Now select (at least) the following Projects and click "Finish".
+
* basyx.sdk
+
* basyx.components
+
* basyx.examples
+
 
+
  
 
[[File:Project-selection.png|500px]]
 
[[File:Project-selection.png|500px]]
  
Now all of them will be imported to the Eclipse IDE as maven projects.
+
The Maven projects should be automatically set up in Eclipse. You can always update the project settings using the Maven plugin (Right Click -> Maven -> Update Project).  
  
=== Starting development ===
+
=== Project dependencies ===
In order to start developing on the project, the first thing you need to do is
+
All dependencies for maven projects are specified in the project's pom.xml. When building the project using maven, these dependencies will be automatically taken from the local maven repository (default: ''C:/User/username/.m2/repository'') and downloaded from the remote repository if it is not available locally.
  
# Make sure that each project has a JDK selected as JRE System Library
+
The imported projects (sdk, components and examples) depend on each other as shown below:
# Right-click “basyx.sdk” >> Select “Run As” >> Select “Maven Install”
+
Maven will download all required sources, run the unit and integration tests and install the projects into the local maven repository.
+
Note: If the JRE System Library is not set up in Eclipse, the following error will occur:
+
''No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?''
+
* Preferences >> Java >> Installed JREs >> Enable the JDK
+
* >> Execution Environments >> JavaSE-1.8 >> Enable the JDK
+
 
+
 
+
The mentioned projects are depending on each other as shown below:
+
  
 
[[File:BaSyx_Java_Dependencies.PNG]]
 
[[File:BaSyx_Java_Dependencies.PNG]]
  
This means basyx.components depends on basyx.sdk and basyx.examples depends on both of the two other projects. So if you make changes in e.g. basyx.sdk, you need to "install" it with maven. This reflects these changes in the other projects.
+
This means '''basyx.components''' depends on '''basyx.sdk''' and '''basyx.examples''' depends on the two other projects. So if you make changes in e.g. basyx.sdk, you need to "install" it to the local repository using Maven before building components that depend on it.
  
Before you get started, the second task you need to do is to update the basyx.sdk project to align with the maven configuration. For this what you need to do is
+
=== Project installation ===
* Right-click “basyx.sdk” >> Select “Maven” >> Select “Update Project…” (ignore errors)
+
# Make sure that each project has a JDK selected as JRE System Library
 
+
## Window -> Preferences -> Java -> Installed JREs -> Enable the '''JDK'''
Finally, the last step is to run a Maven clean compile to make sure that the changes you do during coding are directly reflected when you execute single unit tests manually.
+
## -> Execution Environments -> JavaSE-1.8 -> Enable the JDK in the list of compatible JREs
* Right-click “basyx.sdk” >> Select “Run As” >> Select “Build…”, type “clean test-compile” in the "Goals" field and click "Run".
+
# Install '''basyx.sdk'''
 +
## Right click -> Run As -> Maven install
 +
## Maven will download all required dependencies, run the tests and build and install the project into the local Maven repository
 +
## You can ignore errors in the output coming from testing exceptions in unit tests
 +
## If successful, you will see the message: ''[INFO] BUILD SUCCESS''
 +
# Prepare the components as described in [[BaSyx_/_Download_/_Components_Setup|Setting up the Components project]]
 +
# Install '''basyx.components''' and '''basyx.examples'''
 +
# Done
  
'' Note: If changes do not reflect in manual unit testing, make sure to clean compile after each install!''
+
After installation build outputs are placed in the /target folder and installed in the local Maven repository.
  
To make basyx.examples compile, you need to do a Maven install of basys.components first. This, in turn, requires to set up and run your postgreSQL installation as [[BaSyx:BaSyx.Documentation.Component.Build | described here]].
+
The '''[[BaSyx_/_Examples | basyx.examples]]''' project is a good starting point that shows how the SDK can be included and used by another project.
 +
Also look at '''[[BaSyx_/_Download_/_Components_Setup|basyx.components]]''' to get a description about how to set up and use components that are built on the '''basyx.sdk'''.

Revision as of 06:54, 5 March 2020

How to build the BaSyx Java SDK

The BaSyx Java SDK is using Maven to generate and control its building process.

This article will detail on how to set up the Java SDK from a new checkout.

Requirements

The BaSyx Java SDK requires the following dependencies to successfully build:

  • Java™ SE Development Kit 8, Update 152 (JDK 8u152 or higher)
  • Maven

To check out BaSyx, you also need a GIT installation. No Eclipse GIT plugin is required as we can do the checkout by using GIT only from the command line. If you want to checkout using Eclipse, you need the EGit plugin and also the Maven SCM Handler for EGit (more on that below).

Getting started

  1. Check out BaSyx from the command line with "git clone https://git.eclipse.org/r/basyx/basyx"
  2. Start Eclipse and import the projects as maven projects (File -> Import -> Maven -> Existing Maven Projects -> Browse to the BaSyx directory)
  3. Select (at least) the following Projects and click "Finish":

Project-selection.png

The Maven projects should be automatically set up in Eclipse. You can always update the project settings using the Maven plugin (Right Click -> Maven -> Update Project).

Project dependencies

All dependencies for maven projects are specified in the project's pom.xml. When building the project using maven, these dependencies will be automatically taken from the local maven repository (default: C:/User/username/.m2/repository) and downloaded from the remote repository if it is not available locally.

The imported projects (sdk, components and examples) depend on each other as shown below:

BaSyx Java Dependencies.PNG

This means basyx.components depends on basyx.sdk and basyx.examples depends on the two other projects. So if you make changes in e.g. basyx.sdk, you need to "install" it to the local repository using Maven before building components that depend on it.

Project installation

  1. Make sure that each project has a JDK selected as JRE System Library
    1. Window -> Preferences -> Java -> Installed JREs -> Enable the JDK
    2. -> Execution Environments -> JavaSE-1.8 -> Enable the JDK in the list of compatible JREs
  2. Install basyx.sdk
    1. Right click -> Run As -> Maven install
    2. Maven will download all required dependencies, run the tests and build and install the project into the local Maven repository
    3. You can ignore errors in the output coming from testing exceptions in unit tests
    4. If successful, you will see the message: [INFO] BUILD SUCCESS
  3. Prepare the components as described in Setting up the Components project
  4. Install basyx.components and basyx.examples
  5. Done

After installation build outputs are placed in the /target folder and installed in the local Maven repository.

The basyx.examples project is a good starting point that shows how the SDK can be included and used by another project. Also look at basyx.components to get a description about how to set up and use components that are built on the basyx.sdk.

Back to the top