Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LRDOCS-6934 Project Templates 7.2 #4242

Merged
merged 5 commits into from
Jun 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
38 changes: 38 additions & 0 deletions developer/reference/articles/project-templates/00-intro.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
header-id: project-templates
---

# Project Templates

[TOC levels=1-4]

Liferay provides project templates that you can use to generate starter projects
formatted in an opinionated way. These templates can be used by most build tools
(e.g., Gradle, Maven, Dev Studio) to generate your desired project structure.

If you're using [Blade CLI](/docs/7-2/reference/-/knowledge_base/r/blade-cli),
execute the following command to display a full list of project templates:

```bash
blade create -l
```

If you're using [Maven](/docs/7-2/reference/-/knowledge_base/r/maven), you can
view and use the project templates as Maven archetypes. Execute the following
command to list them:

```bash
mvn archetype:generate -Dfilter=liferay
```

Archetypes with the `com.liferay.project.templates` prefix are the latest
templates offered by Liferay.

If you're using
[Dev Studio](/docs/7-2/reference/-/knowledge_base/r/liferay-dev-studio),
navigate to *File* → *New* → *Liferay Module Project* and view the
project templates from the *Project Template Name* drop-down menu.

In this section of reference articles, each project template is outlined with
the appropriate generation command and folder structure. Visit the project
template article you're most interested in to start building your own project!
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
header-id: activator-template
---

# Activator Template

[TOC levels=1-4]

In this article, you'll learn how to create a Liferay activator as a Liferay
module. To create a Liferay activator via the command line using Blade CLI or
Maven, use one of the commands with the following parameters:

```bash
blade create -t activator [-p packageName] [-c className] projectName
```

or

```bash
mvn archetype:generate \
-DarchetypeGroupId=com.liferay \
-DarchetypeArtifactId=com.liferay.project.templates.activator \
-DartifactId=[projectName] \
-Dpackage=[packageName] \
-DclassName=[className] \
-DliferayVersion=7.2
```

You can also insert the `-b maven` parameter in the Blade command to generate
a Maven project using Blade CLI.

The template for this kind of project is `activator`. Suppose you want to create
an activator project called `my-activator-project` with a package name of
`com.liferay.docs.activator` and a class name of `Activator`. You could run the
following command to accomplish this:

```bash
blade create -t activator -p com.liferay.docs.activator -c Activator my-activator-project
```

or

```bash
mvn archetype:generate \
-DarchetypeGroupId=com.liferay \
-DarchetypeArtifactId=com.liferay.project.templates.activator \
-DgroupId=com.liferay \
-DartifactId=my-activator-project \
-Dpackage=com.liferay.docs.activator \
-Dversion=1.0 \
-DclassName=Activator \
-Dauthor=Joe Bloggs \
-DliferayVersion=7.2
```

Note that in your class, you're implementing the
`org.osgi.framework.BundleActivator` interface.

After running the Blade command above, your project's directory structure looks
like this:

- `my-activator-project`
- `gradle`
- `wrapper`
- `gradle-wrapper.jar`
- `gradle-wrapper.properties`
- `src`
- `main`
- `java`
- `com/liferay/docs/activator`
- `Activator.java`
- `resources`
- `bnd.bnd`
- `build.gradle`
- `gradlew`

The Maven-generated project includes a `pom.xml` file and does not include the
Gradle-specific files, but otherwise, appears exactly the same.

The generated module is functional and is deployable to a @product@ instance. To
build upon the generated app, modify the project by adding logic and additional
files to the folders outlined above.
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
header-id: api-template
---

# API Template

[TOC levels=1-4]

In this tutorial, you'll learn how to create a Liferay API as a Liferay module.
To create a Liferay API via the command line using Blade CLI or Maven, use one
of the commands with the following parameters:

```bash
blade create -t api [-p packageName] [-c className] projectName
```

or

```bash
mvn archetype:generate \
-DarchetypeGroupId=com.liferay \
-DarchetypeArtifactId=com.liferay.project.templates.api \
-DartifactId=[projectName] \
-Dpackage=[packageName] \
-DclassName=[className] \
-DliferayVersion=7.2
```

You can also insert the `-b maven` parameter in the Blade command to generate a
Maven project using Blade CLI.

The template for this kind of project is `api`. The `api` template creates a
simple `api` module with an empty public interface. For example, suppose you
want to create an API project called `my-api-project` with a package name of
`com.liferay.docs.api` and a class name of `MyApi`. You could run the following
command to accomplish this:

```bash
blade create -t api -p com.liferay.docs -c MyApi my-api-project
```

or

```bash
mvn archetype:generate \
-DarchetypeGroupId=com.liferay \
-DarchetypeArtifactId=com.liferay.project.templates.api \
-DgroupId=com.liferay \
-DartifactId=my-api-project \
-Dpackage=com.liferay.docs \
-Dversion=1.0 \
-DclassName=MyApi \
-Dauthor=Joe Bloggs \
-DliferayVersion=7.2
```

After running the Blade command above, your project's directory structure looks
like this:

- `my-api-project`
- `gradle`
- `wrapper`
- `gradle-wrapper.jar`
- `gradle-wrapper.properties`
- `src`
- `main`
- `java`
- `com/liferay/docs/api`
- `MyApi.java`
- `resources`
- `com/liferay/docs/api`
- `packageinfo`
- `bnd.bnd`
- `build.gradle`
- `gradlew`

The Maven-generated project includes a `pom.xml` file and does not include the
Gradle-specific files, but otherwise, appears exactly the same.

The generated module is a working application and is deployable to a @product@
instance. To build upon the generated app, modify the project by adding logic
and additional files to the folders outlined above.
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
---
header-id: control-menu-entry-template
---

# Control Menu Entry Template

[TOC levels=1-4]

In this article, you'll learn how to create a Liferay Control Menu entry as a
Liferay module. To create a Liferay Control Menu entry via the command line
using Blade CLI or Maven, use one of the commands with the following parameters:

```bash
blade create -t control-menu-entry [-p packageName] [-c className] projectName
```

or

```bash
mvn archetype:generate \
-DarchetypeGroupId=com.liferay \
-DarchetypeArtifactId=com.liferay.project.templates.control.menu.entry \
-DartifactId=[projectName] \
-Dpackage=[packageName] \
-DclassName=[className] \
-DliferayVersion=7.2
```

You can also insert the `-b maven` parameter in the Blade command to generate a
Maven project using Blade CLI.

The template for this kind of project is `control-menu-entry`. Suppose you want to
create a control menu entry project called `my-control-menu-entry-project` with
a package name of `com.liferay.docs.entry.control.menu` and a class name of
`SampleProductNavigationControlMenuEntry`. You could run the following command
to accomplish this:

```bash
blade create -t control-menu-entry -p com.liferay.docs.entry -c Sample my-control-menu-entry-project
```

or

```bash
mvn archetype:generate \
-DarchetypeGroupId=com.liferay \
-DarchetypeArtifactId=com.liferay.project.templates.control.menu.entry \
-DgroupId=com.liferay \
-DartifactId=my-control-menu-entry-project \
-Dpackage=com.liferay.docs.entry \
-Dversion=1.0 \
-DclassName=Sample \
-Dauthor=Joe Bloggs \
-DliferayVersion=7.2
```

After running the Blade command above, your project's directory structure would
look like this:

- `my-control-menu-entry-project`
- `gradle`
- `wrapper`
- `gradle-wrapper.jar`
- `gradle-wrapper.properties`
- `src`
- `main`
- `java`
- `com/liferay/docs/entry/control/menu`
- `SampleProductNavigationControlMenuEntry.java`
- `resources`
- `content`
- `Language.properties`
- `bnd.bnd`
- `build.gradle`
- `gradlew`

The Maven-generated project includes a `pom.xml` file and does not include the
Gradle-specific files, but otherwise, appears exactly the same.

The generated module is functional and is deployable to a @product@ instance. To
build upon the generated app, modify the project by adding logic and additional
files to the folders outlined above. You can visit the
[control-menu-entry](/docs/7-1/reference/-/knowledge_base/r/control-menu-entry)
sample project for a more expanded sample of a Control Menu entry. Likewise, see
the
[Customizing the Control Menu](/docs/7-2/customization/-/knowledge_base/c/customizing-the-control-menu)
tutorial for instructions on customizing a Control Menu entry project.
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
---
header-id: form-field-template
---

# Form Field Template

[TOC levels=1-4]

In this article, you'll learn how to create a Liferay form field as a Liferay
module. To create a Liferay form field via the command line using Blade CLI or
Maven, use one of the commands with the following parameters:

```bash
blade create -t form-field [-p packageName] [-c className] projectName
```

or

```bash
mvn archetype:generate \
-DarchetypeGroupId=com.liferay \
-DarchetypeArtifactId=com.liferay.project.templates.form.field \
-DartifactId=[projectName] \
-Dpackage=[packageName] \
-DclassName=[className] \
-DliferayVersion=7.2
```

You can also insert the `-b maven` parameter in the Blade command to generate a
Maven project using Blade CLI.

The template for this kind of project is `form-field`. Suppose you want to
create a form field project called `my-form-field-project` with a package name
of `com.liferay.docs.form.field` and a class name prefix of `MyFormField`. You
could run one of the following commands to accomplish this:

```bash
blade create -t form-field -p com.liferay.docs -c MyFormField my-form-field-project
```

or

```bash
mvn archetype:generate \
-DarchetypeGroupId=com.liferay \
-DarchetypeArtifactId=com.liferay.project.templates.form.field \
-DgroupId=com.liferay \
-DartifactId=my-form-field-project \
-Dpackage=com.liferay.docs \
-Dversion=1.0 \
-DclassName=MyFormField \
-Dauthor=Joe Bloggs \
-DliferayVersion=7.2
```

After running the Blade command above, your project's directory structure looks
like this:

- `my-form-field-project`
- `gradle`
- `wrapper`
- `gradle-wrapper.jar`
- `gradle-wrapper.properties`
- `src`
- `main`
- `java`
- `com/liferay/docs/form/field`
- `MyFormFieldDDMFormFieldRenderer.java`
- `MyFormFieldDDMFormFieldType.java`
- `resources`
- `content`
- `Language.properties`
- `META-INF`
- `resources`
- `config.js`
- `my-form-field-project.soy`
- `my-form-field-project_field.js`
- `my-form-field-project_field.es.js`
- `bnd.bnd`
- `build.gradle`
- `gradlew`

The Maven-generated project includes a `pom.xml` file and does not include the
Gradle-specific files, but otherwise, appears exactly the same.

The generated module is a working form field and is deployable to a @product@
instance. To build upon the generated app, modify the project by adding logic
and additional files to the folders outlined above.