diff --git a/conformance/org.universaal.tools.conformanceTools/.classpath b/conformance/org.universaal.tools.conformanceTools/.classpath index 52dea1591f23d8cde1e70ff45f34b7ac6fb92c9a..212edb3aaafaf2d15cb42ca62305786abd27986c 100644 --- a/conformance/org.universaal.tools.conformanceTools/.classpath +++ b/conformance/org.universaal.tools.conformanceTools/.classpath @@ -7,7 +7,6 @@ <attribute name="maven.pomderived" value="true"/> </attributes> </classpathentry> - <classpathentry kind="lib" path="lib/mw.bus.ui.osgi-1.2.0.jar"/> - <classpathentry kind="lib" path="lib/mw.bus.model.osgi-1.2.0.jar"/> + <classpathentry exported="true" kind="lib" path="lib/plexus-utils-3.0.jar"/> <classpathentry kind="output" path="target/classes"/> </classpath> diff --git a/conformance/org.universaal.tools.conformanceTools/META-INF/MANIFEST.MF b/conformance/org.universaal.tools.conformanceTools/META-INF/MANIFEST.MF index 72b515be72d1be67bc1d77b2f6586c310b029e2d..f3498a9d4a50225fe15fb5934d921463a38a74e8 100644 --- a/conformance/org.universaal.tools.conformanceTools/META-INF/MANIFEST.MF +++ b/conformance/org.universaal.tools.conformanceTools/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: AAL Studio ConformanceTools Bundle-SymbolicName: org.universaal.tools.conformanceTools;singleton:=true -Bundle-Version: 0.6.5 +Bundle-Version: 0.7.2 Bundle-Activator: org.universaal.tools.conformanceTools.Activator Bundle-Vendor: universAAL Require-Bundle: org.eclipse.ui, @@ -22,6 +22,11 @@ Require-Bundle: org.eclipse.ui, Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-ActivationPolicy: lazy Import-Package: org.apache.maven.execution, + org.apache.maven.model, + org.apache.maven.model.io.xpp3, org.apache.maven.project, + org.codehaus.plexus, + org.codehaus.plexus.util, + org.codehaus.plexus.util.xml, org.eclipse.m2e.core.ui.internal.actions, org.eclipse.ui.console diff --git a/conformance/org.universaal.tools.conformanceTools/build.properties b/conformance/org.universaal.tools.conformanceTools/build.properties index a478146003ff6ca94974537caf2fc15effbc1b0c..e57d8adb6a684fe1b2422454af11fb3451d64566 100644 --- a/conformance/org.universaal.tools.conformanceTools/build.properties +++ b/conformance/org.universaal.tools.conformanceTools/build.properties @@ -8,4 +8,5 @@ bin.includes = build.properties,\ .classpath,\ icons/,\ .settings/,\ - files/ + files/,\ + lib/ diff --git a/conformance/org.universaal.tools.conformanceTools/lib/mw.bus.model.osgi-1.2.0.jar b/conformance/org.universaal.tools.conformanceTools/lib/mw.bus.model.osgi-1.2.0.jar deleted file mode 100644 index 8feba52d68c1984da1d8e09a8b2986ba8fa16638..0000000000000000000000000000000000000000 Binary files a/conformance/org.universaal.tools.conformanceTools/lib/mw.bus.model.osgi-1.2.0.jar and /dev/null differ diff --git a/conformance/org.universaal.tools.conformanceTools/lib/mw.bus.ui.osgi-1.2.0.jar b/conformance/org.universaal.tools.conformanceTools/lib/mw.bus.ui.osgi-1.2.0.jar deleted file mode 100644 index 07507db9036188d075447c1a27baec3504159784..0000000000000000000000000000000000000000 Binary files a/conformance/org.universaal.tools.conformanceTools/lib/mw.bus.ui.osgi-1.2.0.jar and /dev/null differ diff --git a/conformance/org.universaal.tools.conformanceTools/lib/plexus-utils-3.0.jar b/conformance/org.universaal.tools.conformanceTools/lib/plexus-utils-3.0.jar new file mode 100644 index 0000000000000000000000000000000000000000..aaa2a5963e9afc60c6ba9c9e55742c59497639af Binary files /dev/null and b/conformance/org.universaal.tools.conformanceTools/lib/plexus-utils-3.0.jar differ diff --git a/conformance/org.universaal.tools.conformanceTools/plugin.xml b/conformance/org.universaal.tools.conformanceTools/plugin.xml index a2ab84a6e209a1cd7c04c8f0bcccde45d0a8e1d4..323aff2468065eadc8dfaaa474876b9777cf704e 100644 --- a/conformance/org.universaal.tools.conformanceTools/plugin.xml +++ b/conformance/org.universaal.tools.conformanceTools/plugin.xml @@ -18,9 +18,8 @@ <handler commandId="org.universaal.tools.conformanceTools.commands.ConformanceToolsRun" class="org.universaal.tools.conformanceTools.handlers.ConformanceToolsHandler"> - <enabledWhen> - <with - variable="selection"> + <!--<enabledWhen> + <with variable="selection"> <iterate ifEmpty="false" operator="or"> @@ -31,7 +30,7 @@ </iterate> <count value="1" /> </with> - </enabledWhen> + </enabledWhen>--> </handler> </extension> diff --git a/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformance/filecheck/plugin/handler/FileCheckHandler.java b/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformance/filecheck/plugin/handler/FileCheckHandler.java index bd18ea5e80dace7b2990a3d59163e363c7571811..7ca52b22e00a4ed8800acff75aa68c3272a95514 100644 --- a/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformance/filecheck/plugin/handler/FileCheckHandler.java +++ b/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformance/filecheck/plugin/handler/FileCheckHandler.java @@ -12,12 +12,12 @@ import javax.xml.parsers.ParserConfigurationException; import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IProject; -import org.eclipse.jdt.internal.core.JavaProject; +import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.dialogs.ContainerSelectionDialog; import org.eclipse.ui.handlers.HandlerUtil; import org.universaal.tools.conformanceTools.run.BugDescriptor; import org.w3c.dom.Document; @@ -44,43 +44,41 @@ public class FileCheckHandler extends AbstractHandler { @Override public Object execute(ExecutionEvent event) throws ExecutionException { - // First retrieve current selection and check if its 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 check - //IProject prj; - if (selected instanceof JavaProject) { - // if you select them from pkg explorer they are JavaProjects - prj = ((JavaProject) selected).getProject(); - } else if (selected instanceof IProject) { - // if you select them from project explorer they are IProjects - prj = ((IProject) selected); - } else { - MessageDialog.openInformation(window.getShell(), "FileCheck", - "Selection is not a valid project."); - return null; - } + + Shell shell = HandlerUtil.getActiveWorkbenchWindowChecked(event).getShell(); - // Main task - check files - // TODO: do this inside a job - // String report = check(prj); - //@Manlio: VVVV This is where the test execution is invoked. Forget about anything else. - checkFORPLUGIN(prj); - //String report = checkFORPLUGIN(prj).toString(); - // // TODO: Handle better the response - // MessageDialog.openInformation(window.getShell(), "FileCheck", - // report); + try{ + ContainerSelectionDialog dialog = new ContainerSelectionDialog(shell, + ResourcesPlugin.getWorkspace().getRoot(), true, "Select the project to analyze:"); + dialog.setTitle("Container Selection"); + dialog.open(); - } else { - MessageDialog.openInformation(window.getShell(), "FileCheck", - "No selection was made."); + if(dialog.getResult() != null && dialog.getResult().length > 0 && dialog.getResult()[0] != null){ + IContainer container = ResourcesPlugin.getWorkspace().getRoot().getProject(dialog.getResult()[0].toString()); + prj = container.getProject(); + } + else{ + MessageDialog.openInformation(shell, "uAAL Conformance Tools", "Please make a valid selection."); + return null; + } } + catch(Exception ex){ + ex.printStackTrace(); + } + // Main task - check files + // TODO: do this inside a job + // String report = check(prj); + //@Manlio: VVVV This is where the test execution is invoked. Forget about anything else. + checkFORPLUGIN(prj); + //String report = checkFORPLUGIN(prj).toString(); + // // TODO: Handle better the response + // MessageDialog.openInformation(window.getShell(), "FileCheck", + // report); + + // } else { + // MessageDialog.openInformation(window.getShell(), "FileCheck", + // "No selection was made."); + // } return null; } diff --git a/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/checks/api/uaalDirectives.java b/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/checks/api/uaalDirectives.java new file mode 100644 index 0000000000000000000000000000000000000000..acc8f06f1108563a9d39a6dca69918bd022bc3cd --- /dev/null +++ b/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/checks/api/uaalDirectives.java @@ -0,0 +1,7 @@ +package org.universaal.tools.conformanceTools.checks.api; + +public enum uaalDirectives { + + decouple, dependency, license, modules, name, parent, svn//, tag + +} \ No newline at end of file diff --git a/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/run/AALDirectivesMavenPlugin.java b/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/run/AALDirectivesMavenPlugin.java index 3598aaee9836ce8221db2e3e617f16eb59bb3201..b2e3f9322895d2036a740954ab62e69fff44a62b 100644 --- a/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/run/AALDirectivesMavenPlugin.java +++ b/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/run/AALDirectivesMavenPlugin.java @@ -14,6 +14,7 @@ import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginExecution; import org.apache.maven.model.ReportPlugin; import org.apache.maven.model.Reporting; +import org.codehaus.plexus.util.xml.Xpp3Dom; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IWorkspace; @@ -24,6 +25,7 @@ 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.universaal.tools.conformanceTools.checks.api.uaalDirectives; import org.universaal.tools.conformanceTools.utils.POMeditor; public class AALDirectivesMavenPlugin { @@ -44,11 +46,17 @@ public class AALDirectivesMavenPlugin { private final String DOXIA_PLUGIN_ARTIFACT_ID = "doxia-sink-api"; private final String DOXIA_PLUGIN_VERSION = "1.3"; + private List<String> goals; + public AALDirectivesMavenPlugin(IProject project){ this.p = project; this.pom = new File(project.getFile("pom.xml").getLocation()+""); pomEditor = new POMeditor(this.pom); + + goals = new ArrayList<String>(); + for(int i = 0; i < uaalDirectives.values().length; i++) + goals.add(uaalDirectives.values()[i]+"-check"); } public List<Throwable> executeTests(){ @@ -59,10 +67,16 @@ public class AALDirectivesMavenPlugin { if(verifyAALDMPinPOMfile()){ output = runTest(); if(output != null) - for(int i = 0; i < output.size(); i++) - System.out.println("**\ngetLocalizedMessage: "+output.get(i).getLocalizedMessage()+ - " \ngetMessage: "+output.get(i).getMessage()+ - " \ngetCause: "+output.get(i).getCause()); + for(int i = 0; i < output.size(); i++){ + try{ + System.out.println("**\ngetLocalizedMessage: "+output.get(i).getLocalizedMessage()+ + " \ngetMessage: "+output.get(i).getMessage()+ + " \ngetCause: "+output.get(i).getCause()); + } + catch(Exception ex){ + ex.printStackTrace(); + } + } } } catch(Exception ex){ @@ -72,88 +86,140 @@ public class AALDirectivesMavenPlugin { return output; } + /* + * <parent> + <groupId>org.universAAL.support</groupId> + <artifactId>support.pom</artifactId> + <version>1.3.1-SNAPSHOT</version> + <relativePath>../pom/</relativePath> + </parent> + */ + + private final String PARENT_POM_GID = "org.universAAL.support"; + private final String PARENT_POM_AID = "support.pom"; + private final String PARENT_POM_VERSION = "1.3.1-SNAPSHOT"; + private boolean verifyAALDMPinPOMfile(){ try{ boolean plugin_bool = false, dependency_bool = false, reporting = false; Model pomC = pomEditor.getPomContent(); - if(pomC.getParent() != null){ - if(!pomC.getParent().getGroupId().equalsIgnoreCase(UAAL_GID) || - !pomC.getParent().getArtifactId().equalsIgnoreCase(UAAL_AID)) - System.out.println("[WARNING] Selected project has a different PARENT declaration in POM file than "+UAAL_GID+"/"+UAAL_AID); - } - else{ - System.out.println("[WARNING] Selected project has not PARENT declaration in POM file equal to "+UAAL_GID+"/"+UAAL_AID); - } - if(pomC.getBuild() != null){ - if(pomC.getBuild().getPlugins() != null){ - for(int i = 0; i < pomC.getBuild().getPlugins().size(); i++){ - if(pomC.getBuild().getPlugins().get(i).getArtifactId().equalsIgnoreCase(UAAL_PLUGIN_ARTIFACT_ID)){ + if(pomC != null){ + if(pomC.getParent() != null){ + if(!pomC.getParent().getGroupId().equalsIgnoreCase(PARENT_POM_GID) || + !pomC.getParent().getArtifactId().equalsIgnoreCase(PARENT_POM_AID)) + System.out.println("[ERROR] Selected project has a different PARENT declaration in POM file than "+PARENT_POM_GID+"/"+PARENT_POM_AID); + } + else + System.out.println("[ERROR] Selected project has not PARENT declaration in POM file equal to "+PARENT_POM_GID+"/"+PARENT_POM_AID); + + if(pomC.getBuild() != null){ + if(pomC.getBuild().getPlugins() != null){ + for(int i = 0; i < pomC.getBuild().getPlugins().size(); i++){ + if(pomC.getBuild().getPlugins().get(i).getArtifactId().equalsIgnoreCase(UAAL_PLUGIN_ARTIFACT_ID)){ - plugin_bool = true; + plugin_bool = true; - if(pomC.getBuild().getPlugins().get(i).getDependencies() != null){ - for(int j = 0; j < pomC.getBuild().getPlugins().get(i).getDependencies().size(); j++){ - if(pomC.getBuild().getPlugins().get(i).getDependencies().get(j).getArtifactId().equalsIgnoreCase(DOXIA_PLUGIN_ARTIFACT_ID)){ + if(pomC.getBuild().getPlugins().get(i).getDependencies() != null){ + for(int j = 0; j < pomC.getBuild().getPlugins().get(i).getDependencies().size(); j++){ + if(pomC.getBuild().getPlugins().get(i).getDependencies().get(j).getArtifactId().equalsIgnoreCase(DOXIA_PLUGIN_ARTIFACT_ID)){ - dependency_bool = true; - } - } + dependency_bool = true; + } + } + } } } } - } - if(pomC.getReporting() != null){ - for(int i = 0; i < pomC.getReporting().getPlugins().size(); i++){ - if(pomC.getReporting().getPlugins().get(i).getArtifactId().equalsIgnoreCase(UAAL_PLUGIN_ARTIFACT_ID)) - reporting = true; + if(pomC.getReporting() != null){ + for(int i = 0; i < pomC.getReporting().getPlugins().size(); i++){ + if(pomC.getReporting().getPlugins().get(i).getArtifactId().equalsIgnoreCase(UAAL_PLUGIN_ARTIFACT_ID)) + reporting = true; + } } } - } - if(!plugin_bool){ + if(!plugin_bool){ - Plugin pl = new Plugin(); - pl.setArtifactId(UAAL_PLUGIN_ARTIFACT_ID); - pl.setGroupId(UAAL_PLUGIN_GROUP_ID); - pl.setVersion(UAAL_PLUGIN_VERSION); - pomC.getBuild().getPlugins().add(pl); + Plugin pl = new Plugin(); + pl.setArtifactId(UAAL_PLUGIN_ARTIFACT_ID); + pl.setGroupId(UAAL_PLUGIN_GROUP_ID); + pl.setVersion(UAAL_PLUGIN_VERSION); + pomC.getBuild().getPlugins().add(pl); - } - if(!dependency_bool){ - // doxia-sink-api dependency not found - Dependency d = new Dependency(); - d.setArtifactId(DOXIA_PLUGIN_ARTIFACT_ID); - d.setGroupId(DOXIA_PLUGIN_GROUP_ID); - d.setVersion(DOXIA_PLUGIN_VERSION); - for(int i = 0; i < pomC.getBuild().getPlugins().size(); i++){ + } + if(!dependency_bool){ + // doxia-sink-api dependency not found + Dependency d = new Dependency(); + d.setArtifactId(DOXIA_PLUGIN_ARTIFACT_ID); + d.setGroupId(DOXIA_PLUGIN_GROUP_ID); + d.setVersion(DOXIA_PLUGIN_VERSION); + for(int i = 0; i < pomC.getBuild().getPlugins().size(); i++){ + if(pomC.getBuild().getPlugins().get(i).getArtifactId().equalsIgnoreCase(UAAL_PLUGIN_ARTIFACT_ID)){ + pomC.getBuild().getPlugins().get(i).addDependency(d); + System.out.println(DOXIA_PLUGIN_ARTIFACT_ID+" dependency added!"); + } + } + } + if(!reporting){ + ReportPlugin rp = new ReportPlugin(); + rp.setArtifactId(UAAL_PLUGIN_ARTIFACT_ID); + rp.setGroupId(UAAL_PLUGIN_GROUP_ID); + rp.setVersion(UAAL_PLUGIN_VERSION); + pomC.setReporting(new Reporting()); + pomC.getReporting().addPlugin(rp); + } + + for(int i = 0; i < pomC.getBuild().getPlugins().size(); i++) if(pomC.getBuild().getPlugins().get(i).getArtifactId().equalsIgnoreCase(UAAL_PLUGIN_ARTIFACT_ID)){ - pomC.getBuild().getPlugins().get(i).addDependency(d); - System.out.println(DOXIA_PLUGIN_ARTIFACT_ID+" dependency added!"); - } - } - } - if(!reporting){ - ReportPlugin rp = new ReportPlugin(); - rp.setArtifactId(UAAL_PLUGIN_ARTIFACT_ID); - rp.setGroupId(UAAL_PLUGIN_GROUP_ID); - rp.setVersion(UAAL_PLUGIN_VERSION); - pomC.setReporting(new Reporting()); - pomC.getReporting().addPlugin(rp); - } - for(int i = 0; i < pomC.getBuild().getPlugins().size(); i++) - if(pomC.getBuild().getPlugins().get(i).getArtifactId().equalsIgnoreCase(UAAL_PLUGIN_ARTIFACT_ID)){ - PluginExecution pex = new PluginExecution(); - pex.addGoal("check"); - pex.setId("CT tool"); - pex.setPhase("verify"); - pex.setInherited(false); - pomC.getBuild().getPlugins().get(i).addExecution(pex); + PluginExecution pex; + pex = new PluginExecution(); + for(int k = 0; k < goals.size(); k++){ + pex.addGoal(goals.get(k)); + } + + Xpp3Dom configuration = new Xpp3Dom("configuration"); + Xpp3Dom failOnMissMatch = new Xpp3Dom("failOnMissMatch"); + failOnMissMatch.setValue("false"); + configuration.addChild(failOnMissMatch); + pex.setConfiguration(configuration); + + pex.setId("CT - uAAL checks"); + pex.setPhase("verify"); + pex.setInherited(false); + + if(pomC.getBuild().getPlugins().get(i).getExecutions() != null){ + for(int j = 0; j < pomC.getBuild().getPlugins().get(i).getExecutions().size(); j++){ + if(pomC.getBuild().getPlugins().get(i).getExecutions().get(j).getId().equalsIgnoreCase(pex.getId())){ + pomC.getBuild().getPlugins().get(i).getExecutions().remove(j); + break; + } + } + } + pomC.getBuild().getPlugins().get(i).addExecution(pex); + + pex = new PluginExecution(); + pex.addGoal("site"); + pex.setId("CT - uAAL checks - site"); + pex.setPhase("site"); + pex.setInherited(false); + + if(pomC.getBuild().getPlugins().get(i).getExecutions() != null){ + for(int j = 0; j < pomC.getBuild().getPlugins().get(i).getExecutions().size(); j++){ + if(pomC.getBuild().getPlugins().get(i).getExecutions().get(j).getId().equalsIgnoreCase(pex.getId())){ + pomC.getBuild().getPlugins().get(i).getExecutions().remove(j); + break; + } + } + } + pomC.getBuild().getPlugins().get(i).addExecution(pex); - return true; - } + pomEditor.writePom(pomC); + return true; + } + } } catch(Exception ex){ ex.printStackTrace(); @@ -180,8 +246,6 @@ public class AALDirectivesMavenPlugin { IWorkspaceDescription description = workspace.getDescription(); if (!description.isAutoBuilding()) goals.add("compiler:compile"); // compile it if autobuilding is off - - //goals.add("install"); goals.add("verify"); request.setGoals(goals); diff --git a/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/run/ToolsRun.java b/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/run/ToolsRun.java index 7c1a122706fd2ee45ed70b27f2adbf632038ad85..472666682e0d79f357bc1aeeab19a22fda352df0 100644 --- a/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/run/ToolsRun.java +++ b/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/run/ToolsRun.java @@ -1,6 +1,8 @@ package org.universaal.tools.conformanceTools.run; +import java.io.ByteArrayOutputStream; import java.io.File; +import java.io.PrintStream; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -15,6 +17,7 @@ import org.apache.maven.execution.MavenExecutionResult; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.filesystem.EFS; +import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IProject; @@ -28,10 +31,8 @@ import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jdt.core.ICompilationUnit; -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; @@ -39,17 +40,13 @@ import org.eclipse.m2e.core.project.IMavenProjectFacade; import org.eclipse.m2e.core.project.IMavenProjectRegistry; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PartInitException; +import org.eclipse.ui.dialogs.ContainerSelectionDialog; import org.eclipse.ui.ide.IDE; import org.osgi.framework.Bundle; import org.universaal.tools.conformance.filecheck.plugin.handler.FileCheckHandler; import org.universaal.tools.conformanceTools.Activator; import org.universaal.tools.conformanceTools.checks.api.CheckImpl; -import org.universaal.tools.conformanceTools.checks.impl.ActivatorCheck; -import org.universaal.tools.conformanceTools.checks.impl.Maven_nature; -import org.universaal.tools.conformanceTools.checks.impl.NameGroupID; -import org.universaal.tools.conformanceTools.checks.impl.OSGI_bundle; -import org.universaal.tools.conformanceTools.checks.impl.POM_file; -import org.universaal.tools.conformanceTools.checks.impl.UICallerImpl; +import org.universaal.tools.conformanceTools.checks.api.uaalDirectives; import org.universaal.tools.conformanceTools.markers.CTMarker; import org.universaal.tools.conformanceTools.markers.Markers; import org.universaal.tools.conformanceTools.utils.HtmlPage; @@ -99,28 +96,28 @@ public class ToolsRun { this.window = window; - this.selection = window.getSelectionService().getSelection("org.eclipse.jdt.ui.PackageExplorer"); - if(this.selection == null)//{ - this.selection = window.getSelectionService().getSelection("org.eclipse.ui.navigator.ProjectExplorer"); - // System.out.println("uAAL CT - using selection from Project Explorer."); - // } - // else - // System.out.println("uAAL CT - using selection from Package Explorer."); - - if ((selection != null) && (selection instanceof StructuredSelection)) { - - Object selected = ((StructuredSelection) selection).getFirstElement(); + try{ + ContainerSelectionDialog dialog = new ContainerSelectionDialog(window.getShell(), ResourcesPlugin.getWorkspace().getRoot(), true, "Select the project to analyze:"); + dialog.setTitle("Container Selection"); + dialog.open(); - if (selected instanceof JavaProject) - this.projectToAnalyze = ((JavaProject) selected).getProject(); - else if (selected instanceof IProject) - this.projectToAnalyze = ((IProject) selected); - else { + if(dialog.getResult() != null && dialog.getResult().length > 0 && dialog.getResult()[0] != null){ + IContainer container = ResourcesPlugin.getWorkspace().getRoot().getProject(dialog.getResult()[0].toString()); + this.projectToAnalyze = container.getProject(); + } + else{ MessageDialog.openInformation(window.getShell(), - "uAAL Conformance Tools", "the selection is not a project or is broken."); + "uAAL Conformance Tools", "Please make a valid selection."); return; } + } + catch(Exception ex){ + ex.printStackTrace(); + } + + if((this.projectToAnalyze != null)) { + try{ verifyImages(); @@ -131,20 +128,24 @@ public class ToolsRun { if(plugin == RunPlugin.CustomChecks){ - // AALDirectivesMavenPlugin tests = new AALDirectivesMavenPlugin(this.projectToAnalyze); - // List<Throwable> results = tests.executeTests(); + AALDirectivesMavenPlugin tests = new AALDirectivesMavenPlugin(this.projectToAnalyze); + List<Throwable> results = tests.executeTests(); - List<String> checks = new ArrayList<String>(); - checks.add(ActivatorCheck.class.getName()); - checks.add(Maven_nature.class.getName()); - checks.add(NameGroupID.class.getName()); - checks.add(OSGI_bundle.class.getName()); - checks.add(POM_file.class.getName()); + // List<String> checks = new ArrayList<String>(); + // checks.add(ActivatorCheck.class.getName()); + // checks.add(Maven_nature.class.getName()); + // checks.add(NameGroupID.class.getName()); + // checks.add(OSGI_bundle.class.getName()); + // checks.add(POM_file.class.getName()); // TODO checks.add(UICallerImpl.class.getName()); - List<Result> results = test(checks); - visualizeResultsCC(results); - //visualizeResultsAALDirectives(results); + // List<Result> results = test(checks); + // visualizeResultsCC(results); + if(results != null) + visualizeResultsAALDirectives(results); + else + MessageDialog.openInformation(window.getShell(), + "uAAL Conformance Tools", "No results to show. Have you selected a valid universAAL project?"); } } catch(Exception ex){ ex.printStackTrace(); } @@ -677,36 +678,32 @@ public class ToolsRun { private void visualizeResultsAALDirectives(List<Throwable> results){ try{ - HtmlPage page = new HtmlPage("uAAL CONFORMANCE TOOLS - Test results from AAL Directives Maven Plugin"); - //String path_ = ResourcesPlugin.getWorkspace().getRoot().getLocation().makeAbsolute()+"/"+projectToAnalyze.getDescription().getName()+"/target/site/images/logos/"; - - Table t = page.new Table(results.size()+2, 4); + HtmlPage page = new HtmlPage("uAAL CONFORMANCE TOOLS - Test results using AAL Directives Maven Plugin"); + Table t = page.new Table(results.size()+1, 2); // table header t.addContentCentered("<font size='5'><b>TEST RESULT</b></font>", 0, 0); - //t.addContentCentered("<font size='5'><b>TEST NAME</b></font>", 0, 1); - t.addContentCentered("<font size='5'><b>TEST DETAILS</b></font>", 0, 2); - //t.addContentCentered("<font size='5'><b>RESULT DESCRIPTION</b></font>", 0, 3); + t.addContentCentered("<font size='5'><b>TEST DETAILS</b></font>", 0, 1); for(int i = 0; i < results.size(); i++){ Throwable check = results.get(i); - // t.addContentCentered("<img src='"+path_+check.getResultImg()+"' />", i+1, 0); - // t.addContentCentered(check.getCheckName(), i+1, 1); - // t.addContentCentered(check.getCheckDescription(), i+1, 2); - // t.addContentCentered(check.getResultDscr(), i+1, 3); t.addContentCentered(check.getLocalizedMessage(), i+1, 0); - //t.addContentCentered(check.getCause().getMessage(), i+1, 1); - if(check.getStackTrace() != null) - t.addContentCentered(check.getStackTrace().toString(), i+1, 2); + if(check.getStackTrace() != null && results.size() != 1){ + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + PrintStream ps = new PrintStream(baos); + check.printStackTrace(ps); + String content = baos.toString("UTF-8"); + t.addContentCentered(content, i+1, 1); + } else - t.addContentCentered("No details.", i+1, 2); - // check.getCause(); - // check.getLocalizedMessage(); - // check.getStackTrace(); + t.addContentCentered("No details.", i+1, 1); } page.getBody().addElement(t.getTable()); - page.getBody().addElement("<br/><br/><p>Total: 9/*"+results.size()+"*/ performed test(s).</p>"); + page.getBody().addElement("<br/><br/><p>Total: "+uaalDirectives.values().length+" performed test(s).</p>"); + for(int i = 0; i < uaalDirectives.values().length; i++) + page.getBody().addElement("<p style='padding-left: 10px; font-size: 13; color: green;'>Test "+(i+1)+": "+uaalDirectives.values()[i]+"-check</p>"); + page.getBody().addElement("<p>Please refer to <a href='http://depot.universaal.org/hudson/job/support/org.universAAL.support$uaalDirectives-maven-plugin/ws/target/site/plugin-info.html'>plugin official page</a> for documentation.</p>"); String filePath = ResourcesPlugin.getWorkspace().getRoot().getLocation().makeAbsolute()+"/"+projectToAnalyze.getDescription().getName()+"/target/site/"+fileNameResults; File file = new File(filePath); page.write(file); diff --git a/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/utils/POMeditor.java b/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/utils/POMeditor.java index cdaabfaa0bfedcd4460d2591cebe1fe0ea95dfe0..99d34811260e63d68dc212ab54e670b2baa5e372 100644 --- a/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/utils/POMeditor.java +++ b/conformance/org.universaal.tools.conformanceTools/src/org/universaal/tools/conformanceTools/utils/POMeditor.java @@ -1,6 +1,7 @@ package org.universaal.tools.conformanceTools.utils; import java.io.File; +import java.io.FileOutputStream; import java.io.FileReader; import java.io.Reader; @@ -13,6 +14,7 @@ import javax.xml.transform.stream.StreamResult; import org.apache.maven.model.Model; import org.apache.maven.model.io.xpp3.MavenXpp3Reader; +import org.apache.maven.model.io.xpp3.MavenXpp3Writer; import org.w3c.dom.Document; public class POMeditor { @@ -49,45 +51,16 @@ public class POMeditor { return null; } - // public INSERT_OUTPUT insertNode(Element father, Element child){ - // - // try{ - // DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); - // DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder(); - // Document parsedPom = docBuilder.parse(pom); - // parsedPom.getDocumentElement().normalize(); - // - // // NodeList fathers = parsedPom.getElementsByTagName(father.getNodeName()); - // // if(fathers.getLength() == 0) - // // return INSERT_OUTPUT.FATHER_NOT_FOUND; - // // else if(fathers.getLength() > 1) - // // return INSERT_OUTPUT.TOO_MANY_FATHERS; - // // else{ - // // // ok - // - // for(int i = 0; i < parsedPom.getDocumentElement().getChildNodes().getLength(); i++){ - // if(parsedPom.getDocumentElement().getChildNodes().item(i).isEqualNode(father)){ - // parsedPom.getDocumentElement().getChildNodes().item(i).appendChild(child); - // break; - // } - // } - // - // // write the content into xml file - // TransformerFactory transformerFactory = TransformerFactory.newInstance(); - // Transformer transformer = transformerFactory.newTransformer(); - // DOMSource source = new DOMSource(parsedPom); - // StreamResult result = new StreamResult(pom); - // transformer.transform(source, result); - // - // return INSERT_OUTPUT.SUCCESS; - // //} - // } - // catch(Exception ex){ - // ex.printStackTrace(); - // } - // - // return INSERT_OUTPUT.FAILED; - // } + public void writePom(Model model){ + + try { + MavenXpp3Writer writer = new MavenXpp3Writer(); + writer.write(new FileOutputStream(this.pom), model); + } + catch(Exception e) { + e.printStackTrace(); + } + } public INSERT_OUTPUT insertNode(String nodeName){