Skip to content

Commit

Permalink
Transform the entity to be a bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
tbouron committed Feb 21, 2019
1 parent 3ff5e73 commit 856294a
Show file tree
Hide file tree
Showing 10 changed files with 322 additions and 21 deletions.
66 changes: 66 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Base build parameters
base_build: &base_build
working_directory: ~/repo
docker:
- image: circleci/openjdk:8-jdk
environment:
MAVEN_OPTS: -Xmx3200m

# Base steps for maven project
base_restore_cache: &base_restore_cache
restore_cache:
keys:
- v1-dependencies-{{ checksum "pom.xml" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

base_save_cache: &base_save_cache
save_cache:
paths:
- ~/.m2
key: v1-dependencies-{{ checksum "pom.xml" }}

# Jobs definitions
version: 2
jobs:
build:
<<: *base_build

steps:
- checkout
- *base_restore_cache
- run: mvn dependency:go-offline
- *base_save_cache
# run tests!
- run: mvn clean install

deploy:
<<: *base_build

steps:
- checkout
- *base_restore_cache
- run: mvn dependency:go-offline
- *base_save_cache
# Import key in GPG
- run: echo $GPG_SECRET_KEY | base64 --decode | $GPG_EXECUTABLE --batch --import
# Deploy to sonatype
- run: mvn clean deploy -DskipTests -DdeployTo=sonatype --settings .circleci/settings.xml

# Workflow definitions
workflows:
version: 2
deploy_sonatype:
jobs:
- build
# If we are on master or a release branch, we deploy directly to sonatype. Release version will still need manual
# approval via sonatype UI: https://oss.sonatype.org/#stagingRepositories
- deploy:
context: org-global
requires:
- build
filters:
branches:
only:
- master
- /^release\/.*$/
49 changes: 49 additions & 0 deletions .circleci/settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>sonatype-nexus-snapshots</id>
<username>${env.SONATYPE_USER}</username>
<password>${env.SONATYPE_PASSWORD}</password>
</server>
<server>
<id>sonatype-nexus-staging</id>
<username>${env.SONATYPE_USER}</username>
<password>${env.SONATYPE_PASSWORD}</password>
</server>
</servers>

<profiles>
<profile>
<id>sonatype-nexus-repo</id>
<properties>
<gpg.executable>${env.GPG_EXECUTABLE}</gpg.executable>
<gpg.secret.key>${env.GPG_SECRET_KEY}</gpg.secret.key>
<gpg.passphrase>${env.GPG_PASSPHRASE}</gpg.passphrase>
</properties>
<repositories>
<repository>
<id>sonatype-nexus-staging</id>
<name>Nexus Release Repository</name>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
<releases>
<enabled>true</enabled>
</releases>
</repository>
<repository>
<id>sonatype-nexus-snapshots</id>
<name>Sonatype Nexus Snapshots</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>

<activeProfiles>
<activeProfile>sonatype-nexus-repo</activeProfile>
</activeProfiles>
</settings>
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
target
.idea
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Three Tier Webapp
# Brooklyn Three Tier Webapp Entity

This is the core [Apache Brooklyn](http://brooklyn.apache.org/) integration for deployment and in-life management of a three tier webapp.

See the [Apache Brooklyn documentation](http://brooklyn.apache.org/v/latest/start/policies.html) for further details of this blueprint.
See the [Apache Brooklyn documentation](http://brooklyn.apache.org/v/latest/start/policies.html) for further details of this blueprint.
36 changes: 36 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Perform releases

## SNAPSHOT releases

`master` branch should only contains `SNAPSHOT` version. Upon every commit pushed on `master`, Circle CI will build, sign
then deploy `SNAPSHOT` version to sonatype automatically.

## Official releases

To perform an official release, simply create a branch `release/<version>`, update the version number in the code then push
your changes. Circle CI will build, sign then deploy artifacts to sonatype automatically.

You will then need to go to the [sonatype UI](https://oss.sonatype.org/#stagingRepositories) to manually
[close and release artifacts](http://central.sonatype.org/pages/releasing-the-deployment.html).

## Manual releases

You can always perform manual releases by running the following command:

```bash
mvn clean deploy -DskipTests -DdeployTo=sonatype --settings .circleci/settings.xml
```

*If your project contains java classes, **don't forget to add** `source:jar javadoc:jar` to the deploy command above!*

Note that you need to setup the following environment variables:


| Environment variable | Value |
| -------------------- | ------------------------------------------------------------------------------------------------- |
| SONATYPE_USER | Sonatype user |
| SONATYPE_PASSWORD | Sonatype password |
| GPG_EXECUTABLE | GPG executable, e.g. `gpg` |
| GPG_SECRET_KEY | GPG secret key to use. You can get it be running: `gpg -a --export-secret-keys <KEY-ID> | base64` |
| GPG_PASSPHRASE | The passphrase of the <KEY-ID> |

3 changes: 3 additions & 0 deletions catalog/catalog.bom
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
brooklyn.catalog:
items:
- classpath://three-tier-webapp/three-tier-webapp.bom
22 changes: 7 additions & 15 deletions catalog.bom → ...g/three-tier-webapp/three-tier-webapp.bom
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,21 @@
# under the License.
#
brooklyn.catalog:
bundle: brooklyn-three-tier-webapp
version: 0.0.1-SNAPSHOT
id: ThreeTierApp
description: This is the core Apache Brooklyn integration for deployment and in-life management of a three tier webapp. See the Apache Brooklyn documentation for further details of this blueprint
name: Three Tier Web App
version: 1.0.0-SNAPSHOT # BROOKLYN_THREE_TIER_WEBAPP_VERSION
publish:
name: &threeTierWebappName Three Tier Web App
description: &threeTierWebappDescription This is the core Apache Brooklyn integration for deployment and in-life management of a three tier webapp. See the Apache Brooklyn documentation for further details of this blueprint
license_code: Apache-2.0
qa: catalog.tests.bom

items:
- id: ThreeTierApp
name: Three Tier Web App
itemType: template
item:
services:
- type: ThreeTierApp-application
name: Three Tier Web App

- id: ThreeTierApp-application
- id: brooklyn-three-tier-webapp
name: *threeTierWebappName
description: *threeTierWebappDescription
itemType: entity
item:
type: org.apache.brooklyn.entity.stock.BasicApplication
id: app
name: *threeTierWebappName
brooklyn.parameters:
- name: ssl
label: Cluster SSL
Expand Down
12 changes: 12 additions & 0 deletions feature/feature.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<features xmlns="http://karaf.apache.org/xmlns/features/v1.3.0" name="${project.artifactId}-${project.version}">
<feature name="${project.artifactId}" version="${project.version}">
<bundle>mvn:${project.groupId}/${project.artifactId}/${project.version}</bundle>
</feature>

<feature name="${project.artifactId}-bom" version="${project.version}">
<configfile finalname="${karaf.home}/catalog/${project.artifactId}-${project.version}.bom" override="true">
mvn:${project.groupId}/${project.artifactId}/${project.version}/bom/three-tier-webapp
</configfile>
</feature>
</features>
141 changes: 141 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
<?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>io.brooklyn.three-tier-webapp</groupId>
<artifactId>brooklyn-three-tier-webapp</artifactId>
<version>1.0.0-SNAPSHOT</version><!--BROOKLYN_THREE_TIER_WEBAPP_VERSION-->
<packaging>bundle</packaging>

<parent>
<groupId>io.brooklyn</groupId>
<artifactId>brooklyncentral-parent</artifactId>
<version>1.0.2</version>
</parent>

<name>Brooklyn :: Three Tier Webapp</name>
<description>This is the core Apache Brooklyn integration for deployment and in-life management of a three tier webapp. See the Apache Brooklyn documentation for further details of this blueprint</description>
<url>https://github.com/brooklyncentral/brooklyn-three-tier-webapp</url>

<properties>
<build-helper-maven-plugin.version>3.0.0</build-helper-maven-plugin.version>
<buildnumber-maven-plugin.version>1.4</buildnumber-maven-plugin.version>
<maven-bundle-plugin.version>3.3.0</maven-bundle-plugin.version>
</properties>

<scm>
<url>https://github.com/brooklyncentral/brooklyn-three-tier-webapp</url>
<connection>scm:git:https://github.com/brooklyncentral/brooklyn-three-tier-webapp.git</connection>
<developerConnection>scm:git:[email protected]:brooklyncentral/brooklyn-three-tier-webapp.git</developerConnection>
<tag>HEAD</tag>
</scm>

<licenses>
<license>
<name>Apache 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>

<!-- For the full list of developers, see contributors to https://github.com/brooklyncentral/brooklyn-elk -->
<developers>
<developer>
<name>Cloudsoft</name>
<organizationUrl>https://github.com/cloudsoft</organizationUrl>
</developer>
</developers>

<build>
<resources>
<resource>
<directory>catalog</directory>
<filtering>false</filtering>
</resource>
<resource>
<directory>feature</directory>
<filtering>true</filtering>
</resource>
<resource>
<directory>resources</directory>
<filtering>false</filtering>
</resource>
</resources>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>${build-helper-maven-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>${maven-bundle-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.karaf.tooling</groupId>
<artifactId>karaf-maven-plugin</artifactId>
<version>${karaf-maven-plugin.version}</version>
<extensions>true</extensions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<executions>
<execution>
<id>bundle-manifest</id>
<phase>process-classes</phase>
<goals>
<goal>manifest</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>attach-artifact</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>${project.build.outputDirectory}/three-tier-webapp/three-tier-webapp.bom</file>
<classifier>three-tier-webapp</classifier>
<type>bom</type>
</artifact>
<artifact>
<file>${project.build.outputDirectory}/feature.xml</file>
<classifier>features</classifier>
<type>xml</type>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
# under the License.
#
brooklyn.catalog:
version: 0.0.1-SNAPSHOT
version: 1.0.0-SNAPSHOT # BROOKLYN_THREE_TIER_WEBAPP_VERSION
items:
- "https://github.com/brooklyncentral/common-catalog-utils/releases/download/v0.1.0/common.tests.bom"
- id: ThreeTierAppTest
- "https://raw.githubusercontent.com/brooklyncentral/common-catalog-utils/master/common-tests/src/main/resources/commontests/common.tests.bom"
- id: brooklyn-three-tier-webapp-tests
itemType: template
name: Three tier webapp Test
item:
services:
- type: ThreeTierApp:0.0.1-SNAPSHOT
- type: brooklyn-three-tier-webapp
id: target-app
brooklyn.config:
ssl:
Expand Down

0 comments on commit 856294a

Please sign in to comment.