-
Notifications
You must be signed in to change notification settings - Fork 7
Quick Start
Olga Shiryaeva edited this page May 28, 2018
·
18 revisions
This section describes the process of creating an application using CUBA CLI.
Make sure that the necessary software is already installed and set up on your computer, see Installation and Setup.
CUBA CLI is a tool for CUBA Platform projects scaffolding. CLI can work in two modes: shell mode and single command mode.
- Create a directory for the future project, for example
sales, and navigate to it in a terminal. - Start CUBA CLI.
- Input command
create-app. You can use tab auto-completion.
- CLI will ask you questions about the project. If a question implies default answer, you can press enter to accept it. You will be asked the following questions:
- Project name – the project name.
- Project namespace – the namespace which will be used as a prefix for entity names and database tables. The namespace can consist of Latin letters only and should be as short as possible.
-
Platform version – the platform version used in the project. The platform artifacts will be automatically downloaded from the repository on project build. Choose
6.8.5. - Root package – the root package of Java classes.
-
Database – the SQL database to use. Choose
HSQLDB.
- The empty project will be created in the current directory.
- Close CLI or open new terminal window. Run
./gradlew assemble
- Run
./gradlew startDbto start the local HyperSQL server.
- Run
./gradlew createDbto create a database.
- Run
./gradlew setupTomcat deploy start.
- In your browser go to http://localhost:8080/app
The username and password are admin / admin.
- Open IntelliJ IDEA
- File -> Open, navigate to project directory, choose
build.gradle, pressOK. - In gradle settings choose
Use gradle 'wrapper' task configuration. - Press
OK.
- In terminal navigate to project directory.
- Start CUBA CLI.
- Enter
entity. You will be asked the following questions:
-
Entity name – entity class name. Enter
Customer. - Package name – entity class package name. Accept default.
-
Entity type – entity may be Persistent, Persistent embedded or Not Persistent. Choose Persistent to make the entity able to be saved in the database.
- Let's add some fields. Open the created class in your IDE. Add the following field and methods:
@Column(name = "NAME")
protected String name;
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}- Now let's add SQL scripts to create the entity table.
Create a file
modules/core/db/init/hsql/10.create-db.sqlwith the content
-- begin SALES_CUSTOMER
create table SALES_CUSTOMER (
ID varchar(36) not null,
VERSION integer not null,
CREATE_TS timestamp,
CREATED_BY varchar(50),
UPDATE_TS timestamp,
UPDATED_BY varchar(50),
DELETE_TS timestamp,
DELETED_BY varchar(50),
--
NAME varchar(255),
--
primary key (ID)
)^
-- end SALES_CUSTOMERAlso, create a file with name modules/core/db/update/hsql/{yy}/{yymmdd}-createCustomer.sql with the same content.
You can read more about create and update scripts on official documentation.
- Run
./gradlew updateDbto create the table for theCustomerentity.