Hi, Someone on the FPC (Fedora Packaging Committee) voted -1 to the Eclipse plugin packaging guidelines in the recent meeting due to the verbosity of our PDE Build invocation. While I was annoyed with this at first, I took the opportunity to write a bash script to wrap our copy-platform and PDE build calls. I made it so that if there's only one feature in the source directory, it finds it automatically. I've attached it so that my horrible bash skills can be laughed at. Suggestions greatly welcome. I'm going to put it into the eclipse-pde RPM when it's ready. I tried it locally with eclipse-quickrex and here's what the diff looks like: -# See comments in the script to understand this. -/bin/sh -x %{eclipse_base}/buildscripts/copy-platform SDK %{eclipse_base} -mkdir home - %build -SDK=$(cd SDK > /dev/null && pwd) - -# Eclipse may try to write to the home directory. -homedir=$(cd home > /dev/null && pwd) - -java -cp $SDK/startup.jar \ - -Dosgi.sharedConfiguration.area=%{_libdir}/eclipse/configuration \ - org.eclipse.core.launcher.Main \ - -application org.eclipse.ant.core.antRunner \ - -Dtype=feature \ - -Did=de.babe.eclipse.plugins.QuickREx \ - -DbaseLocation=$SDK \ - -DsourceDirectory=$(pwd) \ - -DbuildDirectory=$(pwd)/build \ - -Dbuilder=%{eclipse_base}/plugins/org.eclipse.pde.build/templates/package-build \ - -f %{eclipse_base}/plugins/org.eclipse.pde.build/scripts/build.xml \ - -vmargs -Duser.home=$homedir +%{eclipse_base}/plugins/org.eclipse.pde.build/templates/package-build/pdebuild I've attached the diff for Mylyn (eclipse-mylyn). Both packages build the same with and without the script (which I have on my path for testing). A drawback is that we're calling copy-platform multiple times for multiple-feature projects like Mylyn and the calls after the first one all say "file exists" for the mkdir and ln -s calls. The nice thing here is that if we get package-build or something like it into pde.build upstream, we can just change the script. I'd really appreciate some feedback. Andrew
#!/bin/bash # args: [-f <feature>] [-d <dependencies (outside SDK)>] [-a <additional build args>] [-j <JVM args>] [-v] [-D] function usage { cat << _EOF_ usage: $0 [<options>] Use PDE Build to build Eclipse features Optional arguments: -h Show this help message -f Feature ID to build -d Plugin dependencies in addition to Eclipse SDK (space-separated, names on which to glob features and plugins) -a Additional build arguments (ex. -DjavacSource=1.5) -j VM arguments (ex. -DJ2SE-1.5=%{_jvmdir}/java/jre/lib/rt.jar) -v Be verbose -D Debug platform itself (passes -consolelog -debug to Eclipse) _EOF_ } function copyPlatform { # This seems silly but I was running into issues with empty strings # counting as arguments to copy-platform if [ -z $dependencies ]; then if [ $verbose -eq 1 ]; then echo "/bin/sh -x $datadir/eclipse/buildscripts/copy-platform $SDK $datadir/eclipse" /bin/sh -x $datadir/eclipse/buildscripts/copy-platform $SDK $datadir/eclipse else echo "/bin/sh $datadir/eclipse/buildscripts/copy-platform $SDK $datadir/eclipse" /bin/sh $datadir/eclipse/buildscripts/copy-platform $SDK $datadir/eclipse fi else if [ $verbose -eq 1 ]; then echo "/bin/sh -x $datadir/eclipse/buildscripts/copy-platform $SDK $datadir/eclipse $dependencies" /bin/sh -x $datadir/eclipse/buildscripts/copy-platform $SDK $datadir/eclipse $dependencies else echo "/bin/sh $datadir/eclipse/buildscripts/copy-platform $SDK $datadir/eclipse $dependencies" /bin/sh $datadir/eclipse/buildscripts/copy-platform $SDK $datadir/eclipse $dependencies fi fi } function findFeatureId { # We can determine the feature ID if we have only one numFeatures=$(find $sourceDir -name feature.xml | wc -l) if [ $numFeatures -ne 1 ]; then #echo "# features found = $numFeatures" echo "Cannot determine feature ID. Please specify with -f." usage exit 1 fi featureXml=$(find $sourceDir -name feature.xml) # Taken from Ben Konrath's package-build # make an ant build files to extract the id from the feature.xml buildFile=$buildDir/findFeatureForRPM-tmp-build.xml echo "<project default=\"main\"> <target name=\"main\"> <xmlproperty file=\"$featureXml\" collapseAttributes=\"true\"/> <fail unless=\"feature.id\" message=\"feature.id not set\"/> <echo message=\"\${feature.id}\" /> </target> </project>" > $buildFile featureId=$(ant -Dbasedir=$sourceDir -f $buildFile 2>&1 | grep echo | cut --delimiter=' ' -f 7) rm $buildFile } sourceDir=$PWD buildDir=$PWD/build SDK=$buildDir/SDK homeDir=$buildDir/home libdir=`rpm --eval "%{_libdir}"` datadir=`rpm --eval "%{_datadir}"` pdeBuildDir=$datadir/eclipse/plugins/org.eclipse.pde.build featureId= dependencies= additionalArgs= vmArgs= verbose=0 dryRun=0 debugPlatform=0 # See above. r = dry run (used for testing) while getopts “hf:d:a:j:vrD” OPTION do case $OPTION in h) usage exit ;; f) featureId=$OPTARG ;; d) dependencies=$OPTARG ;; a) additionalArgs=$OPTARG ;; j) vmArgs=$OPTARG ;; v) verbose=1 ;; r) dryRun=1 ;; D) debugPlatform=1 ;; ?) usage exit ;; esac done echo "mkdir -p $buildDir" if [ $dryRun -ne 1 ]; then mkdir -p $buildDir fi # Eclipse may try to write to the building user's home directory so we create a # temporary one for use by the build. echo "mkdir -p $homeDir" if [ $dryRun -ne 1 ]; then mkdir -p $homeDir fi if [ -z $featureId ]; then findFeatureId fi if [ -z $featureId ]; then echo "Cannot determine feature ID. Please specify with -f." usage exit 1 fi echo "Building feature = $featureId." if [ -z "$dependencies" ]; then if [ $verbose -eq 1 ]; then echo "Assuming no dependencies except Eclipse SDK." fi fi # Symlink the SDK and dependencies for build if [ -z "$dependencies" ]; then echo "Symlinking SDK into $SDK directory." else echo "Symlinking SDK and \"$dependencies\" into $SDK directory." fi if [ $dryRun -ne 1 ]; then copyPlatform fi if [ $debugPlatform -eq 1 ]; then debugPlatformArgs="-debug -consolelog" fi echo echo "Starting build:" echo " java -cp $SDK/startup.jar \ -Dosgi.sharedConfiguration.area=$libdir/eclipse/configuration \ org.eclipse.core.launcher.Main \ -application org.eclipse.ant.core.antRunner \ $debugPlatformArgs \ -Dtype=feature \ -Did=$featureId \ -DbaseLocation=$SDK \ -DsourceDirectory=$sourceDir \ -DbuildDirectory=$buildDir \ -Dbuilder=$datadir/eclipse/plugins/org.eclipse.pde.build/templates/package-build \ $additionalArgs \ -f $pdeBuildDir/scripts/build.xml \ -vmargs \ -Duser.home=$homeDir \ $vmArgs " if [ $dryRun -ne 1 ]; then java -cp $SDK/startup.jar \ -Dosgi.sharedConfiguration.area=$libdir/eclipse/configuration \ org.eclipse.core.launcher.Main \ -application org.eclipse.ant.core.antRunner \ $debugPlatformArgs \ -Dtype=feature \ -Did=$featureId \ -DbaseLocation=$SDK \ -DsourceDirectory=$sourceDir \ -DbuildDirectory=$buildDir \ -Dbuilder=$datadir/eclipse/plugins/org.eclipse.pde.build/templates/package-build \ $additionalArgs \ -f $pdeBuildDir/scripts/build.xml \ -vmargs \ -Duser.home=$homeDir \ $vmArgs fi
Index: eclipse-mylyn.spec =================================================================== RCS file: /cvs/pkgs/rpms/eclipse-mylyn/devel/eclipse-mylyn.spec,v retrieving revision 1.14 diff -u -r1.14 eclipse-mylyn.spec --- eclipse-mylyn.spec 19 Feb 2008 17:31:43 -0000 1.14 +++ eclipse-mylyn.spec 27 Mar 2008 20:14:59 -0000 @@ -144,9 +144,6 @@ %patch4 popd -/bin/sh -x %{eclipse_base}/buildscripts/copy-platform SDK %{eclipse_base} -mkdir home - # symlink out to jars we built pushd org.eclipse.mylyn.web.core/lib-httpclient rm commons-*.jar @@ -177,130 +174,27 @@ %{__grep} mylar org.eclipse.mylyn-feature/feature.xml && exit 1 %build -SDK=$(cd SDK > /dev/null && pwd) - -# Eclipse may try to write to the home directory. -homedir=$(cd home > /dev/null && pwd) - -# build the main mylyn feature -java -cp $SDK/startup.jar \ - -Dosgi.sharedConfiguration.area=%{_libdir}/eclipse/configuration \ - org.eclipse.core.launcher.Main \ - -application org.eclipse.ant.core.antRunner \ - -DjavacSource=1.5 \ - -DjavacTarget=1.5 \ - -Dtype=feature \ - -Did=org.eclipse.mylyn_feature \ - -DbaseLocation=$SDK \ - -DsourceDirectory=$(pwd) \ - -DbuildDirectory=$(pwd)/build \ - -Dbuilder=%{eclipse_base}/plugins/org.eclipse.pde.build/templates/package-build \ - -f %{eclipse_base}/plugins/org.eclipse.pde.build/scripts/build.xml \ - -vmargs -Duser.home=$homedir \ - -DJ2SE-1.5=%{_jvmdir}/java/jre/lib/rt.jar - -# build the mylyn bugzilla feature -java -cp $SDK/startup.jar \ - -Dosgi.sharedConfiguration.area=%{_libdir}/eclipse/configuration \ - org.eclipse.core.launcher.Main \ - -application org.eclipse.ant.core.antRunner \ - -DjavacSource=1.5 \ - -DjavacTarget=1.5 \ - -Dtype=feature \ - -Did=org.eclipse.mylyn.bugzilla_feature \ - -DbaseLocation=$SDK \ - -DsourceDirectory=$(pwd) \ - -DbuildDirectory=$(pwd)/build \ - -Dbuilder=%{eclipse_base}/plugins/org.eclipse.pde.build/templates/package-build \ - -f %{eclipse_base}/plugins/org.eclipse.pde.build/scripts/build.xml \ - -vmargs -Duser.home=$homedir \ - -DJ2SE-1.5=%{_jvmdir}/java/jre/lib/rt.jar - -# build the mylyn context feature -java -cp $SDK/startup.jar \ - -Dosgi.sharedConfiguration.area=%{_libdir}/eclipse/configuration \ - org.eclipse.core.launcher.Main \ - -application org.eclipse.ant.core.antRunner \ - -DjavacSource=1.5 \ - -DjavacTarget=1.5 \ - -Dtype=feature \ - -Did=org.eclipse.mylyn.context_feature \ - -DbaseLocation=$SDK \ - -DsourceDirectory=$(pwd) \ - -DbuildDirectory=$(pwd)/build \ - -Dbuilder=%{eclipse_base}/plugins/org.eclipse.pde.build/templates/package-build \ - -f %{eclipse_base}/plugins/org.eclipse.pde.build/scripts/build.xml \ - -vmargs -Duser.home=$homedir \ - -DJ2SE-1.5=%{_jvmdir}/java/jre/lib/rt.jar - -# build the mylyn ide feature -java -cp $SDK/startup.jar \ - -Dosgi.sharedConfiguration.area=%{_libdir}/eclipse/configuration \ - org.eclipse.core.launcher.Main \ - -application org.eclipse.ant.core.antRunner \ - -DjavacSource=1.5 \ - -DjavacTarget=1.5 \ - -Dtype=feature \ - -Did=org.eclipse.mylyn.ide_feature \ - -DbaseLocation=$SDK \ - -DsourceDirectory=$(pwd) \ - -DbuildDirectory=$(pwd)/build \ - -Dbuilder=%{eclipse_base}/plugins/org.eclipse.pde.build/templates/package-build \ - -f %{eclipse_base}/plugins/org.eclipse.pde.build/scripts/build.xml \ - -vmargs -Duser.home=$homedir \ - -DJ2SE-1.5=%{_jvmdir}/java/jre/lib/rt.jar - -# build the mylyn trac feature -java -cp $SDK/startup.jar \ - -Dosgi.sharedConfiguration.area=%{_libdir}/eclipse/configuration \ - org.eclipse.core.launcher.Main \ - -application org.eclipse.ant.core.antRunner \ - -DjavacSource=1.5 \ - -DjavacTarget=1.5 \ - -Dtype=feature \ - -Did=org.eclipse.mylyn.trac_feature \ - -DbaseLocation=$SDK \ - -DsourceDirectory=$(pwd) \ - -DbuildDirectory=$(pwd)/build \ - -Dbuilder=%{eclipse_base}/plugins/org.eclipse.pde.build/templates/package-build \ - -f %{eclipse_base}/plugins/org.eclipse.pde.build/scripts/build.xml \ - -vmargs -Duser.home=$homedir \ - -DJ2SE-1.5=%{_jvmdir}/java/jre/lib/rt.jar - -# build the mylyn java feature -java -cp $SDK/startup.jar \ - -Dosgi.sharedConfiguration.area=%{_libdir}/eclipse/configuration \ - org.eclipse.core.launcher.Main \ - -application org.eclipse.ant.core.antRunner \ - -DjavacSource=1.5 \ - -DjavacTarget=1.5 \ - -Dtype=feature \ - -Did=org.eclipse.mylyn.java_feature \ - -DbaseLocation=$SDK \ - -DsourceDirectory=$(pwd) \ - -DbuildDirectory=$(pwd)/build \ - -Dbuilder=%{eclipse_base}/plugins/org.eclipse.pde.build/templates/package-build \ - -f %{eclipse_base}/plugins/org.eclipse.pde.build/scripts/build.xml \ - -vmargs -Duser.home=$homedir \ - -DJ2SE-1.5=%{_jvmdir}/java/jre/lib/rt.jar - -# build the mylyn pde feature -java -cp $SDK/startup.jar \ - -Dosgi.sharedConfiguration.area=%{_libdir}/eclipse/configuration \ - org.eclipse.core.launcher.Main \ - -application org.eclipse.ant.core.antRunner \ - -DjavacSource=1.5 \ - -DjavacTarget=1.5 \ - -Dtype=feature \ - -Did=org.eclipse.mylyn.pde_feature \ - -DbaseLocation=$SDK \ - -DsourceDirectory=$(pwd) \ - -DbuildDirectory=$(pwd)/build \ - -Dbuilder=%{eclipse_base}/plugins/org.eclipse.pde.build/templates/package-build \ - -f %{eclipse_base}/plugins/org.eclipse.pde.build/scripts/build.xml \ - -vmargs -Duser.home=$homedir \ - -DJ2SE-1.5=%{_jvmdir}/java/jre/lib/rt.jar - +pdebuild -f org.eclipse.mylyn_feature \ + -a "-DjavacSource=1.5 -DjavacTarget=1.5" \ + -j -DJ2SE-1.5=%{_jvmdir}/java/jre/lib/rt.jar +pdebuild -f org.eclipse.mylyn.bugzilla_feature \ + -a "-DjavacSource=1.5 -DjavacTarget=1.5" \ + -j -DJ2SE-1.5=%{_jvmdir}/java/jre/lib/rt.jar +pdebuild -f org.eclipse.mylyn.context_feature \ + -a "-DjavacSource=1.5 -DjavacTarget=1.5" \ + -j -DJ2SE-1.5=%{_jvmdir}/java/jre/lib/rt.jar +pdebuild -f org.eclipse.mylyn.ide_feature \ + -a "-DjavacSource=1.5 -DjavacTarget=1.5" \ + -j -DJ2SE-1.5=%{_jvmdir}/java/jre/lib/rt.jar +pdebuild -f org.eclipse.mylyn.trac_feature \ + -a "-DjavacSource=1.5 -DjavacTarget=1.5" \ + -j -DJ2SE-1.5=%{_jvmdir}/java/jre/lib/rt.jar +pdebuild -f org.eclipse.mylyn.java_feature \ + -a "-DjavacSource=1.5 -DjavacTarget=1.5" \ + -j -DJ2SE-1.5=%{_jvmdir}/java/jre/lib/rt.jar +pdebuild -f org.eclipse.mylyn.pde_feature \ + -a "-DjavacSource=1.5 -DjavacTarget=1.5" \ + -j -DJ2SE-1.5=%{_jvmdir}/java/jre/lib/rt.jar %install rm -rf %{buildroot}
-- fedora-devel-java-list mailing list fedora-devel-java-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/fedora-devel-java-list