[tycho] Improve logging and error handling fop copy-platform-all

Mikolaj Izdebski mizdebsk at fedoraproject.org
Wed Feb 26 14:17:42 UTC 2014


commit f63325d80dde70a99a81b110413ef8ba86cda90d
Author: Mikolaj Izdebski <mizdebsk at redhat.com>
Date:   Wed Feb 26 15:09:50 2014 +0100

    Improve logging and error handling fop copy-platform-all

 copy-platform-all               |   21 +++++++++++++-----
 tycho-use-custom-resolver.patch |   44 ++++++++++++++++++++++++--------------
 tycho.spec                      |    5 +++-
 3 files changed, 47 insertions(+), 23 deletions(-)
---
diff --git a/copy-platform-all b/copy-platform-all
index dd56786..600d815 100755
--- a/copy-platform-all
+++ b/copy-platform-all
@@ -1,8 +1,11 @@
 #! /bin/sh
+set -e
 
 sdk=$1'-sdk'
 repo=$1
 
+echo Building system local p2 repository... >&2
+
 eclipse=$(rpm --eval '%{_libdir}')/eclipse
 
 datadir=/usr/share/eclipse
@@ -14,8 +17,9 @@ if [ ! -e ${launcher} ]; then
   launcher="$(pwd)/tycho-bundles/tycho-bundles-external/target/eclipse/plugins/org.eclipse.equinox.launcher_*.jar"
 fi
 
+trap "rm -rf $sdk" 0
 mkdir -p $sdk/plugins $sdk/features
-pushd $sdk
+pushd $sdk >/dev/null
 
       (cd $eclipse;
 	ls -d plugins/* features/* 2>/dev/null) |
@@ -87,20 +91,25 @@ done
 # jars in %%{_javadir} may not be uniquely named
 id=1
 for p in $(find $javadir $jnidir -name "*.jar"); do
-    unzip -p $p 'META-INF/MANIFEST.MF' | grep -q 'Bundle-SymbolicName'
-    if [ $? = 0 ]; then
+    if unzip -p $p 'META-INF/MANIFEST.MF' | grep -q 'Bundle-SymbolicName'; then
         plugin=${id}-$(basename $p)
         [ ! -e plugins/$plugin ] && ln -s $p plugins/$plugin
         id=$((${id} + 1))
     fi
 done
 
-popd
+popd >/dev/null
 
+(set -x
 java -jar ${launcher} -nosplash -application org.eclipse.equinox.p2.publisher.FeaturesAndBundlesPublisher \
 -metadataRepository file:$repo \
 -artifactRepository file:$repo \
 -source $sdk \
--compress -append -publishArtifacts
+-compress -append -publishArtifacts)
 
-rm -rf $sdk
+# In debugging mode dump contents of local p2 repo
+if [ x"$2" = x-X ]; then
+    echo === begin local p2 repo dump ===
+    find $repo -name \*.jar
+    echo === end local p2 repo dump ===
+fi
diff --git a/tycho-use-custom-resolver.patch b/tycho-use-custom-resolver.patch
index 9591288..078d623 100644
--- a/tycho-use-custom-resolver.patch
+++ b/tycho-use-custom-resolver.patch
@@ -1,4 +1,4 @@
-From f71f72eaaf6946f5b981eb345503aa9875c2dfcd Mon Sep 17 00:00:00 2001
+From 6e23e084e86c2f5d3f914469e67ed74e17736dde Mon Sep 17 00:00:00 2001
 From: Roland Grunberg <rgrunber at redhat.com>
 Date: Tue, 12 Jun 2012 10:38:51 -0400
 Subject: [PATCH] Implement a custom resolver for Tycho in local mode.
@@ -34,13 +34,13 @@ Change-Id: Ia1ece07ece2412bc4a88901631f3f651ad2b634b
  .../facade/TargetPlatformConfigurationStub.java    |  5 ++-
  tycho-core/pom.xml                                 |  5 +++
  .../eclipse/tycho/core/locking/FileLockerImpl.java | 26 ++++++++---
- .../core/maven/TychoMavenLifecycleParticipant.java | 33 ++++++++++++++
+ .../core/maven/TychoMavenLifecycleParticipant.java | 45 +++++++++++++++++++
  .../tycho/core/osgitools/AbstractTychoProject.java | 24 +++++++++++
  .../tycho/core/osgitools/OsgiBundleProject.java    | 29 ++++++++++++-
  .../DefaultTargetPlatformConfigurationReader.java  |  6 ++-
  .../osgi/runtime/TychoOsgiRuntimeLocator.java      | 17 ++++++++
  .../p2/resolver/P2TargetPlatformResolver.java      | 10 +++++
- 13 files changed, 235 insertions(+), 30 deletions(-)
+ 13 files changed, 247 insertions(+), 30 deletions(-)
 
 diff --git a/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/target/TargetDefinitionResolver.java b/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/target/TargetDefinitionResolver.java
 index b008768..77c1443 100644
@@ -311,18 +311,19 @@ index 86253bd..cef15d2 100644
              throw new RuntimeException(e);
          } catch (IOException e) {
 diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/maven/TychoMavenLifecycleParticipant.java b/tycho-core/src/main/java/org/eclipse/tycho/core/maven/TychoMavenLifecycleParticipant.java
-index d003619..53a3669 100644
+index 08daf3c..f11f439 100644
 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/maven/TychoMavenLifecycleParticipant.java
 +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/maven/TychoMavenLifecycleParticipant.java
-@@ -11,6 +11,7 @@
+@@ -11,6 +11,8 @@
  package org.eclipse.tycho.core.maven;
  
  import java.io.File;
 +import java.io.IOException;
++import java.lang.ProcessBuilder.Redirect;
  import java.util.ArrayList;
  import java.util.Arrays;
  import java.util.Collections;
-@@ -29,6 +30,7 @@ import org.apache.maven.project.MavenProject;
+@@ -29,6 +31,7 @@ import org.apache.maven.project.MavenProject;
  import org.codehaus.plexus.PlexusContainer;
  import org.codehaus.plexus.component.annotations.Component;
  import org.codehaus.plexus.component.annotations.Requirement;
@@ -330,7 +331,7 @@ index d003619..53a3669 100644
  import org.codehaus.plexus.logging.Logger;
  import org.eclipse.tycho.ReactorProject;
  import org.eclipse.tycho.core.osgitools.BundleReader;
-@@ -66,6 +68,37 @@ public class TychoMavenLifecycleParticipant extends AbstractMavenLifecyclePartic
+@@ -66,6 +69,48 @@ public class TychoMavenLifecycleParticipant extends AbstractMavenLifecyclePartic
          validate(projects);
          configureComponents(session);
  
@@ -354,14 +355,25 @@ index d003619..53a3669 100644
 +                if (! new File(copyPlatformPath).exists()) {
 +                    copyPlatformPath = System.getProperty("user.dir") + "/copy-platform-all";
 +                }
-+                String[] cmd = new String[] { copyPlatformPath, System.getProperty("user.dir") + "/.m2/p2/repo" };
-+                System.out.println("Building system local p2 repository...");
-+                Process p = Runtime.getRuntime().exec(cmd);
-+                p.waitFor();
-+            } catch (IOException e) {
-+                // Continue
-+            } catch (InterruptedException e) {
-+                // Continue
++                List<String> cmd = new ArrayList<String>();
++                cmd.add(copyPlatformPath);
++                cmd.add(System.getProperty("user.dir") + "/.m2/p2/repo");
++                if (session.getRequest().getLoggingLevel() <= Logger.LEVEL_DEBUG) {
++                    cmd.add("-X");
++                }
++                ProcessBuilder pb = new ProcessBuilder(cmd);
++                pb.redirectInput(Redirect.PIPE);
++                pb.redirectOutput(Redirect.INHERIT);
++                pb.redirectError(Redirect.INHERIT);
++                Process p = pb.start();
++                p.getOutputStream().close();
++                int exitCode = p.waitFor();
++                if (exitCode != 0) {
++                    throw new IOException("copy-platform-all script returned non-zero exit code: " + exitCode);
++                }
++            }
++            catch (Exception e) {
++                throw new MavenExecutionException( "Unable to build system local p2 repository", e );
 +            }
 +        }
 +
@@ -557,5 +569,5 @@ index 5150a19..d0e1e68 100644
              addEntireP2RepositoryToTargetPlatform(repository, tpConfiguration, session);
          }
 -- 
-1.8.3.1
+1.8.4.2
 
diff --git a/tycho.spec b/tycho.spec
index 248412a..d1c4498 100644
--- a/tycho.spec
+++ b/tycho.spec
@@ -19,7 +19,7 @@
 
 Name:           tycho
 Version:        0.19.0
-Release:        8%{?dist}
+Release:        9%{?dist}
 Summary:        Plugins and extensions for building Eclipse plugins and OSGI bundles with Maven
 
 Group:          Development/Libraries
@@ -334,6 +334,9 @@ install -m 644 $osgiJarPath $RPM_BUILD_ROOT%{_javadir}/%{name}/osgi.jar
 %{_javadocdir}/%{name}
 
 %changelog
+* Wed Feb 26 2014 Mikolaj Izdebski <mizdebsk at redhat.com> - 0.19.0-9
+- Improve logging and error handling fop copy-platform-all
+
 * Wed Jan 15 2014 Roland Grunberg <rgrunber at redhat.com> - 0.19.0-8
 - Perform a pure bootstrap build.
 - Fix issues with bootstrap build.


More information about the scm-commits mailing list