コード例 #1
0
  public IArchive createDefaultConfiguration(String projectName, IProgressMonitor monitor) {
    // IPackageType t = this;
    IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
    Assert.isNotNull(project);

    IJavaProject javaProject = JavaCore.create(project);
    Assert.isNotNull(javaProject);

    if (monitor == null) monitor = new NullProgressMonitor();

    monitor.beginTask(
        ArchivesCore.bind(ArchivesCoreMessages.CreatingDefaultJarConfig, project.getName()), 2);

    IPath outputPath;
    try {
      outputPath = javaProject.getOutputLocation();
    } catch (JavaModelException e) {
      ArchivesCore.getInstance().getLogger().log(IStatus.WARNING, e.getMessage(), e);
      return null;
    }

    outputPath = outputPath.removeFirstSegments(1);
    IContainer outputContainer = project.getFolder(outputPath);

    IArchive jar = new ArchiveImpl();

    jar.setDestinationPath(project.getLocation());
    jar.setInWorkspace(true);
    jar.setExploded(false);
    jar.setName(project.getName() + ".jar"); // $NON-NLS-1$
    jar.setArchiveType(this);

    IArchiveStandardFileSet classes = new ArchiveFileSetImpl();
    classes.setIncludesPattern("**/*"); // $NON-NLS-1$
    classes.setRawSourcePath(outputContainer.getFullPath().toString());
    classes.setInWorkspace(true);

    try {
      jar.addChild(classes);
    } catch (ArchivesModelException ame) {
    }

    monitor.worked(1);
    monitor.done();

    return jar;
  }
コード例 #2
0
 public AbstractArchiveWizard(IArchive existingPackage) {
   this.existingPackage = existingPackage;
   this.project =
       ResourcesPlugin.getWorkspace().getRoot().getProject(existingPackage.getProjectName());
 }