Creating a new Maven Project
In Eclipse Project Explorer
Adjust the pom.xml file
- Provide a description of your project if you have missed to edit the archetype property (In
<description>
)
- Adjust the URL to your documentation webpage
- Adjust the properties
bundle.mainClass
and git.organization
(the organization of your git project in https://git.acc.gsi.de/ if present)
<properties>
<!-- Adjust this to point to your main class -->
<bundle.mainClass>please.set.the.bundle.properties</bundle.mainClass>
<!-- Adjust this to point to the Git Organisation name where you want to share the project -->
<git.organization>fcc-applications</git.organization>
</properties>
<scm>
<connection>scm:git:${git.view.url}/${git.organization}/${project.artifactId}.git</connection>
<developerConnection>scm:git:${git.dev.url}/${git.organization}/${project.artifactId}.git</developerConnection>
<url>${git.view.url}/${git.organization}/${project.artifactId}/commits/branch/${scmBranch}</url>
<tag>HEAD</tag>
</scm>
- Adjust the URL to your continuous integration location for the project
- Adjust the URL to your projects bugtracker
- Add yourself as developer in the
<developers>
part (change URL to your persons web page)
- provide the correct roles of all developers since these roles are used to generate documentations
- possible roles are: owner, architect, developer, release engineer and tester
- Replace dependencies by e.g.
<dependencies>
<dependency>
<groupId>de.gsi.fcc.commons</groupId>
<artifactId>common-widgets</artifactId>
<version>17.0.0</version> <!-- look for newer version -->
</dependency>
<dependency>
<groupId>de.gsi.fcc.commons</groupId>
<artifactId>common-dependencies</artifactId>
<version>17.0.0</version> <!-- look for newer version -->
</dependency>
</dependencies>
If your project needs some configuration properties, specify them using
How To Configuration (more dynamically).
Checklist for new Applications
- Use the Standard GSI Frame to guarantee a common look: GsiFrame
- System Properties are stored in the common-config repository: Configuration / Startup Options
- Use diagnostic Logging: How to logging
- Use the language translator to internationalize your Application: Language Selector
Build your project
-
Right click on project -> run as -> maven build ...
- use goals
"clean package"
to just ensure your project can be build and to test it locally
or
use goals "compile exec:java"
to run the newly created application
or
use goals "clean install"
to install your project to your local maven repository and build zip file for rollout (ensure the correct codebase is set!)
or
- use
"clean deploy"
to deploy your project to the nexus
Next Steps
Rename the main class and controller
Once you feel safe enough with the project setup you should rename the main method and controller to the actual name of the application. Using our archetype
TemplateApp
as starting point we want to rename it for example to
BeamApp.
You will have to rename or edit the selected files in the screenshot.
- Make sure the project is in a compiling state without errors (see eclipse "Problems" view)
- Edit
pom.xml
and change the last part of bundle.mainClass
from TemplateApp to BeamApp
- Right click on
TemplateApp.java
then choose Refactor -> Rename...
enter BeamApp.java
and confirm the following information dialogs with next
or finish
- (Shortcut
Alt+Shift+R
if you feel comfortable using it)
- Open
TemplateApp.java
and change APP_TITLE
to "Beam App"
and APP_STYLESHEET to "BeamApp.css"
- Rename the following files in the same way using the
Refactor -> Rename...
function (you can use the shortcut Ctrl+Shift+R
to find the files)
-
TemplateAppResourceBundle_en.java
-> BeamAppResourceBundle _en.java
-
TemplateAppResourceBundle.java
-> BeamAppResourceBundle.java
-
TemplateAppController.java
-> BeamAppController.java
-
TemplateAppModel.java
-> BeamAppModel.java
-
TemplateApp.fxml
-> BeamApp.fxml
-
TemplateApp.css
-> BeamApp.css
- Done. If everything went well there should be no "Problems" and you can still run the app by clicking on the project name in the "Package Explorer", select
Run As -> Maven build...
then Goals: "clean compile exec:java" -> Run
Creating a git project and upload your code
Please make sure to read
AppHowToGitInEclipseForBeginners at least up to and including 2.1.
We will create a project in our personal git organisation which can later be move to one of the bigger organisations like fcc-applications or fcc-commons.
Create the gitea project
Visit
https://git.acc.gsi.de/ and Please follow the screenshots.
- Owner: You name
- Chose a repository name that resembles or even is the same as the maven artifact name
- Private repository is only if you want to hide the project, none of your collegues will be able to see the project
- Leave the gitignore, license and especially the "initialize repository" option empty. We already have code that we want to upload and don't want do get any conflict
- Hit "Create Repository"
3. Repository created, copy URL
- Repository created successfully - make sure to copy the marked http repository URL.
4. Initialize the local git repository
Now we have to do some command line work. Open a bash shell and navigate to the source files of your project. (To get the path, in Eclipse: select
Project -> Properties -> Location
might help you)
Enter the following commands from the main project directory (were
pom.xml
is)
cd DIRECTORY_OF_THE_PROJECT
git init
# download a default gitignore file that will prevent eclipse project files from being uploaded
wget https://git.acc.gsi.de/buildsystem-common/csco-java-fx-template/raw/branch/main/.gitignore
# Adjust the complete URL to the previously copied one
git remote add origin https://git.acc.gsi.de/REPLACE_COMPLETE_WITH_THE_URL_YOU_HAVE_COPIED_BEFORE
# Add and commit all these changes with the following commands
git add -A
git commit -m 'Initial commit'
# We will then push the changes using eclipse in the next step
5. Push the repository using eclipse
- Now we switch back to eclipse, select our project in the repository explorer and do a
"-> refresh"
or hit F5
while the project is selected
- Select
Team -> Push Branch "master"...
- (highlighted blue in the screenshot below)
- if you only have the options "Apply patch", "Share Project", and "Share Projects", choose "Share Project", select GIT and finish, repeate step 2
- There might be a prompt for your local
keystore
password, enter it or cancel the keystore
dialog
- Click on
Preview
and Push
in the following dialog pages
6. Success
You can see an entry in your eclipse "history" view now and if you refresh you gitea project page.
See also
--
AndreasSchaller - 23 Sep 2014