]>
Commit | Line | Data |
---|---|---|
1b2798f6 EK |
1 | /******************************************************************************* |
2 | * Copyright (c) 2007, 2011 IBM Corporation and others. | |
3 | * All rights reserved. This program and the accompanying materials | |
4 | * are made available under the terms of the Eclipse Public License v1.0 | |
5 | * which accompanies this distribution, and is available at | |
6 | * http://www.eclipse.org/legal/epl-v10.html | |
7 | * | |
8 | * Contributors: | |
9 | * IBM Corporation - initial API and implementation | |
10 | * Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 83258 [jar exporter] Deploy java application as executable jar | |
11 | *******************************************************************************/ | |
12 | package org.eclipse.jdt.internal.ui.jarpackager; | |
13 | ||
14 | import java.util.zip.ZipFile; | |
15 | ||
16 | import org.eclipse.swt.widgets.Shell; | |
17 | ||
18 | import org.eclipse.core.runtime.CoreException; | |
19 | import org.eclipse.core.runtime.IPath; | |
20 | import org.eclipse.core.runtime.IProgressMonitor; | |
21 | import org.eclipse.core.runtime.MultiStatus; | |
22 | ||
23 | import org.eclipse.core.resources.IFile; | |
24 | ||
25 | import org.eclipse.jdt.ui.jarpackager.IManifestProvider; | |
26 | import org.eclipse.jdt.ui.jarpackager.JarPackageData; | |
27 | import org.eclipse.jdt.ui.jarpackager.JarWriter3; | |
28 | ||
29 | /** | |
30 | * Jar builder for the plain jar exported. Does not export archives. | |
31 | * | |
32 | * @since 3.4 | |
33 | */ | |
34 | public class PlainJarBuilder extends JarBuilder { | |
35 | ||
36 | public static final String BUILDER_ID= "org.eclipse.jdt.ui.plain_jar_builder"; //$NON-NLS-1$ | |
37 | ||
38 | private JarPackageData fJarPackage; | |
39 | private JarWriter3 fJarWriter; | |
40 | ||
41 | /** | |
42 | * {@inheritDoc} | |
43 | */ | |
44 | public String getId() { | |
45 | return BUILDER_ID; | |
46 | } | |
47 | ||
48 | /** | |
49 | * {@inheritDoc} | |
50 | */ | |
51 | public IManifestProvider getManifestProvider() { | |
52 | return new ManifestProvider(); | |
53 | } | |
54 | ||
55 | /** | |
56 | * {@inheritDoc} | |
57 | */ | |
58 | @Override | |
59 | public void open(JarPackageData jarPackage, Shell displayShell, MultiStatus statusMsg) throws CoreException { | |
60 | super.open(jarPackage, displayShell, statusMsg); | |
61 | fJarPackage= jarPackage; | |
62 | fJarWriter= new JarWriter3(fJarPackage, displayShell); | |
63 | } | |
64 | ||
65 | /** | |
66 | * {@inheritDoc} | |
67 | */ | |
68 | public void writeFile(IFile resource, IPath destinationPath) throws CoreException { | |
69 | fJarWriter.write(resource, destinationPath); | |
70 | } | |
71 | ||
72 | /** | |
73 | * {@inheritDoc} | |
74 | */ | |
75 | public void writeArchive(ZipFile archiveRoot, IProgressMonitor progressMonitor) { | |
76 | //do nothing, plain jar builder can not handle archives, use fat jar builder | |
77 | } | |
78 | ||
79 | /** | |
80 | * {@inheritDoc} | |
81 | */ | |
82 | public void close() throws CoreException { | |
83 | if (fJarWriter != null) { | |
84 | fJarWriter.close(); | |
85 | } | |
86 | } | |
87 | ||
88 | } |