-
Notifications
You must be signed in to change notification settings - Fork 17
/
create-archetype.sh
executable file
·62 lines (53 loc) · 2.81 KB
/
create-archetype.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/sh
# This script generates an archetype into target/archetype from the source project.
#
# Two optional commands can be provided (in the order listed):
#
# install - which will automatically install the generated archetype in the local repository
# generate - generate a project from the archetype into target/generated-project
#
ARCHETYPE_BUILD_DIR=target/generated-sources/archetype
ARCHETYPE_DIR=target/archetype
ARCHETYPE_RESOURCES_DIR=$ARCHETYPE_DIR/src/main/resources/archetype-resources
echo Generating archetype from project into $ARCHETYPE_BUILD_DIR...
if [ ! -z `which markdown` ]; then
markdown readme.md -f readme.html
else
echo markdown cannot be found, skipping generation of readme.html
fi
mvn clean archetype:create-from-project -Darchetype.properties=archetype.properties
echo Relocating generated archetype project to $ARCHETYPE_DIR...
rsync -az --exclude `basename $0` --exclude-from=archetype-excludes.txt $ARCHETYPE_BUILD_DIR/src $ARCHETYPE_DIR/
cp -f archetype-pom.xml $ARCHETYPE_DIR/pom.xml
mvn -f $ARCHETYPE_DIR/pom.xml clean
echo Patching generated archetype...
# could also use col -b
touch $ARCHETYPE_RESOURCES_DIR/pom.xml
touch $ARCHETYPE_RESOURCES_DIR/readme.md
#sed -i 's;<name>jboss-as-subsystem-src</name>;<name>${name}</name>;' $ARCHETYPE_RESOURCES_DIR/pom.xml
touch $ARCHETYPE_RESOURCES_DIR/pom.xml
#sed -i 's;eclipse-dot-files/\?;;' $ARCHETYPE_DIR/src/main/resources/META-INF/maven/archetype-metadata.xml
cp -f archetype-metadata.xml $ARCHETYPE_DIR/src/main/resources/META-INF/maven/archetype-metadata.xml
touch $ARCHETYPE_DIR/src/main/resources/META-INF/maven/archetype-metadata.xml
cp archetype-test.properties $ARCHETYPE_DIR/src/test/resources/projects/basic/archetype.properties
mv $ARCHETYPE_RESOURCES_DIR/src/main/resources/com/mycompany/subsystem/* $ARCHETYPE_RESOURCES_DIR/src/main/resources/
#rsync -az --exclude .svn eclipse-dot-files/ $ARCHETYPE_RESOURCES_DIR/
# fix the archetype plugin being an idiot
find $ARCHETYPE_RESOURCES_DIR -type f -exec sed -i -e 's;packageInPathFormat;package;g' {} \;
# remove local file that NetBeans add to source project
rm -f $ARCHETYPE_RESOURCES_DIR/src/main/webapp/WEB-INF/sun-web.xml
rm -f readme.html
# could set the release version at this point, if specified
if [ ! -z $1 ] && [ "$1" = "install" ]; then
echo Installing archetype...
shift
mvn -f $ARCHETYPE_DIR/pom.xml install
fi
if [ ! -z $1 ] && [ "$1" = "generate" ]; then
echo Generating project from archetype...
cd target
mvn archetype:generate -B -DarchetypeCatalog=local \
-DarchetypeArtifactId=jboss-as-subsystem -DarchetypeGroupId=org.jboss.as.archetypes -DarchetypeVersion=7.1.1.Final \
-DartifactId=example-project -DgroupId=com.acme -Dpackage=com.acme.example -Dversion=1.0.0-SNAPSHOT -Dname="Java EE 6 subsystem project" \
-Dmodule=org.test.subsystem
fi