diff options
author | Roland Grunberg <rgrunber@redhat.com> | 2013-08-08 15:08:56 -0400 |
---|---|---|
committer | Roland Grunberg <rgrunber@redhat.com> | 2013-08-08 15:52:37 -0400 |
commit | f9a71ca6994a9e9fa7e29451f91fbf4445e53cf7 (patch) | |
tree | aa5d1f5b193d5e3283d33e110869cdec41010d1b /prepTestBundle.sh | |
download | tycho-surefire-testbundlerunner-f9a71ca6994a9e9fa7e29451f91fbf4445e53cf7.tar.gz tycho-surefire-testbundlerunner-f9a71ca6994a9e9fa7e29451f91fbf4445e53cf7.tar.xz tycho-surefire-testbundlerunner-f9a71ca6994a9e9fa7e29451f91fbf4445e53cf7.zip |
Initial Commit.
Diffstat (limited to 'prepTestBundle.sh')
-rwxr-xr-x | prepTestBundle.sh | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/prepTestBundle.sh b/prepTestBundle.sh new file mode 100755 index 0000000..be704d2 --- /dev/null +++ b/prepTestBundle.sh @@ -0,0 +1,67 @@ +#! /bin/bash + +# Copyright (C) 2013, Red Hat, Inc. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html + +# Support for running Tycho Surefire on an OSGi Test Bundle +# mvn org.eclipse.tycho:tycho-surefire-plugin:test + +# Maven Conceptual Layout +# org.eclipse.tycho:org.eclipse.tycho.surefire.testbundlerunner +# | plugin:tycho-maven-plugin +# | plugin:target-platform-configuration +# | +# --> osgiTestBundle (gid:aid) +# plugin:tycho-surefire-plugin + + +# File System Conceptual Layout +# org.eclipse.tycho:org.eclipse.tycho.surefire.testbundlerunner +# | +# --> pom.xml +# --> ${bsname} +# | +# --> pom.xml +# --> META-INF/MANIFEST.MF +# --> target/classes/**.class +# --> resources/ + +jarLoc=$1 + +jarPomPath=`jar -tf ${jarLoc} | grep 'pom.xml'` +bsname=`unzip -p ${jarLoc} 'META-INF/MANIFEST.MF' | grep 'Bundle-SymbolicName' | sed 's/Bundle-SymbolicName: \([a-zA-Z.]*\)\(;\)\?.*/\1/'` + +mkdir ${bsname} +pushd ${bsname} + +# place manifest and pom +jar -xf ${jarLoc} 'META-INF/MANIFEST.MF' ${jarPomPath} +mv ${jarPomPath} . +rm -rf 'META-INF/maven' + +# set the parent +sed -i '/<parent>/,/<\/parent>/ s/<artifactId>.*<\/artifactId>/<artifactId>org.eclipse.tycho.surefire.testbundlerunner<\/artifactId>/ ' pom.xml +sed -i '/<parent>/,/<\/parent>/ s/<groupId>.*<\/groupId>/<groupId>org.eclipse.tycho<\/groupId>/ ' pom.xml +sed -i '/<parent>/,/<\/parent>/ s/<version>.*<\/version>/<version>1.0.0-SNAPSHOT<\/version>/ ' pom.xml + +# place classes +# non-classes will just be ignored +mkdir -p target/classes +pushd target/classes +jar -xf ${jarLoc} +popd + +# place resources and other files +# non-resources will just be ignored +jar -xf ${jarLoc} + +popd + +if [ ! -e pom.xml ]; then + cp pom.xml{.orig,} +fi +# link the parent to the child +sed -i "/<\/modules>/ i <module>${bsname}<\/module>" pom.xml |