Skip to content

Commit

Permalink
spring forge updates (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
pcalouche authored Aug 1, 2024
1 parent 3c526a1 commit 5f3d38e
Show file tree
Hide file tree
Showing 17 changed files with 189 additions and 77 deletions.
6 changes: 6 additions & 0 deletions .githooks/post-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

# update git's index (bc they get messy with the pre-commit hook) according to
# https://prettier.io/docs/en/precommit.html
# see also https://github.com/prettier/prettier/issues/2978
git update-index -g
6 changes: 3 additions & 3 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ registries:
github:
type: "maven-repository"
url: "https://maven.pkg.github.com/pcalouche/*"
username: ${{ secrets.MAVEN_SERVER_USERNAME }}
password: ${{ secrets.MAVEN_SERVER_PASSWORD }}
username: ${{ github.actor }}
password: ${{ github.token }}
updates:
- package-ecosystem: "maven"
directory: "/" # Location of package manifests
directory: "/"
registries: "*"
schedule:
interval: "daily"
Expand Down
29 changes: 17 additions & 12 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,34 @@ name: Continuous Integration

on:
push:
env:
MAVEN_SERVER_USERNAME: ${{ secrets.MAVEN_SERVER_USERNAME }}
MAVEN_SERVER_PASSWORD: ${{ secrets.MAVEN_SERVER_PASSWORD }}
branches-ignore:
- main

permissions:
contents: read
packages: read

concurrency:
group: "${{ github.workflow }}-${{ github.ref != 'refs/heads/main' && github.ref || github.run_id }}"
cancel-in-progress: true

jobs:
maven-verify:
build-and-run-tests:
name: Build and Run Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
- name: Checkout Repo
uses: actions/checkout@v4
with:
show-progress: false
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'
cache: maven
server-id: github
server-username: MAVEN_SERVER_USERNAME
server-password: MAVEN_SERVER_PASSWORD
- name: Verify build
run: mvn -B verify
- name: Run Maven
run: mvn -B clean verify
env:
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_TOKEN: ${{ github.token }}
65 changes: 39 additions & 26 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,32 +1,45 @@
# Heavily influenced by https://www.toptal.com/developers/gitignore?templates=java,jetbrains,macos

### Additional inclusions and exclusions specific to this project ###

### Java ###
# Compiled class file
*.class

# Log file
*.log

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
replay_pid*

### Maven ###
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### IntelliJ IDEA ###
.idea
# flatten-maven-plugin
.flattened-pom.xml

### JetBrains ###
.idea/*
!.idea/codeStyles
!.idea/runConfigurations
*.iws
*.iml
*.ipr

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
out/

### VS Code ###
.vscode/
.vscode/

### macOS ###
.DS_Store
.AppleDouble
.LSOverride
22 changes: 22 additions & 0 deletions .idea/runConfigurations/All_in_spring_boot_excel.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions .mvn/settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<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>github</id>
<username>${env.GITHUB_ACTOR}</username>
<password>${env.GITHUB_TOKEN}</password>
</server>
</servers>
</settings>
21 changes: 21 additions & 0 deletions .run/SpringBootExcelApplication (Default).run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="SpringBootExcelApplication (Default)" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot">
<option name="FRAME_DEACTIVATION_UPDATE_POLICY" value="UpdateClassesAndResources" />
<module name="excel-spring-boot" />
<option name="SPRING_BOOT_MAIN_CLASS" value="dev.pcalouche.springboot.excel.SpringBootExcelApplication" />
<option name="UPDATE_ACTION_UPDATE_POLICY" value="UpdateClassesAndResources" />
<extension name="net.ashald.envfile">
<option name="IS_ENABLED" value="false" />
<option name="IS_SUBST" value="false" />
<option name="IS_PATH_MACRO_SUPPORTED" value="false" />
<option name="IS_IGNORE_MISSING_FILES" value="false" />
<option name="IS_ENABLE_EXPERIMENTAL_INTEGRATIONS" value="false" />
<ENTRIES>
<ENTRY IS_ENABLED="true" PARSER="runconfig" IS_EXECUTABLE="false" />
</ENTRIES>
</extension>
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
39 changes: 37 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,47 @@
# format the code
# Format the code
.PHONY: format
format:
mvn spotless:apply spring-javaformat:apply

# Run tests and verify
.PHONY: mvn-verify
mvn-verify: format
mvn clean verify

# Skip tests and verify
.PHONY: mvn-verify-skip-tests
mvn-verify-skip-tests: format
mvn clean verify -DskipTests

# Run tests and install locally
.PHONY: mvn-install
mvn-install: format
mvn clean install
mvn clean install

# Skip tests and install locally
.PHONY: mvn-install-skip-tests
mvn-install-skip-tests: format
mvn clean install -DskipTests

# Check if version is a SNAPSHOT
.PHONY: check-if-snapshot-version
check-if-snapshot-version:
version="$(shell mvn help:evaluate -Dexpression=spring-enzymes.version -q -DforceStdout)" ; \
echo "version is $$version" ; \
if [[ $$version == *-SNAPSHOT ]]; then \
echo "Release version is a SNAPSHOT, so manual deploy can proceed." ; \
else \
echo "Release version is NOT a SNAPSHOT. Use a SNAPSHOT version to deploy or deploy with GitHub Actions CD." ; \
exit 1 ; \
fi

# Run tests and deploy SNAPSHOT version
.PHONY: mvn-deploy-snapshot
mvn-deploy-snapshot: check-if-snapshot-version format
mvn clean deploy

# Skip tests and deploy SNAPSHOT version
.PHONY: mvn-deploy-snapshot-skip-tests
mvn-deploy-snapshot-skip-tests: check-if-snapshot-version format
mvn clean deploy -DskipTests

27 changes: 13 additions & 14 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
<?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">
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.pcalouche.poms</groupId>
<artifactId>calouche-company-pom</artifactId>
<groupId>dev.pcalouche.springforge.spring33x</groupId>
<artifactId>spring-forge-starter-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath/>
</parent>

<groupId>com.pcalouche</groupId>
<artifactId>excel-spring-boot</artifactId>
<version>0.0.1-SNAPSHOT</version>
<groupId>dev.pcalouche.springboot</groupId>
<artifactId>spring-boot-excel</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>Excel Export Spring Boot Example</name>

<dependencies>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<groupId>dev.pcalouche.springforge.spring33x</groupId>
<artifactId>pcalouche-spring-boot-starter-app</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand All @@ -36,8 +35,8 @@
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<groupId>dev.pcalouche.springforge.spring33x</groupId>
<artifactId>pcalouche-spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Expand All @@ -61,4 +60,4 @@
</plugins>
</build>

</project>
</project>
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.pcalouche.excelspringboot;
package dev.pcalouche.springboot.excel;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class ExcelSpringBootApplication {
public class SpringBootExcelApplication {

public static void main(String[] args) {
SpringApplication.run(ExcelSpringBootApplication.class, args);
SpringApplication.run(SpringBootExcelApplication.class, args);
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.pcalouche.excelspringboot.controller;
package dev.pcalouche.springboot.excel.controller;

import com.pcalouche.excelspringboot.excel.NonStreamingExcelExport;
import com.pcalouche.excelspringboot.excel.StreamExcelExport;
import dev.pcalouche.springboot.excel.excel.NonStreamingExcelExport;
import dev.pcalouche.springboot.excel.excel.StreamExcelExport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.ResponseEntity;
Expand All @@ -18,30 +18,30 @@ public class ExcelController {

@GetMapping("non-streaming-excel")
public ResponseEntity<byte[]> nonStreamingExcel(@RequestParam int columns, @RequestParam int rows) {
logger.info("columns->" + columns + " rows->" + rows);
logger.info("columns->{} rows->{}", columns, rows);

Long startTime = System.currentTimeMillis();
logger.info("start of Non Streaming Excel request");

NonStreamingExcelExport nonStreamingExcelExport = new NonStreamingExcelExport(columns, rows);

Long endTime = System.currentTimeMillis();
logger.info("end of Non Streaming Excel request->" + (endTime - startTime) / 1000 + " seconds.");
logger.info("end of Non Streaming Excel request->{} seconds.", (endTime - startTime) / 1000);

return nonStreamingExcelExport.getResponseEntity();
}

@GetMapping("streaming-excel")
public ResponseEntity<byte[]> streamingExcel(@RequestParam int columns, @RequestParam int rows) {
logger.info("columns->" + columns + " rows->" + rows);
logger.info("columns->{} rows->{}", columns, rows);

Long startTime = System.currentTimeMillis();
logger.info("start of Streaming Excel request");

StreamExcelExport streamExcelExport = new StreamExcelExport(columns, rows);

Long endTime = System.currentTimeMillis();
logger.info("end of Streaming Excel request->" + (endTime - startTime) / 1000 + " seconds.");
logger.info("end of Streaming Excel request->{} seconds.", (endTime - startTime) / 1000);
return streamExcelExport.getResponseEntity();
}

Expand Down
Loading

0 comments on commit 5f3d38e

Please sign in to comment.