Skip to content
Snippets Groups Projects
Commit 18fdd03d authored by Erlend Stav's avatar Erlend Stav
Browse files

Moved old conformance tool to branches

parent 887e66fe
No related branches found
No related tags found
No related merge requests found
Showing
with 0 additions and 401 deletions
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.universaal.tools.conformance.verify.plugin</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
#Fri May 04 12:01:44 CEST 2012
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: org.universaal.tools.conformance.verify.plugin
Bundle-SymbolicName: org.universaal.tools.conformance.verify.plugin; singleton:=true
Bundle-Version: 0.3.1
Bundle-Activator: org.universaal.tools.conformance.verify.plugin.Activator
Bundle-Vendor: universAAL
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.m2e.core.ui,
org.eclipse.m2e.core
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Import-Package: org.apache.maven.execution,
org.apache.maven.project,
org.eclipse.core.resources,
org.eclipse.jdt.internal.core,
org.eclipse.m2e.core.ui.internal,
org.eclipse.ui.console
Export-Package: org.universaal.tools.conformance.verify.plugin.handlers
source.. = src/
output.. = bin/
bin.includes = plugin.xml,\
META-INF/,\
.,\
icons/,\
files/
<verifications xmlns="http://maven.apache.org/verifications/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/verifications/1.0.0 http://maven.apache.org/xsd/verifications-1.0.0.xsd">
<files>
<file>
<location>src/main/resources/file1.txt</location>
</file>
<file>
<location>src/main/resources/file2.txt</location>
<contains>aaaabbbb</contains>
</file>
<file>
<location>src/main/resources/file3.txt</location>
<exists>false</exists>
</file>
</files>
</verifications>
conformance/org.universaal.tools.conformance.verify.plugin/icons/uaal.gif

872 B

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.ui.commands">
<category
name="universAAL"
id="org.universaal.tools.conformance.verify.plugin.commands.category">
</category>
<command
name="Verify File Conformance"
categoryId="org.universaal.tools.conformance.verify.plugin.commands.category"
id="org.universaal.tools.conformance.verify.plugin.commands.sampleCommand">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers">
<!--<handler
commandId="org.universaal.tools.conformance.verify.plugin.commands.sampleCommand"
class="org.universaal.tools.conformance.verify.plugin.handlers.VerifierHandler">
<enabledWhen>
<with
variable="selection">
<iterate
ifEmpty="false"
operator="or">
<or>
<instanceof value="org.eclipse.core.resources.IProject" />
<instanceof value="org.eclipse.jdt.internal.core.JavaProject" />
</or>
</iterate>
<count value="1" />
</with>
</enabledWhen>
</handler>-->
</extension>
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="menu:org.universaal.tools.AALStudio.menu?after=test">
<command
commandId="org.universaal.tools.conformance.verify.plugin.commands.sampleCommand"
mnemonic="V"
id="org.universaal.tools.conformance.verify.plugin.menus.sampleCommand"
icon="icons/chckuaal_file.gif">
</command>
</menuContribution>
</extension>
</plugin>
package org.universaal.tools.conformance.verify.plugin;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle
*/
public class Activator extends AbstractUIPlugin {
// The plug-in ID
public static final String PLUGIN_ID = "org.universaal.tools.conformance.verify.plugin"; //$NON-NLS-1$
// The shared instance
private static Activator plugin;
// The absolute path for files
public static String absolutePath;
/**
* The constructor
*/
public Activator() {
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
super.start(context);
absolutePath=context.getBundle().getLocation().substring(15);//Remove "reference:file:"
plugin = this;
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Activator getDefault() {
return plugin;
}
/**
* Returns an image descriptor for the image file at the given
* plug-in relative path
*
* @param path the path
* @return the image descriptor
*/
public static ImageDescriptor getImageDescriptor(String path) {
return imageDescriptorFromPlugin(PLUGIN_ID, path);
}
}
package org.universaal.tools.conformance.verify.plugin.handlers;
import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.Properties;
import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.execution.MavenExecutionResult;
import org.apache.maven.project.MavenProject;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jdt.internal.core.JavaProject;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.embedder.IMaven;
import org.eclipse.m2e.core.internal.IMavenConstants;
import org.eclipse.m2e.core.project.IMavenProjectFacade;
import org.eclipse.m2e.core.project.IMavenProjectRegistry;
import org.eclipse.m2e.core.ui.internal.Messages;
import org.eclipse.m2e.core.ui.internal.actions.OpenMavenConsoleAction;
import org.eclipse.m2e.core.ui.internal.console.MavenConsoleImpl;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.console.ConsolePlugin;
import org.eclipse.ui.console.IConsole;
import org.eclipse.ui.console.IConsoleManager;
import org.eclipse.ui.console.IOConsole;
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.ui.progress.IProgressConstants2;
import org.universaal.tools.conformance.verify.plugin.Activator;
public class VerifierHandler extends AbstractHandler {
// Field so it can be used from Job
private IProject project;
/* (non-Javadoc)
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*/
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
// First, retrieve the current selection and check whether it is a project
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
// ISelection selection = HandlerUtil.getCurrentSelection(event);
// //TODO: Is this the same and faster?
ISelection selection = window.getSelectionService().getSelection();
if ((selection != null) && (selection instanceof StructuredSelection)) {
Object selected = ((StructuredSelection) selection)
.getFirstElement();
// If the selection is a project, start the transformation
IProject selectedPrj;
if (selected instanceof JavaProject) {
// Because they must be Maven projects, they will most prob. be JavaProjects
selectedPrj = ((JavaProject) selected).getProject();
} else if (selected instanceof IProject) {
// But if you select them from project explorer they are IProjects
selectedPrj = ((IProject) selected);
} else {
MessageDialog.openInformation(window.getShell(),
"Verify Conformance", "Selection is not a valid project. You must select a valid Maven project first.");
return null;
}
// Main task - verify
verify(selectedPrj);
} else {
MessageDialog.openInformation(window.getShell(),
"Verify Conformance", "No selection was made. You must select a valid Maven project first.");
}
return null;
}
/**
* Execute Maven verifier plugin as workspace Job for the selected project.
*
* @param selected
* The selected project to verify.
* @throws CoreException
*/
private void verify(IProject selected) {
project=selected;
Job job = new Job("AAL Studio") {
protected IStatus run(IProgressMonitor monitor) {
try {
// Continuous progress bar
monitor.beginTask("Verifying conformance", IProgressMonitor.UNKNOWN);
IMavenProjectRegistry projectManager = MavenPlugin.getMavenProjectRegistry();
// Check that it is a Maven Project
if (!project.hasNature(IMavenConstants.NATURE_ID)) {
monitor.done();
return new Status(Status.ERROR, Activator.PLUGIN_ID,"");
}
// Check that there is a POM.xml
IFile pomResource = project.getFile(IMavenConstants.POM_FILE_NAME);
if (pomResource == null) {
monitor.done();
return new Status(Status.ERROR, Activator.PLUGIN_ID,"");
}
//TODO: Refresh/update config here?
//Get Maven project and plugin
IMavenProjectFacade projectFacade = projectManager.create(project, monitor);
MavenProject mavenProject = projectFacade.getMavenProject(monitor);
IMaven maven = MavenPlugin.getMaven();
// Build command request:
// mvn verifier:verify -Dverifier.failOnError=true -Dverifier.verificationFile=...
MavenExecutionRequest request = projectManager.createExecutionRequest(pomResource,
projectFacade.getResolverConfiguration(), monitor);
Properties props=new Properties();
props.put("verifier.verificationFile", Activator.absolutePath+"/files/verify.xml");
props.put("verifier.failOnError", "true");
request.setUserProperties(props);
request.setGoals(Arrays.asList("verifier:verify"));
// TODO: Open Maven console to see it run. Not Working?
IOConsole console=setConsole();
// Execute
MavenExecutionResult result = maven.execute(request,monitor);
// Check if there are errors (missing files or plugin error)
if(result.hasExceptions()) {
String errors="The following errors where encountered: \n";
for(Throwable e : result.getExceptions()) {
if(e.getCause().getCause() instanceof FileNotFoundException){
errors="The verification guideline could not be found: "+e.getCause().getCause().getMessage()+"\n";
}else{
errors+="There are missing files, look at the console \n" +
"(if its blank you must select the right console): "+
e.getCause().getMessage()+"\n";
}
}
monitor.done();
return new Status(Status.ERROR, Activator.PLUGIN_ID,errors);
}
} catch (Exception ex) {
ex.printStackTrace();
monitor.done();
return new Status(Status.ERROR, Activator.PLUGIN_ID,ex.getMessage());
}
monitor.done();
//TODO: Elaborate a good result dialog
return new Status(Status.OK, Activator.PLUGIN_ID, "Project has all files");
}
};
// TODO: Open (again) the Maven console to see it run. Not working?
job.setProperty(IProgressConstants2.ACTION_PROPERTY, new OpenMavenConsoleAction());
job.setProperty(IProgressConstants2.ICON_PROPERTY, Activator.getImageDescriptor("icons/uaal.gif"));
job.setUser(true);
job.schedule();
}
/**
* Gets the Maven console, or a new console if its not there. Currently
* its not working as desired. It creates an empty console named Maven
* Console, but Maven is somehow always executed in current console, so this
* one gets on top of that.
*
* @return The console
*/
private IOConsole setConsole() {
ConsolePlugin plugin = ConsolePlugin.getDefault();
IConsoleManager conMan = plugin.getConsoleManager();
IConsole[] existing = conMan.getConsoles();
// Look for Maven Console
for (int i = 0; i < existing.length; i++)
if (Messages.MavenConsoleImpl_title.equals(existing[i].getName()))
return (IOConsole) existing[i];
// no console found, so create a new (Maven) one
// MessageConsole myConsole = new MessageConsole(
// Messages.MavenConsoleImpl_title, null);
MavenConsoleImpl myConsole = new MavenConsoleImpl(null);//Not working?
conMan.addConsoles(new IConsole[] { myConsole });
conMan.showConsoleView(myConsole);
myConsole.clearConsole();
myConsole.activate();
return myConsole;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment