Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Knauer2008-04-03 09:19:03 +0000
committerMarkus Knauer2008-04-03 09:19:03 +0000
commite4ca298ca14b9c009d1fccb991cde7f641b780b1 (patch)
tree80ec7506070dd6e88856ac1b74b8e2afb119eb28 /plugins
parentd40fa153110b750cf7518ca6763fe43b85c24c83 (diff)
downloadorg.eclipse.epp.packages-e4ca298ca14b9c009d1fccb991cde7f641b780b1.tar.gz
org.eclipse.epp.packages-e4ca298ca14b9c009d1fccb991cde7f641b780b1.tar.xz
org.eclipse.epp.packages-e4ca298ca14b9c009d1fccb991cde7f641b780b1.zip
application returns correct error codes
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.epp.packaging.core/plugin.xml2
-rw-r--r--plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/PackagingApplication.java67
2 files changed, 57 insertions, 12 deletions
diff --git a/plugins/org.eclipse.epp.packaging.core/plugin.xml b/plugins/org.eclipse.epp.packaging.core/plugin.xml
index da7d34c6..7eb6fd49 100644
--- a/plugins/org.eclipse.epp.packaging.core/plugin.xml
+++ b/plugins/org.eclipse.epp.packaging.core/plugin.xml
@@ -15,7 +15,7 @@
id="EPP"
point="org.eclipse.core.runtime.products">
<product
- application="application"
+ application="org.eclipse.epp.packaging.core.application"
name="EPP Packaging">
<property
name="appName"
diff --git a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/PackagingApplication.java b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/PackagingApplication.java
index 69320ace..706a89f1 100644
--- a/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/PackagingApplication.java
+++ b/plugins/org.eclipse.epp.packaging.core/src/org/eclipse/epp/packaging/core/PackagingApplication.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Innoopract Informationssysteme GmbH
+ * Copyright (c) 2007, 2008 Innoopract Informationssysteme GmbH
* 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
@@ -10,44 +10,81 @@
*******************************************************************************/
package org.eclipse.epp.packaging.core;
+import java.io.IOException;
+import java.net.URISyntaxException;
import java.util.Map;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
import org.eclipse.epp.packaging.core.configuration.ArgumentParser;
import org.eclipse.epp.packaging.core.configuration.ICommands;
import org.eclipse.epp.packaging.core.configuration.IPackagerConfiguration;
import org.eclipse.epp.packaging.core.configuration.xml.ConfigurationParser;
import org.eclipse.equinox.app.IApplication;
import org.eclipse.equinox.app.IApplicationContext;
+import org.xml.sax.SAXException;
/**
* Main entry point for the EPP packager.
*/
public class PackagingApplication implements IApplication {
- public Object start( final IApplicationContext context ) throws Exception {
+ private static final Integer EXIT_ERROR = new Integer( 1 );
+
+ public Object start( final IApplicationContext context ) {
Map<?, ?> arguments = context.getArguments();
String[] args = ( String[] )arguments.get( IApplicationContext.APPLICATION_ARGS );
ICommands commands = ArgumentParser.parse( args );
ConfigurationParser configurationParser
= new ConfigurationParser( commands.getConfigurationFile() );
- IPackagerConfiguration configuration
- = configurationParser.parseConfiguration();
- IStatus checkFeaturesResult
- = configuration.checkFeatures( new NullProgressMonitor() );
+ IPackagerConfiguration configuration;
+ try {
+ configuration = configurationParser.parseConfiguration();
+ } catch( SAXException saxEx ) {
+ logError( saxEx, "Could not parse configuration file." ); //$NON-NLS-1$
+ return EXIT_ERROR;
+ } catch( IOException ioEx ) {
+ logError( ioEx, "Could not read configuration file." ); //$NON-NLS-1$
+ return EXIT_ERROR;
+ } catch( ParserConfigurationException parserConfigEx ) {
+ logError( parserConfigEx, "XML parser configuration error." ); //$NON-NLS-1$
+ return EXIT_ERROR;
+ }
+ IStatus checkFeaturesResult;
+ try {
+ checkFeaturesResult = configuration.checkFeatures( new NullProgressMonitor() );
+ } catch( CoreException coreEx ) {
+ logError( coreEx, "Features with error." ); //$NON-NLS-1$
+ return EXIT_ERROR;
+ }
IStatus[] status = checkFeaturesResult.getChildren();
for( IStatus singleStatus : status ) {
System.out.println( singleStatus.getMessage() );
}
- if( checkFeaturesResult.getSeverity() == IStatus.OK
- || checkFeaturesResult.getSeverity() == IStatus.INFO
- || checkFeaturesResult.getSeverity() == IStatus.WARNING ) {
+ if( checkFeaturesResult.getSeverity() == IStatus.OK
+ || checkFeaturesResult.getSeverity() == IStatus.INFO
+ || checkFeaturesResult.getSeverity() == IStatus.WARNING )
+ {
EclipsePackagingExecutor packagingExecutor
= new EclipsePackagingExecutor( commands, configuration );
- packagingExecutor.execute();
+ try {
+ packagingExecutor.execute();
+ } catch( CoreException coreEx ) {
+ logError( coreEx, "Could not build package." ); //$NON-NLS-1$
+ return EXIT_ERROR;
+ } catch( IOException ioEx ) {
+ logError( ioEx, "I/O exception during package build." ); //$NON-NLS-1$
+ return EXIT_ERROR;
+ } catch( URISyntaxException uriSyntaxEx ) {
+ logError( uriSyntaxEx, "Malformed URI." ); //$NON-NLS-1$
+ return EXIT_ERROR;
+ }
}
return EXIT_OK;
}
@@ -55,4 +92,12 @@ public class PackagingApplication implements IApplication {
public void stop() {
// nothing to stop here...
}
-} \ No newline at end of file
+
+ private void logError( final Exception exception, final String message ) {
+ IStatus status = new Status( IStatus.ERROR,
+ Activator.PLUGIN_ID,
+ message,
+ exception );
+ Activator.getDefault().getLog().log( status );
+ }
+}

Back to the top