[jboss-cvs] jbosside/core/plugins/org.jboss.ide.eclipse.packages.core/src/main/org/jboss/ide/eclipse/archives/core/model/types ...
Robert Stryker
rob.stryker at jboss.com
Wed Apr 18 12:52:04 EDT 2007
User: rawb
Date: 07/04/18 12:52:04
Added: core/plugins/org.jboss.ide.eclipse.packages.core/src/main/org/jboss/ide/eclipse/archives/core/model/types
JARPackageType.java AbstractArchiveType.java
IArchiveType.java
Log:
refactored to archive rather than package, a la max
Revision Changes Path
1.1 date: 2007/04/18 16:52:04; author: rawb; state: Exp;jbosside/core/plugins/org.jboss.ide.eclipse.packages.core/src/main/org/jboss/ide/eclipse/archives/core/model/types/JARPackageType.java
Index: JARPackageType.java
===================================================================
package org.jboss.ide.eclipse.archives.core.model.types;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.jboss.ide.eclipse.archives.core.Trace;
import org.jboss.ide.eclipse.archives.core.model.IArchive;
import org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet;
import org.jboss.ide.eclipse.archives.core.model.internal.ArchiveFileSetImpl;
import org.jboss.ide.eclipse.archives.core.model.internal.ArchiveImpl;
/**
* The default JAR package type will simply jar-up all the classes in a java project's output directory, and place it in the top-level of the project.
* The name of the resulting JAR will be the project's name followed by a ".jar" extension.
* @author Marshall
*/
public class JARPackageType extends AbstractArchiveType {
public static final String TYPE_ID = "jar";
public IArchive createDefaultConfiguration(IProject project, IProgressMonitor monitor) {
//IPackageType t = this;
Assert.isNotNull(project);
IJavaProject javaProject = JavaCore.create(project);
Assert.isNotNull(javaProject);
if (monitor == null) monitor = new NullProgressMonitor();
monitor.beginTask("Creating default JAR configuration for java project \"" + project.getName() + "\"", 2);
IPath outputPath;
try {
outputPath = javaProject.getOutputLocation();
} catch (JavaModelException e) {
Trace.trace(JARPackageType.class, e);
return null;
}
outputPath = outputPath.removeFirstSegments(1);
IContainer outputContainer = project.getFolder(outputPath);
IArchive jar = new ArchiveImpl();
jar.setDestinationPath(project.getLocation(), true);
jar.setExploded(false);
jar.setName(project.getName() + ".jar");
//jar.setPackageType(this);
IArchiveFileSet classes = new ArchiveFileSetImpl();
classes.setIncludesPattern("**/*");
classes.setSourcePath(outputContainer.getLocation());
jar.addChild(classes);
monitor.worked(1);
monitor.done();
return jar;
}
}
1.1 date: 2007/04/18 16:52:04; author: rawb; state: Exp;jbosside/core/plugins/org.jboss.ide.eclipse.packages.core/src/main/org/jboss/ide/eclipse/archives/core/model/types/AbstractArchiveType.java
Index: AbstractArchiveType.java
===================================================================
/**
* JBoss, a Division of Red Hat
* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.ide.eclipse.archives.core.model.types;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExecutableExtension;
import org.eclipse.core.runtime.IProgressMonitor;
import org.jboss.ide.eclipse.archives.core.model.IArchive;
/**
*
* @author rob.stryker at jboss.com
*/
public abstract class AbstractArchiveType implements IArchiveType, IExecutableExtension {
private IConfigurationElement element;
public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException {
if( element == null ) element = config;
}
public String getId() {
return element.getAttribute("id");
}
public String getLabel() {
return element.getAttribute("label");
}
public abstract IArchive createDefaultConfiguration(IProject project, IProgressMonitor monitor);
}
1.1 date: 2007/04/18 16:52:04; author: rawb; state: Exp;jbosside/core/plugins/org.jboss.ide.eclipse.packages.core/src/main/org/jboss/ide/eclipse/archives/core/model/types/IArchiveType.java
Index: IArchiveType.java
===================================================================
package org.jboss.ide.eclipse.archives.core.model.types;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IProgressMonitor;
import org.jboss.ide.eclipse.archives.core.model.IArchive;
/**
* This interface represents a package type (i.e. JAR,WAR,SAR etc).
*
* A package type's main focus right now is to provide a default "template" Package for a given Project, making it easier
* for users and adopters to automatically adapt projects into a deployable package type.
*
* @author Marshall
*/
public interface IArchiveType {
/**
* @return The ID for this PackageType, i.e. "jar", "war" etc
*/
public String getId();
/**
* @return The label for this PackageType (usually shown in UI)
*/
public String getLabel();
/**
* This will create a "default" packaging configuration for this project using this package type.
*
* If the passed-in project does not support this package type, a null IPackage should be returned.
*
* @param project The project to create the packages configuration for
* @return The top level package that was created
*/
public IArchive createDefaultConfiguration(IProject project, IProgressMonitor monitor);
}
More information about the jboss-cvs-commits
mailing list