Skip to content

Commit

Permalink
add maven build
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeloffner committed Jun 24, 2024
1 parent 293af71 commit 11e33a6
Show file tree
Hide file tree
Showing 7 changed files with 455 additions and 118 deletions.
192 changes: 143 additions & 49 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,56 +1,150 @@
# This workflow will build a Java project with Ant
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-ant
name: Java CI Combined

name: Java CI - Lucee latest

on: [push, pull_request,workflow_dispatch]
on: [push, pull_request, workflow_dispatch]

jobs:
build:
setup:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.extract-version.outputs.VERSION }}
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up JDK 11
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
- name: Cache Maven packages
uses: actions/cache@v3
with:
path: ~/.m2
key: lucee-script-runner-maven-cache
- name: Cache Maven packages
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Extract version number
id: extract-version
run: |
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "::set-output name=VERSION::$VERSION"
- name: Cache Lucee files
uses: actions/cache@v4
with:
path: ~/work/_actions/lucee/script-runner/main/lucee-download-cache
key: lucee-downloads

- name: Import GPG key
run: |
echo "$GPG_PRIVATE_KEY" | base64 --decode | gpg --batch --import
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}

build-and-test:
runs-on: ubuntu-latest
needs: setup
env:
luceeVersion: light-6.0.0.451-BETA
luceeVersionQuery: 0/all/light
testLabels: image
testAdditional: ${{ github.workspace }}/tests
MYSQL_SERVER: localhost
MYSQL_USERNAME: lucee
MYSQL_PASSWORD: lucee
MYSQL_PORT: 3306
MYSQL_DATABASE: lucee
strategy:
matrix:
lucee:
- { version: 'light-5.4.6.9', query: '5/all/light' }
- { version: 'light-6.0.3.1', query: '6.0/all/light' }
- { version: 'light-6.1.0.206-SNAPSHOT', query: '6.1/all/light' }
services:
minio:
image: fclairamb/minio-github-actions
ports:
- 9000:9000
steps:
- uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'adopt'
- name: Cache Maven packages
uses: actions/cache@v4
with:
path: ~/.m2
key: lucee-script-runner-maven-cache
enableCrossOsArchive: true
- name: Cache Lucee files
uses: actions/cache@v4
with:
path: ~/work/_actions/lucee/script-runner/main/lucee-download-cache
key: lucee-downloads
enableCrossOsArchive: true
- name: Build with Ant
run: ant -noinput -verbose -buildfile build.xml
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: image-lex
path: dist/*.lex
- name: Checkout Lucee
uses: actions/checkout@v4
with:
repository: lucee/lucee
path: lucee
- name: Run Lucee Test Suite (testFilter="image")
uses: lucee/script-runner@main
with:
webroot: ${{ github.workspace }}/lucee/test
execute: /bootstrap-tests.cfm
luceeVersion: ${{ env.luceeVersion }}
luceeVersionQuery: ${{ env.luceeVersionQuery }}
extensionDir: ${{ github.workspace }}/dist
env:
testLabels: image
testAdditional: ${{ github.workspace }}/tests
- uses: actions/checkout@v4

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

- name: Build and Install with Maven
run: |
echo "------- Maven Install -------";
mvn -B -e -f pom.xml clean install
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: image-lex-${{ matrix.lucee.version }}
path: target/*.lex

- name: Checkout Lucee
uses: actions/checkout@v4
with:
repository: lucee/lucee
path: lucee

- name: Run Lucee Test Suite
uses: lucee/script-runner@main
with:
webroot: ${{ github.workspace }}/lucee/test
execute: /bootstrap-tests.cfm
luceeVersion: ${{ matrix.lucee.version }}
luceeVersionQuery: ${{ matrix.lucee.query }}
extensionDir: ${{ github.workspace }}/target
env:
testLabels: image
testAdditional: ${{ github.workspace }}/tests

deploy:
runs-on: ubuntu-latest
needs: [build-and-test]
if: always() && needs.build-and-test.result == 'success'
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up JDK 11
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'

- name: Cache Maven packages
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Import GPG key
run: |
echo "$GPG_PRIVATE_KEY" | base64 --decode | gpg --batch --import
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}

- name: Build and Deploy with Maven
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
run: |
if [[ "${{ needs.setup.outputs.version }}" == *-SNAPSHOT ]]; then
echo "------- Maven Deploy snapshot on ${{ github.event_name }} -------";
mvn -B -e -f pom.xml clean deploy --settings maven-settings.xml
else
echo "------- Maven Deploy release on ${{ github.event_name }} -------";
mvn -B -e -f pom.xml clean deploy -DperformRelease=true --settings maven-settings.xml
fi
3 changes: 0 additions & 3 deletions build.number

This file was deleted.

8 changes: 0 additions & 8 deletions build.properties

This file was deleted.

17 changes: 0 additions & 17 deletions build.sh

This file was deleted.

74 changes: 33 additions & 41 deletions build.xml
Original file line number Diff line number Diff line change
@@ -1,39 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<project default="clean" basedir="." name="formtag-extension">
<project default="clean" basedir="." name="image-extension">
<description>
Build Form Extension
Build Image Extension
</description>
<!-- set global properties for this build -->

<property file="build.properties"/>


<property name="lib" location="source/java/libs"/>
<property name="src" location="source/java/src"/>
<property name="srcImg" location="source/images"/>
<property name="srcFld" location="source/fld"/>
<property name="srcTld" location="source/tld"/>
<property name="temp" location="temp"/>
<property name="build" location="build"/>
<property name="dist" location="dist"/>
<property name="dist" location="target"/>

<buildnumber file="build.number"/>

<scriptdef name="replace" language="javascript">
<attribute name="haystack" />
<attribute name="needle" />
<attribute name="repl" />
<attribute name="property" />
<![CDATA[
var text = attributes.get("haystack");
var needle = attributes.get("needle");
var repl = attributes.get("repl");
text=text.trim();
var regex = new RegExp(needle,'g');
text=text.replace(regex,repl);
project.setProperty(attributes.get("property"), text);
]]>
</scriptdef>

<path id="classpath">
<fileset dir="${lib}">
Expand Down Expand Up @@ -73,11 +53,11 @@

<echo file="${dist}/extension/META-INF/MANIFEST.MF">Manifest-Version: 1.0
Built-Date: ${NOW}
version: "${bundleversion}${build.number}${appendix}"
version: "${bundleversion}"
id: "${id}"
name: "${label}"
description: "${description}"
lucee-core-version: "${minversion}"
lucee-core-version: "${luceeCoreVersion}"
start-bundles: false
</echo>

Expand All @@ -89,7 +69,7 @@ start-bundles: false
<target name="compile" depends="copy"
description="compile the source " >
<!-- Compile source -->
<javac srcdir="${temp}" target="1.8" destdir="${build}" debug="true" debuglevel="lines,vars,source">
<javac srcdir="${temp}" target="11" destdir="${build}" debug="true" debuglevel="lines,vars,source">
<classpath refid="classpath" />
</javac>

Expand All @@ -107,9 +87,9 @@ start-bundles: false

<!-- Put everything in ${build} into .jar file -->
<jar
jarfile="${dist}/extension/jars/${filename}-${bundleversion}${build.number}${appendix}.jar" basedir="${build}" manifest="${src}/META-INF/MANIFEST.MF">
jarfile="${dist}/extension/jars/${bundlename}-${bundleversion}.jar" basedir="${build}" manifest="${src}/META-INF/MANIFEST.MF">
<manifest>
<attribute name="Bundle-Version" value="${bundleversion}${build.number}${appendix}"/>
<attribute name="Bundle-Version" value="${bundleversion}"/>
<attribute name="Built-Date" value="${NOW}"/>
<attribute name="Bundle-SymbolicName" value="${bundlename}"/>

Expand Down Expand Up @@ -143,23 +123,35 @@ start-bundles: false
</fileset>
</copy>


<!-- copy the flds necessary -->
<loadfile property="f1" srcFile="${srcFld}/function.fld" />
<replace haystack="${f1}" needle="{bundle-name}" repl="${bundlename}" property="f2"/>
<replace haystack="${f2}" needle="{bundle-version}" repl="${bundleversion}${build.number}${appendix}" property="f3"/>
<echo message="${f3}" file="${dist}/extension/flds/image-function.fld"/>

<copy file="${srcFld}/function.fld" tofile="${dist}/extension/flds/image-functions.fld" />
<replaceregexp
file="${dist}/extension/flds/image-functions.fld"
match="\{bundle-name\}"
replace="${bundlename}"
byline="true"/>
<replaceregexp
file="${dist}/extension/flds/image-functions.fld"
match="\{bundle-version\}"
replace="${bundleversion}"
byline="true"/>

<!-- copy the tlds necessary -->
<loadfile property="t1" srcFile="${srcTld}/tag.tldx" />
<replace haystack="${t1}" needle="{bundle-name}" repl="${bundlename}" property="t2"/>
<replace haystack="${t2}" needle="{bundle-version}" repl="${bundleversion}${build.number}${appendix}" property="t3"/>
<echo message="${t3}" file="${dist}/extension/tlds/image-tag.tldx"/>
<!-- copy the flds necessary -->
<copy file="${srcTld}/tag.tldx" tofile="${dist}/extension/tlds/image-tags.tldx" />
<replaceregexp
file="${dist}/extension/tlds/image-tags.tldx"
match="\{bundle-name\}"
replace="${bundlename}"
byline="true"/>
<replaceregexp
file="${dist}/extension/tlds/image-tags.tldx"
match="\{bundle-version\}"
replace="${bundleversion}"
byline="true"/>


<!-- Zip everything -->
<zip destfile="${dist}/${filename}-${bundleversion}${build.number}${appendix}.lex">
<zip destfile="${dist}/${filename}-${bundleversion}.lex">
<zipfileset dir="${dist}/extension"/>
</zip>

Expand Down
27 changes: 27 additions & 0 deletions maven-settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<pluginGroups></pluginGroups>
<proxies></proxies>
<servers>
<server>
<id>ossrh</id>
<username>${env.MAVEN_USERNAME}</username>
<password>${env.MAVEN_PASSWORD}</password>
</server>
</servers>
<mirrors></mirrors>
<profiles>
<profile>
<id>ossrh</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<gpg.executable>gpg2</gpg.executable>
<gpg.passphrase>${env.GPG_PASSPHRASE}</gpg.passphrase>
</properties>
</profile>
</profiles>
</settings>
Loading

0 comments on commit 11e33a6

Please sign in to comment.