Skip to content

Commit e6ca1fb

Browse files
michaeloffnerclaude
andcommitted
convert to Maven-based extension, bump version to 3.0.0.0-ALPHA
- Replace OSGi bundle pattern with Maven-based extension (start-bundles: false) - Add source/java/pom.xml: org.lucee:ehcache artifact with net.sf.ehcache:ehcache:2.10.9.2 compile dep - Rewrite build.xml: Maven build + copy-dependencies into maven/ repo layout, full + lite lex - Update MANIFEST.MF: maven: coordinate in cache entry, drop OSGi bundle headers - Simplify EHCacheClassLoader: remove OSGi/Felix bundle search fallback - Update Eclipse .project/.classpath to Maven project (m2e) - Remove local JARs from libs/, all deps now managed via pom.xml - Add copy-parent-poms.sh for embedded Maven repo parent POM resolution Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 9a58a23 commit e6ca1fb

14 files changed

Lines changed: 496 additions & 216 deletions

build.xml

Lines changed: 119 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -3,51 +3,120 @@
33
<description>
44
Build EHCache Extension
55
</description>
6-
<!-- set global properties for this build -->
76

8-
<property name="lib" location="source/java/libs"/>
9-
<property name="src" location="source/java/src"/>
7+
<!-- default goal when not passed by Maven (e.g. local mvn package run) -->
8+
<property name="maven.goal" value="install"/>
9+
1010
<property name="srcCFML" location="source/CFML/src"/>
1111
<property name="srcImg" location="source/images"/>
1212
<property name="temp" location="temp"/>
1313
<property name="build" location="build"/>
1414
<property name="dist" location="target"/>
1515

16-
<path id="classpath">
17-
<fileset dir="${lib}">
18-
<include name="**/*.jar" />
19-
</fileset>
20-
</path>
21-
2216
<target name="init">
23-
<!-- Create the time stamp -->
2417
<tstamp/>
25-
18+
2619
<delete dir="${temp}"/>
2720
<delete dir="${dist}"/>
2821

29-
<!-- Create the build directory structure used by compile -->
3022
<mkdir dir="${temp}"/>
3123
<mkdir dir="${build}"/>
3224
<mkdir dir="${dist}/"/>
25+
</target>
3326

34-
27+
<target name="maven-build" depends="init">
28+
29+
<condition property="is.deploy" value="true" else="false">
30+
<equals arg1="${maven.goal}" arg2="deploy"/>
31+
</condition>
32+
33+
<!-- Check if artifact already exists in Maven Central -->
34+
<condition property="artifact.exists">
35+
<and>
36+
<equals arg1="${is.deploy}" arg2="true"/>
37+
<http url="https://repo1.maven.org/maven2/${mvnGroupPath}/${mvnArtifactId}/${bundleversion}/${mvnArtifactId}-${bundleversion}.pom"/>
38+
</and>
39+
</condition>
40+
41+
<!-- Set effective goal based on whether artifact exists -->
42+
<!-- if artifact already on Central, downgrade to install to avoid re-deploying -->
43+
<condition property="effective.goal" value="install" else="${maven.goal}">
44+
<istrue value="${artifact.exists}"/>
45+
</condition>
46+
47+
<echo>goal:${maven.goal}</echo>
48+
<echo>effective.goal:${effective.goal}</echo>
49+
<echo>performRelease:${is.deploy}</echo>
50+
<echo>groupId:${mvnGroupId}</echo>
51+
<echo>groupPath:${mvnGroupPath}</echo>
52+
<echo>artifactId:${mvnArtifactId}</echo>
53+
<echo>bundleversion:${bundleversion}</echo>
54+
55+
<exec dir="source/java" executable="mvn" failonerror="true">
56+
<arg value="clean"/>
57+
<arg value="${effective.goal}"/>
58+
<arg value="-Drevision=${bundleversion}"/>
59+
<arg value="-DperformRelease=${is.deploy}"/>
60+
<arg value="-e"/>
61+
<arg value="--settings"/>
62+
<arg value="${basedir}/maven-settings.xml"/>
63+
<arg value="-Dmaven.username=${maven.username}"/>
64+
<arg value="-Dmaven.password=${maven.password}"/>
65+
<arg value="-Dgpg.passphrase=${gpg.passphrase}"/>
66+
</exec>
67+
68+
<!-- Copy dependencies with Maven repository layout -->
69+
<exec dir="source/java" executable="mvn" failonerror="true">
70+
<arg value="-DoutputDirectory=${temp}/dependency"/>
71+
<arg value="-Dmdep.copyPom=true"/>
72+
<arg value="-Dmdep.useRepositoryLayout=true"/>
73+
<arg value="-DexcludeScope=provided"/>
74+
<arg value="-Drevision=${bundleversion}"/>
75+
<arg value="dependency:copy-dependencies"/>
76+
</exec>
77+
78+
<!-- Copy parent POMs -->
79+
<exec executable="bash" failonerror="true">
80+
<arg value="${basedir}/copy-parent-poms.sh"/>
81+
<arg value="${temp}/dependency"/>
82+
</exec>
3583
</target>
3684

85+
<target name="copy-dependencies" depends="maven-build">
86+
<mkdir dir="${dist}/extension/maven"/>
3787

38-
<target name="copy" depends="init" description="copy source file to temp" >
39-
<!-- copy the source -->
40-
<copy todir="${temp}">
41-
<fileset dir="${src}">
42-
<include name="**/*.java"/>
88+
<!-- Copy the Maven-built JAR and POM -->
89+
<copy todir="${dist}/extension/maven">
90+
<fileset dir="source/java/target">
91+
<include name="*.jar"/>
92+
<include name="*.pom"/>
93+
<exclude name="*-sources.jar"/>
94+
<exclude name="*-javadoc.jar"/>
4395
</fileset>
4496
</copy>
4597

98+
<copy file="source/java/pom.xml" tofile="${dist}/extension/maven/${mvnArtifactId}-${bundleversion}.pom"/>
99+
100+
<mkdir dir="${dist}/extension/maven/${mvnGroupPath}/${mvnArtifactId}/${bundleversion}/"/>
46101

102+
<move file="${dist}/extension/maven/${mvnArtifactId}-${bundleversion}.jar"
103+
tofile="${dist}/extension/maven/${mvnGroupPath}/${mvnArtifactId}/${bundleversion}/${mvnArtifactId}-${bundleversion}.jar"/>
104+
<move file="${dist}/extension/maven/${mvnArtifactId}-${bundleversion}.pom"
105+
tofile="${dist}/extension/maven/${mvnGroupPath}/${mvnArtifactId}/${bundleversion}/${mvnArtifactId}-${bundleversion}.pom"/>
106+
107+
<!-- Copy all dependencies -->
108+
<copy todir="${dist}/extension/maven">
109+
<fileset dir="${temp}/dependency">
110+
<include name="**/*.jar"/>
111+
<include name="**/*.pom"/>
112+
</fileset>
113+
</copy>
114+
</target>
115+
116+
<target name="createManifest" depends="copy-dependencies">
47117
<tstamp>
48-
<format property="NOW" pattern="yyyy-MM-dd HH:mm:ss" />
118+
<format property="NOW" pattern="yyyy-MM-dd HH:mm:ss"/>
49119
</tstamp>
50-
51120
<echo file="${dist}/extension/META-INF/MANIFEST.MF">Manifest-Version: 1.0
52121
Built-Date: ${NOW}
53122
version: "${bundleversion}"
@@ -56,37 +125,14 @@ groupId: "${groupId}"
56125
artifactId: "${artifactId}"
57126
name: "${label}"
58127
description: "${description}"
59-
lucee-core-version: "5.0.0.230"
128+
lucee-core-version: "${luceeCoreVersion}"
129+
release-type: ${releaseType}
60130
start-bundles: false
61-
release-type: server
62-
cache: "[{'class':'${class}','bundleName':'${bundlename}','bundleVersion':'${bundleversion}'}]"
131+
cache: "[{'class':'${class}','maven':'${mvnGroupId}:${mvnArtifactId}:${bundleversion}'}]"
63132
</echo>
64133
</target>
65-
66-
67-
68-
<target name="compile" depends="copy"
69-
description="compile the source " >
70-
<!-- Compile ACF-Infinspan source -->
71-
<javac srcdir="${temp}" target="11" source="11" destdir="${build}" debug="true" debuglevel="lines,vars,source">
72-
<classpath refid="classpath" />
73-
</javac>
74-
</target>
75134

76-
<target name="dist" depends="compile"
77-
description="generate the distribution" >
78-
79-
80-
<!-- Put everything in ${build} into .jar file -->
81-
<jar
82-
jarfile="${dist}/extension/jars/${bundlename}-${bundleversion}.jar" basedir="${build}" manifest="${src}/META-INF/MANIFEST.MF">
83-
<manifest>
84-
<attribute name="Bundle-Version" value="${bundleversion}"/>
85-
<attribute name="Built-Date" value="${NOW}"/>
86-
<attribute name="Bundle-SymbolicName" value="${bundlename}"/>
87-
88-
</manifest>
89-
</jar>
135+
<target name="dist" depends="createManifest">
90136

91137
<!-- copy EHCache.cfc -->
92138
<copy todir="${dist}/extension/context">
@@ -95,73 +141,45 @@ cache: "[{'class':'${class}','bundleName':'${bundlename}','bundleVersion':'${bun
95141
</fileset>
96142
</copy>
97143

98-
<copy
99-
file="${srcCFML}/context/admin/cdriver/EHCache.cfc"
100-
tofile="${dist}/extension/context/admin/cdriver/EHCache.cfc" />
101-
102-
<replaceregexp
103-
file="${dist}/extension/context/admin/cdriver/EHCache.cfc"
104-
match="\{class\}"
105-
replace="${class}"
106-
byline="true"/>
107-
<replaceregexp
108-
file="${dist}/extension/context/admin/cdriver/EHCache.cfc"
109-
match="\{label\}"
110-
replace="${label}"
111-
byline="true"/>
112-
<replaceregexp
113-
file="${dist}/extension/context/admin/cdriver/EHCache.cfc"
114-
match="\{desc\}"
115-
replace="${description}"
144+
<replaceregexp
145+
file="${dist}/extension/context/admin/cdriver/EHCache.cfc"
146+
match="\{class\}"
147+
replace="${class}"
116148
byline="true"/>
117-
<replaceregexp
118-
file="${dist}/extension/context/admin/cdriver/EHCache.cfc"
119-
match="\{bundlename\}"
120-
replace="${bundlename}"
149+
<replaceregexp
150+
file="${dist}/extension/context/admin/cdriver/EHCache.cfc"
151+
match="\{label\}"
152+
replace="${label}"
121153
byline="true"/>
122-
<replaceregexp
123-
file="${dist}/extension/context/admin/cdriver/EHCache.cfc"
124-
match="\{bundleversion\}"
125-
replace="${bundleversion}"
154+
<replaceregexp
155+
file="${dist}/extension/context/admin/cdriver/EHCache.cfc"
156+
match="\{desc\}"
157+
replace="${description}"
126158
byline="true"/>
127159

128-
129-
130-
131-
132-
<!-- copy the jars necessary -->
133-
<copy todir="${dist}/extension/jars">
134-
<fileset dir="${lib}">
135-
<include name="**/*.jar"/>
136-
<exclude name="**/javax.*"/>
137-
<exclude name="**/jsp-*"/>
138-
<exclude name="**/lucee.jar"/>
139-
<exclude name="**/org.apache.felix.framework-*"/>
140-
<exclude name="**/org.lucee.axis*"/>
141-
</fileset>
142-
</copy>
143-
144-
145160
<!-- copy the logo -->
146161
<copy todir="${dist}/extension/META-INF">
147162
<fileset dir="${srcImg}/">
148163
<include name="logo.png"/>
149164
</fileset>
150165
</copy>
151166

167+
<!-- Full lex (includes bundled Maven dependencies) -->
168+
<zip destfile="${dist}/${filename}-${bundleversion}.lex">
169+
<zipfileset dir="${dist}/extension"/>
170+
</zip>
152171

153-
154-
<!-- Zip everything -->
155-
<zip destfile="${dist}/${filename}-${bundleversion}.lex">
156-
<zipfileset dir="${dist}/extension"/>
172+
<!-- Lite lex (without bundled Maven dependencies) -->
173+
<zip destfile="${dist}/${filename}-${bundleversion}.lite.lex">
174+
<zipfileset dir="${dist}/extension">
175+
<exclude name="maven/**"/>
176+
</zipfileset>
157177
</zip>
158-
159178
</target>
160179

161-
<target name="clean" depends="dist" description="clean up" >
162-
<!-- Delete the ${build} and ${dist} directory trees -->
163-
<delete dir="${build}"/>
164-
<delete dir="${temp}"/>
165-
</target>
180+
<target name="clean" depends="dist">
181+
<delete dir="${build}"/>
182+
<delete dir="${temp}"/>
183+
</target>
166184

167-
</project>
185+
</project>

copy-parent-poms.sh

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#!/bin/bash
2+
3+
DEPENDENCY_DIR="$1"
4+
M2_REPO="${HOME}/.m2/repository"
5+
COPIED_TRACKER="${DEPENDENCY_DIR}/.parent_poms_copied"
6+
7+
echo "========================================"
8+
echo "Copying parent POMs from local Maven repository"
9+
echo "========================================"
10+
11+
# Create tracker file
12+
mkdir -p "$DEPENDENCY_DIR"
13+
> "$COPIED_TRACKER"
14+
15+
# Function to check if we've already copied this POM
16+
is_already_copied() {
17+
grep -qx "$1" "$COPIED_TRACKER" 2>/dev/null
18+
}
19+
20+
# Function to mark POM as copied
21+
mark_as_copied() {
22+
echo "$1" >> "$COPIED_TRACKER"
23+
}
24+
25+
# Function to recursively copy parent chain
26+
copy_parent_chain() {
27+
pom_file="$1"
28+
29+
# Check if POM exists
30+
if [ ! -f "$pom_file" ]; then
31+
return
32+
fi
33+
34+
# Extract parent info (handles multi-line XML)
35+
parent_block=$(sed -n '/<parent>/,/<\/parent>/p' "$pom_file" | tr '\n' ' ')
36+
37+
if [ -z "$parent_block" ]; then
38+
return # No parent, stop recursion
39+
fi
40+
41+
parent_group=$(echo "$parent_block" | sed -n 's/.*<groupId>\([^<]*\)<\/groupId>.*/\1/p' | head -1)
42+
parent_artifact=$(echo "$parent_block" | sed -n 's/.*<artifactId>\([^<]*\)<\/artifactId>.*/\1/p' | head -1)
43+
parent_version=$(echo "$parent_block" | sed -n 's/.*<version>\([^<]*\)<\/version>.*/\1/p' | head -1)
44+
45+
# Validate we got all three values
46+
if [ -z "$parent_group" ] || [ -z "$parent_artifact" ] || [ -z "$parent_version" ]; then
47+
return
48+
fi
49+
50+
# Create unique key for this POM (safe for file storage)
51+
pom_key="${parent_group}__${parent_artifact}__${parent_version}"
52+
53+
# Skip if already copied
54+
if is_already_copied "$pom_key"; then
55+
return
56+
fi
57+
58+
# Convert group ID to path
59+
parent_path=$(echo "$parent_group" | tr '.' '/')
60+
61+
# Source location in local Maven repo
62+
parent_pom="$M2_REPO/$parent_path/$parent_artifact/$parent_version/$parent_artifact-$parent_version.pom"
63+
64+
# Target location in dependency directory
65+
target_dir="$DEPENDENCY_DIR/$parent_path/$parent_artifact/$parent_version"
66+
67+
if [ -f "$parent_pom" ]; then
68+
mkdir -p "$target_dir"
69+
cp "$parent_pom" "$target_dir/"
70+
echo "✓ Copied: $parent_artifact:$parent_version"
71+
72+
# Mark as copied
73+
mark_as_copied "$pom_key"
74+
75+
# Recursively copy this parent's parent
76+
copy_parent_chain "$parent_pom"
77+
else
78+
echo "✗ NOT FOUND in local repo: $parent_artifact:$parent_version"
79+
echo " Expected at: $parent_pom"
80+
fi
81+
}
82+
83+
# Find all POM files and process each
84+
find "$DEPENDENCY_DIR" -name "*.pom" -type f | while read pom; do
85+
copy_parent_chain "$pom"
86+
done
87+
88+
# Clean up tracker file
89+
rm -f "$COPIED_TRACKER"
90+
91+
echo "========================================"
92+
echo "Parent POM copy complete"
93+
echo "========================================"

0 commit comments

Comments
 (0)