/**
* Copyright (c) 2003-2005 Craig Setera
* All Rights Reserved.
* Licensed under the Eclipse Public License - v 1.0
* For more information see http://www.eclipse.org/legal/epl-v10.html
*/
package eclipseme.core.internal.preverification.builder;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.IStreamListener;
import org.eclipse.debug.core.model.IProcess;
import org.eclipse.debug.core.model.IStreamMonitor;
import org.eclipse.debug.core.model.IStreamsProxy;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import de.schlichtherle.io.ArchiveException;
import de.schlichtherle.io.File;
import de.schlichtherle.io.FileOutputStream;
import eclipseme.core.BuildLoggingConfiguration;
import eclipseme.core.IEclipseMECoreConstants;
import eclipseme.core.console.BuildConsoleProxy;
import eclipseme.core.console.IBuildConsoleProxy;
import eclipseme.core.internal.EclipseMECorePlugin;
import eclipseme.core.internal.PreferenceAccessor;
import eclipseme.core.internal.packaging.DeployedJADWriter;
import eclipseme.core.internal.packaging.ObfuscatorTool;
import eclipseme.core.internal.preverifier.PreverificationUtils;
import eclipseme.core.internal.utils.AbstractClasspathEntryVisitor;
import eclipseme.core.internal.utils.ColonDelimitedProperties;
import eclipseme.core.internal.utils.Utils;
import eclipseme.core.model.ApplicationDescriptor;
import eclipseme.core.model.IJADConstants;
import eclipseme.core.model.IMidletSuiteProject;
import eclipseme.core.model.MidletSuiteFactory;
import eclipseme.core.model.Version;
import eclipseme.core.model.ApplicationDescriptor.MidletDefinition;
import eclipseme.preverifier.results.PreverificationError;
/**
* Provides an incremental project builder implementation
* to do a J2ME preverification of classes. It is imperative
* that this builder follow the standard Java builder. The
* standard Java builder will generate the standard compiled
* class. The preverifier will then preverify that generated
* class.
* <p />
* Copyright (c) 2003-2007 Craig Setera<br>
* All Rights Reserved.<br>
* Licensed under the Eclipse Public License - v 1.0<p/>
* <br>
* $Revision: 1.16 $
* <br>
* $Date: 2006/11/26 21:42:00 $
* <br>
* @author Craig Setera
*/
public class PreverificationBuilder extends IncrementalProjectBuilder {
public static final String ARG_UPDATE_VERSION = "_update_version";
public static final String ARG_DO_PACKAGE = "_do_package";
public static final String ARG_DO_OBFUSCATION = "_do_obfuscation";
private static BuildLoggingConfiguration buildLoggingConfig = BuildLoggingConfiguration.instance;
// Tracks the TrueZip File instances that point to the deployed jar files
private static Map runtimeJars = new HashMap(5);
/**
* Clean the output of the specified project.
* @param project
* @param cleanDeployed Whether or not to clean the deployed directory too.
* @param monitor
*
* @throws JavaModelException
* @throws CoreException
*/
public static void cleanProject(IProject project, boolean cleanDeployed, IProgressMonitor monitor)
throws JavaModelException, CoreException
{
if (buildLoggingConfig.isPreverifierTraceEnabled()) {
BuildConsoleProxy.instance.traceln("> PreverificationBuilder.cleanProject project = " + project);
}
IJavaProject javaProject = JavaCore.create(project);
BuildInfo buildInfo =
new BuildInfo(IncrementalProjectBuilder.CLEAN_BUILD, new HashMap(), javaProject);
// Clear and remove the old verified directory and runtime folders
IFolder oldVerifiedFolder = project.getFolder(EclipseMECorePlugin.getVerifiedOutputDirectoryName());
if (oldVerifiedFolder.exists()) {
Utils.clearContainer(oldVerifiedFolder, monitor);
oldVerifiedFolder.delete(true, monitor);
}
IFolder oldRuntimeFolder = project.getFolder(IEclipseMECoreConstants.TEMP_FOLDER_NAME).getFolder("runtime");
if (oldRuntimeFolder.exists()) {
Utils.clearContainer(oldRuntimeFolder, monitor);
oldRuntimeFolder.delete(true, monitor);
}
// Clear the classes and libraries
IFolder classesPreverifyFolder = buildInfo.getVerifiedClassesFolder(monitor);
Utils.clearContainer(classesPreverifyFolder, monitor);
IFolder libsPreverifyFolder = buildInfo.getVerifiedLibsFolder(monitor);
Utils.clearContainer(libsPreverifyFolder, monitor);
// Delete the runtime JAR file
IFolder runtimeFolder = buildInfo.getRuntimeFolder(monitor);
if (runtimeFolder.exists()) {
deleteRuntimeJar(project, monitor);
Utils.clearContainer(runtimeFolder, monitor);
}
// We also delete the deployed folder
if (cleanDeployed) {
IFolder deploymentFolder = getDeploymentFolder(project, monitor);
if (deploymentFolder.exists()) {
Utils.clearContainer(deploymentFolder, monitor);
}
}
if (buildLoggingConfig.isPreverifierTraceEnabled()) {
BuildConsoleProxy.instance.traceln("< PreverificationBuilder.cleanProject project = " + project);
}
}
/**
* Return the File instance for the runtime jar file in the specified project.
*
* @param project
* @return
*/
public static File getRuntimeJar(IProject project, IProgressMonitor monitor)
throws CoreException
{
if (buildLoggingConfig.isPreverifierTraceEnabled()) {
BuildConsoleProxy.instance.traceln("> PreverificationBuilder.getRuntimeJar project = " + project);
}
File runtimeJar = (File) runtimeJars.get(project);
if (runtimeJar == null) {
if (buildLoggingConfig.isPreverifierTraceEnabled()) {
BuildConsoleProxy.instance.traceln("- PreverificationBuilder.getRuntimeJar JAR file not in cache");
}
IFolder tempFolder = project.getFolder(IEclipseMECoreConstants.TEMP_FOLDER_NAME);
IFolder runtimeFolder = tempFolder.getFolder(IEclipseMECoreConstants.EMULATION_FOLDER_NAME);
createFolders(runtimeFolder, monitor);
IJavaProject javaProject = JavaCore.create(project);
IMidletSuiteProject midletSuite =
MidletSuiteFactory.getMidletSuiteProject(javaProject);
runtimeJar = new File(runtimeFolder.getLocation().toFile(), midletSuite.getJarFilename());
runtimeJar.mkdir();
runtimeFolder.refreshLocal(IResource.DEPTH_ONE, monitor);
runtimeJars.put(project, runtimeJar);
}
if (buildLoggingConfig.isPreverifierTraceEnabled()) {
BuildConsoleProxy.instance.traceln("< PreverificationBuilder.getRuntimeJar project = " + project);
}
return runtimeJar;
}
/**
* Delete the deployed jar file instance being cached (if found).
*
* @param project
* @param monitor
* @throws CoreException
*/
private static void deleteRuntimeJar(IProject project, IProgressMonitor monitor)
throws CoreException
{
if (buildLoggingConfig.isPreverifierTraceEnabled()) {
BuildConsoleProxy.instance.traceln("> PreverificationBuilder.deleteRuntimeJar project = " + project);
}
File runtimeJar = (File) runtimeJars.remove(project);
if ((runtimeJar != null) && (runtimeJar.exists())) {
try {
if (buildLoggingConfig.isPreverifierTraceEnabled())
没有合适的资源?快使用搜索试试~ 我知道了~
EclipseMe插件
共542个文件
java:298个
png:83个
html:52个
需积分: 0 1 下载量 50 浏览量
2009-03-01
19:12:34
上传
评论
收藏 2.95MB ZIP 举报
温馨提示
EclipseMe 一种Eclipse插件 用于J2Me开发 很好用的
资源详情
资源评论
资源推荐
收起资源包目录
EclipseMe插件 (542个子文件)
genKeyStore.bat 662B
genTestJad.bat 412B
.classpath 451B
.classpath 433B
.classpath 372B
.classpath 354B
.classpath 307B
.classpath 307B
.classpath 307B
.classpath 307B
.classpath 307B
docs.css 2KB
api.exsd 5KB
deviceImporter.exsd 5KB
deviceEditor.exsd 4KB
configurations.exsd 4KB
profiles.exsd 4KB
importdev_wiz.gif 3KB
newclass_wiz_M.gif 3KB
newjprj_wiz_M.gif 3KB
eclipseME.gif 2KB
downarrow16.gif 869B
uparrow16.gif 868B
projects_M.gif 624B
javadoc_location_attrib.gif 596B
library.gif 587B
source_attach_attrib.gif 582B
newjprj_wiz_m_sm.gif 576B
newclass_wiz_green.gif 571B
cellphone_icon.gif 560B
class_obj_green.gif 346B
profile_obj.gif 338B
news.html 31KB
refSigning.html 23KB
faq.html 17KB
License.html 16KB
License.html 16KB
License.html 16KB
License.html 16KB
License.html 16KB
License.html 16KB
License.html 16KB
License.html 14KB
installEclipseME.html 14KB
refPrefJ2ME.html 13KB
migration.html 11KB
advJarFiles.html 11KB
refPropProject.html 10KB
troubleshooting.html 9KB
preprocessing.html 9KB
jadeditor.html 8KB
advDeviceMgmt.html 8KB
packaging.html 8KB
configuring.html 7KB
JETTY-LICENSE.html 7KB
removing.html 7KB
bestPractices.html 6KB
refAntenna.html 6KB
advDeviceMgmtBasics.html 6KB
buildingRef.html 5KB
refLaunchConfig.html 5KB
advDeviceMgmtLibs.html 4KB
index.html 4KB
migration150.html 4KB
run.html 4KB
createProject.html 4KB
support.html 3KB
installation.html 3KB
updating.html 3KB
createMidlet.html 2KB
about.html 2KB
advJavadoc.html 2KB
support_wtk.html 2KB
acknowledgements.html 1KB
prereqs.html 997B
ref.html 892B
about.html 690B
about.html 690B
about.html 690B
about.html 678B
about.html 672B
advanced.html 657B
about.html 656B
about.html 616B
about.ini 998B
UnitTest.jad 1KB
MyMidlet.jad 247B
org.mortbay.http.jar 305KB
JadTool.jar 16KB
MyMidlet.jar 739B
PreverificationBuilder.java 37KB
ResourceDeltaBuilder.java 34KB
MethodRewriter.java 34KB
AntennaBuildExporter.java 33KB
J2MESigningPropertiesPage.java 30KB
Utils.java 26KB
BasePreverifyTestCase.java 25KB
StandardPreverifier.java 23KB
SymbolDefinitionsPreferencePage.java 23KB
PreprocessorBuilder.java 22KB
共 542 条
- 1
- 2
- 3
- 4
- 5
- 6
gao8wen
- 粉丝: 10
- 资源: 13
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0