Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
416 changes: 390 additions & 26 deletions .github/workflows/main.yml

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/dist
temp
**/Test.java
**/TestCase.java
**/.DS_Store
Expand All @@ -10,3 +11,4 @@ target
target/*
*.lock
*.DS_Store
**/.flattened-pom.xml
197 changes: 98 additions & 99 deletions build.xml
Original file line number Diff line number Diff line change
@@ -1,58 +1,107 @@
<?xml version="1.0" encoding="UTF-8"?>
<project default="clean" basedir="." name="argon2-extension">
<description>
<description>
Build Argon2 Extension
</description>
<!-- set global properties for this build -->

<!-- set global properties for this build -->

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

<property name="tld" location="source/tld"/>
<property name="fld" location="source/fld"/>

<path id="classpath">
<fileset dir="${lib}">
<include name="**/*.jar" />
</fileset>
</path>

<target name="init">
<!-- Create the time stamp -->
<tstamp/>

<delete dir="${temp}"/>
<delete dir="${dist}"/>

<!-- Create the build directory structure used by compile -->
<mkdir dir="${temp}"/>
<mkdir dir="${build}"/>
<mkdir dir="${dist}/"/>
</target>


<!-- build the org.lucee:argon2-functions jar with Maven (deployed to Maven Central on deploy) -->
<target name="maven-build" depends="init">

<condition property="is.deploy" value="true" else="false">
<equals arg1="${maven.goal}" arg2="deploy"/>
</condition>

<!-- Check if artifact already exists in Maven Central -->
<condition property="artifact.exists">
<and>
<equals arg1="${is.deploy}" arg2="true"/>
<http url="https://repo1.maven.org/maven2/${mvnGroupPath}/${mvnArtifactId}/${bundleversion}/${mvnArtifactId}-${bundleversion}.pom"/>
</and>
</condition>

<!-- Set effective goal based on whether artifact exists -->
<condition property="effective.goal" value="install" else="${maven.goal}">
<equals arg1="${artifact.exists}" arg2="true"/>
</condition>

<echo>goal:${maven.goal}</echo>
<echo>effective.goal:${effective.goal}</echo>
<echo>performRelease:${is.deploy}</echo>
<echo>groupId:${mvnGroupId}</echo>
<echo>artifactId:${mvnArtifactId}</echo>
<echo>bundleversion:${bundleversion}</echo>
<echo>luceeCoreVersion:${luceeCoreVersion}</echo>

<exec dir="source/java" executable="mvn" failonerror="true">
<arg value="clean"/>
<arg value="${effective.goal}"/>
<arg value="-B"/>
<arg value="-e"/>
<arg value="-Drevision=${bundleversion}"/>
<arg value="-Dlucee.version=${luceeCoreVersion}"/>
<arg value="-DperformRelease=${is.deploy}"/>
<arg value="--settings"/>
<arg value="maven-settings.xml"/>
<!-- credentials as system properties, read from the environment by the root pom.xml -->
<arg value="-Dmaven.username=${maven.username}"/>
<arg value="-Dmaven.password=${maven.password}"/>
<arg value="-Dgpg.passphrase=${gpg.passphrase}"/>
</exec>

<!-- copy the runtime dependencies (not the provided Lucee core) in repository layout -->
<exec dir="source/java" executable="mvn" failonerror="true">
<arg value="-B"/>
<arg value="-DoutputDirectory=${temp}/dependency"/>
<arg value="-Dmdep.copyPom=true"/>
<arg value="-Dmdep.useRepositoryLayout=true"/>
<arg value="-DexcludeScope=provided"/>
<arg value="-Drevision=${bundleversion}"/>
<arg value="-Dlucee.version=${luceeCoreVersion}"/>
<arg value="dependency:copy-dependencies"/>
</exec>

<!-- parent POMs are needed to resolve the dependency POMs offline -->
<exec executable="bash" failonerror="true">
<arg value="${basedir}/copy-parent-poms.sh"/>
<arg value="${temp}/dependency"/>
</exec>
</target>

<target name="copy-dependencies" depends="maven-build">
<property name="mvnDir" location="${dist}/extension/maven/${mvnGroupPath}/${mvnArtifactId}/${bundleversion}"/>
<mkdir dir="${mvnDir}"/>

<!-- the jar built by Maven -->
<copy file="source/java/target/${mvnArtifactId}-${bundleversion}.jar" tofile="${mvnDir}/${mvnArtifactId}-${bundleversion}.jar" failonerror="true"/>
<!-- the flattened POM (resolved version, dependency list), the same one that is published -->
<copy file="source/java/.flattened-pom.xml" tofile="${mvnDir}/${mvnArtifactId}-${bundleversion}.pom" failonerror="true"/>

<target name="copy" depends="init" description="copy source file to temp" >
<!-- copy the source -->
<copy todir="${temp}">
<fileset dir="${src}">
<include name="**/*.java"/>
<exclude name="**/Test.java"/>
<exclude name="**/TestCase.java"/>
<!-- all runtime dependencies -->
<copy todir="${dist}/extension/maven">
<fileset dir="${temp}/dependency">
<include name="**/*.jar"/>
<include name="**/*.pom"/>
</fileset>
</copy>
</target>


<target name="createManifest" depends="copy-dependencies" description="create MANIFEST.MF file" >
<tstamp>
<format property="NOW" pattern="yyyy-MM-dd HH:mm:ss" />
<format property="NOW" pattern="yyyy-MM-dd HH:mm:ss" />
</tstamp>

<echo file="${dist}/extension/META-INF/MANIFEST.MF">Manifest-Version: 1.0
Built-Date: ${NOW}
version: "${bundleversion}"
Expand All @@ -66,67 +115,12 @@ release-type: ${releaseType}
start-bundles: false
</echo>
</target>



<target name="compile" depends="copy"
description="compile the source " >
<!-- Compile ACF-Infinspan source -->
<javac srcdir="${temp}" source="1.8" target="1.8" destdir="${build}" debug="true" debuglevel="lines,vars,source">
<classpath refid="classpath" />
</javac>
</target>

<target name="dist" depends="compile"
description="generate the distribution" >


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

</manifest>
</jar>
<target name="dist" depends="createManifest" description="generate the distribution" >

<!-- copy the flds necessary -->
<copy
file="${fld}/function.fld"
tofile="${dist}/extension/flds/argon2-functions.fld" />

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


<!-- copy the jars necessary -->
<copy todir="${dist}/extension/jars">
<fileset dir="${lib}">
<include name="**/*.jar"/>
<exclude name="**/javax.*"/>
<exclude name="**/jsp-*"/>
<exclude name="**/lucee.jar"/>
<exclude name="**/org.apache.felix.framework-*"/>

<!-- we exclude this because this is part of the Lucee core and in worst case it is loaded on the fly -->
<exclude name="**/httpcomponents-*"/>
<exclude name="**/org.lucee.httpcomponents.*"/>
<!-- <exclude name="**/org.apache.commons.codec-*"/> -->
<exclude name="**/commons-codec-*"/>
<exclude name="**/log4j-*"/>
<exclude name="**/javax-mail-activation-*"/>
</fileset>
</copy>
<copy file="${fld}/function.fld" tofile="${dist}/extension/flds/argon2-functions.fld" />
<replaceregexp file="${dist}/extension/flds/argon2-functions.fld" match="\{maven\}" replace="${mvnGroupId}:${mvnArtifactId}:${bundleversion}" byline="true"/>

<!-- copy the logo -->
<copy todir="${dist}/extension/META-INF">
Expand All @@ -135,16 +129,21 @@ start-bundles: false
</fileset>
</copy>

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


<!-- Lite artifact: same but without bundled Maven dependencies -->
<zip destfile="${dist}/${filename}-${bundleversion}.lite.lex">
<zipfileset dir="${dist}/extension">
<exclude name="maven/**"/>
</zipfileset>
</zip>
</target>

<target name="clean" depends="dist" description="clean up" >
<delete dir="${temp}"/>
</target>
<target name="clean" depends="dist" description="clean up" >
<!-- Delete the ${build} and ${dist} directory trees -->
<delete dir="${build}"/>
<delete dir="${temp}"/>
</target>

</project>
</project>
93 changes: 93 additions & 0 deletions copy-parent-poms.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#!/bin/bash

DEPENDENCY_DIR="$1"
M2_REPO="${HOME}/.m2/repository"
COPIED_TRACKER="${DEPENDENCY_DIR}/.parent_poms_copied"

echo "========================================"
echo "Copying parent POMs from local Maven repository"
echo "========================================"

# Create tracker file
mkdir -p "$DEPENDENCY_DIR"
> "$COPIED_TRACKER"

# Function to check if we've already copied this POM
is_already_copied() {
grep -qx "$1" "$COPIED_TRACKER" 2>/dev/null
}

# Function to mark POM as copied
mark_as_copied() {
echo "$1" >> "$COPIED_TRACKER"
}

# Function to recursively copy parent chain
copy_parent_chain() {
pom_file="$1"

# Check if POM exists
if [ ! -f "$pom_file" ]; then
return
fi

# Extract parent info (handles multi-line XML)
parent_block=$(sed -n '/<parent>/,/<\/parent>/p' "$pom_file" | tr '\n' ' ')

if [ -z "$parent_block" ]; then
return # No parent, stop recursion
fi

parent_group=$(echo "$parent_block" | sed -n 's/.*<groupId>\([^<]*\)<\/groupId>.*/\1/p' | head -1)
parent_artifact=$(echo "$parent_block" | sed -n 's/.*<artifactId>\([^<]*\)<\/artifactId>.*/\1/p' | head -1)
parent_version=$(echo "$parent_block" | sed -n 's/.*<version>\([^<]*\)<\/version>.*/\1/p' | head -1)

# Validate we got all three values
if [ -z "$parent_group" ] || [ -z "$parent_artifact" ] || [ -z "$parent_version" ]; then
return
fi

# Create unique key for this POM (safe for file storage)
pom_key="${parent_group}__${parent_artifact}__${parent_version}"

# Skip if already copied
if is_already_copied "$pom_key"; then
return
fi

# Convert group ID to path
parent_path=$(echo "$parent_group" | tr '.' '/')

# Source location in local Maven repo
parent_pom="$M2_REPO/$parent_path/$parent_artifact/$parent_version/$parent_artifact-$parent_version.pom"

# Target location in dependency directory
target_dir="$DEPENDENCY_DIR/$parent_path/$parent_artifact/$parent_version"

if [ -f "$parent_pom" ]; then
mkdir -p "$target_dir"
cp "$parent_pom" "$target_dir/"
echo "✓ Copied: $parent_artifact:$parent_version"

# Mark as copied
mark_as_copied "$pom_key"

# Recursively copy this parent's parent
copy_parent_chain "$parent_pom"
else
echo "✗ NOT FOUND in local repo: $parent_artifact:$parent_version"
echo " Expected at: $parent_pom"
fi
}

# Find all POM files and process each
find "$DEPENDENCY_DIR" -name "*.pom" -type f | while read pom; do
copy_parent_chain "$pom"
done

# Clean up tracker file
rm -f "$COPIED_TRACKER"

echo "========================================"
echo "Parent POM copy complete"
echo "========================================"
Loading
Loading