Skip to content

Commit

Permalink
Updating project structure, introducing code quality checks, and gith…
Browse files Browse the repository at this point in the history
…ub actions to keep building.
  • Loading branch information
JonathanGiles committed Jul 1, 2024
1 parent 9c15904 commit 733a764
Show file tree
Hide file tree
Showing 82 changed files with 213 additions and 102 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Build

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up JDK 21
uses: actions/setup-java@v2
with:
java-version: '21'
distribution: 'adopt'

- name: Cache Maven packages
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Build with Maven
run: mvn -B package --file pom.xml

- name: Run Checkstyle
run: mvn checkstyle:check

- name: Run PMD
run: mvn pmd:pmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@
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>com.microsoft.aspire</groupId>
<parent>
<groupId>com.microsoft.aspire</groupId>
<artifactId>aspire4j-sdk-parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>

<artifactId>aspire4j-extensions-azure-storage</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>com.microsoft.aspire</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@
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>com.microsoft.aspire</groupId>
<parent>
<groupId>com.microsoft.aspire</groupId>
<artifactId>aspire4j-sdk-parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>

<artifactId>aspire4j-extensions-azure</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>

<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>com.microsoft.aspire</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@
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>com.microsoft.aspire</groupId>
<parent>
<groupId>com.microsoft.aspire</groupId>
<artifactId>aspire4j-sdk-parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>

<artifactId>aspire4j-extensions-spring</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>com.microsoft.aspire</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
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>com.microsoft.aspire</groupId>
<parent>
<groupId>com.microsoft.aspire</groupId>
<artifactId>aspire4j-sdk-parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>

<artifactId>aspire4j-maven-tools</artifactId>
<version>1.0-SNAPSHOT</version>

<name>Tools for creating Aspire projects</name>

<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven-plugin-tools.version>3.13.1</maven-plugin-tools.version>
</properties>

Expand Down
File renamed without changes.
62 changes: 15 additions & 47 deletions aspire4j/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,61 +4,29 @@
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>com.microsoft.aspire</groupId>
<artifactId>aspire4j</artifactId>
<parent>
<groupId>com.microsoft.aspire</groupId>
<artifactId>aspire4j-parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>

<artifactId>aspire4j-sdk-parent</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>

<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<!-- JSON support -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.17.1</version>
</dependency>
<modules>
<module>aspire4j</module>
<module>aspire4j-maven-tools</module>

<!-- Model validation -->
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<version>8.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.glassfish.expressly</groupId>
<artifactId>expressly</artifactId>
<version>5.0.0</version>
</dependency>
</dependencies>
<module>aspire4j-extensions-azure</module>
<module>aspire4j-extensions-azure-storage</module>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.1</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.microsoft.aspire.ManifestGenerator</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<mainClass>com.microsoft.aspire.ManifestGenerator</mainClass>
</configuration>
</plugin>
</plugins>
</build>
<module>aspire4j-extensions-spring</module>
</modules>
</project>
13 changes: 13 additions & 0 deletions contributing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Contributing

Firstly - thanks for thinking about contributing!

## Code Quality

The build has three tools that are used to ensure code quality:

1. [Checkstyle](https://checkstyle.org/) - this is used to ensure that the code adheres to a consistent style.
2. [PMD](https://pmd.github.io/) - this is used to find common programming flaws.
3. [SpotBugs](https://spotbugs.github.io/) - this is used to find common bugs in Java code.

Before submitting a pull request, please ensure that the code passes all of these checks. You can run them locally by executing `mvn clean verify`.
58 changes: 52 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,57 @@

<modules>
<module>aspire4j</module>
<module>aspire4j-extensions-azure-storage</module>
<module>aspire4j-extensions-azure</module>
<module>aspire4j-extensions-spring</module>
<module>storage-explorer-apphost</module>
<module>storage-explorer</module>
<module>date-service</module>
<module>samples</module>
</modules>

<build>
<plugins>
<!-- Checkstyle plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.4.0</version>
<configuration>
<configLocation>sun_checks.xml</configLocation>
<consoleOutput>false</consoleOutput>
<failsOnError>false</failsOnError>
<linkXRef>false</linkXRef>
</configuration>
</plugin>

<!-- PMD plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.23.0</version>
<configuration>
<rulesets>
<ruleset>/rulesets/java/maven-pmd-plugin-default.xml</ruleset>
<ruleset>/category/java/bestpractices.xml</ruleset>
</rulesets>
</configuration>
</plugin>

<!-- SpotBugs plugin -->
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>4.8.6.1</version>
<configuration>
<effort>Max</effort>
<threshold>Low</threshold>
</configuration>
</plugin>
</plugins>
</build>

<reporting>
<plugins>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>4.8.6.1</version>
</plugin>
</plugins>
</reporting>
</project>
16 changes: 8 additions & 8 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

This is a proof of concept project, which introduces a minimal example of a Java implementation of the Aspire framework. It aims to provide a Java-idiomatic developer experience that mimics the concepts introduced by the Aspire framework for .net. In particular, it introduces the concept of the AppHost, allowing for Java developers to define infrastructure as code, whilst continuing to rely on the existing Java ecosystem frameworks such as Spring, Micronaut, and Quarkus.

This GitHub repository is split into six sub-projects:
This GitHub repository is split into many sub-projects, but they can be broadly categorised as follows:

* `aspire4j`: The core library that provides the AppHost and the ability to define infrastructure as code.
* `aspire4j-extensions-azure-storage`: An extension to the core library that provides the ability to configure Azure Storage resources.
* `aspire4j-extensions-azure`: A wrapper project that developers could use to bring in all Azure extensions at once.
* `storage-explorer`: A sample Spring application that is designed to work with Azure Services. It does not have any specific knowledge of the Aspire4J framework or how to deploy to Azure.
* `date-service`: A simple Spring application that provides a date microservice. It is used by the `storage-explorer`.
* `storage-explorer-apphost`: The infrastructure as code project that defines how the `storage-explorer` application, using the Aspire4J framework, should be deployed to Azure.
* **Aspire4J**:
* `aspire4j`: The core library that provides the AppHost and the ability to define infrastructure as code.
* `aspire4j-extensions-*`: Extensions for the Aspire4J library, providing support for Azure, Spring, etc.
* `aspire4j-maven-archetype`: A Maven archetype that can be used to create new Aspire4J App Hosts.
* **Sample Applications**:
* **Storage Explorer**: Refer to the [readme](tree/main/samples/storage-explorer/readme.md) for more information.

In this way, the file of most interest is the [StorageExplorerAppHost file](https://github.com/JonathanGiles/aspire4j/blob/main/storage-explorer-apphost/src/main/java/com/microsoft/aspire/springsample/StorageExplorerAppHost.java), which defines the infrastructure as code.
In this way, the file of most interest is the `StorageExplorerAppHost` file, which defines the infrastructure as code.

## Getting Started

Expand Down
20 changes: 20 additions & 0 deletions samples/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?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>

<parent>
<groupId>com.microsoft.aspire</groupId>
<artifactId>aspire4j-parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>

<artifactId>aspire4j-samples-parent</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>

<modules>
<module>storage-explorer</module>
</modules>
</project>
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.microsoft.aspire.storage.explorer;
package com.microsoft.aspire.storageexplorer;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.microsoft.aspire.storage.explorer;
package com.microsoft.aspire.storageexplorer;

import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
Expand Down
22 changes: 22 additions & 0 deletions samples/storage-explorer/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?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>

<parent>
<groupId>com.microsoft.aspire</groupId>
<artifactId>aspire4j-samples-parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>

<artifactId>aspire4j-sample-storage-explorer</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>

<modules>
<module>date-service</module>
<module>storage-explorer</module>
<module>storage-explorer-apphost</module>
</modules>
</project>
7 changes: 7 additions & 0 deletions samples/storage-explorer/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Aspire4J Storage Explorer Sample

This sample is split into the following three modules:

* `storage-explorer`: A sample Spring application that is designed to work with Azure Services. It does not have any specific knowledge of the Aspire4J framework or how to deploy to Azure.
* `date-service`: A simple Spring application that provides a date microservice. It is used by the `storage-explorer`.
* `storage-explorer-apphost`: The infrastructure as code project that defines how the `storage-explorer` application, using the Aspire4J framework, should be deployed to Azure.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<mainClass>com.microsoft.aspire.springsample.StorageExplorerAppHost</mainClass>
<mainClass>com.microsoft.aspire.storageexplorer.StorageExplorerAppHost</mainClass>

<!-- This is the property that azd init looks for -->
<aspire.isAppHost>true</aspire.isAppHost>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.microsoft.aspire.springsample;
package com.microsoft.aspire.storageexplorer;

import com.microsoft.aspire.AppHost;
import com.microsoft.aspire.DistributedApplication;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 733a764

Please sign in to comment.