Revision: 19239
          http://sourceforge.net/p/gate/code/19239
Author:   markagreenwood
Date:     2016-04-13 17:28:56 +0000 (Wed, 13 Apr 2016)
Log Message:
-----------
two new maven projects for the test utils and the parent pom for developing new 
plugins

Added Paths:
-----------
    gate/branches/sawdust2/build/Plugin_Base/
    gate/branches/sawdust2/build/Plugin_Base/.classpath
    gate/branches/sawdust2/build/Plugin_Base/.project
    gate/branches/sawdust2/build/Plugin_Base/pom.xml
    gate/branches/sawdust2/build/Test-Utils/
    gate/branches/sawdust2/build/Test-Utils/.classpath
    gate/branches/sawdust2/build/Test-Utils/.project
    gate/branches/sawdust2/build/Test-Utils/pom.xml
    gate/branches/sawdust2/build/Test-Utils/src/
    gate/branches/sawdust2/build/Test-Utils/src/main/
    gate/branches/sawdust2/build/Test-Utils/src/main/java/
    gate/branches/sawdust2/build/Test-Utils/src/main/java/gate/
    gate/branches/sawdust2/build/Test-Utils/src/main/java/gate/test/
    
gate/branches/sawdust2/build/Test-Utils/src/main/java/gate/test/GATEPluginTestCase.java
    gate/branches/sawdust2/build/Test-Utils/src/main/resources/
    gate/branches/sawdust2/build/Test-Utils/src/test/
    gate/branches/sawdust2/build/Test-Utils/src/test/java/
    gate/branches/sawdust2/build/Test-Utils/src/test/resources/

Added: gate/branches/sawdust2/build/Plugin_Base/.classpath
===================================================================
--- gate/branches/sawdust2/build/Plugin_Base/.classpath                         
(rev 0)
+++ gate/branches/sawdust2/build/Plugin_Base/.classpath 2016-04-13 17:28:56 UTC 
(rev 19239)
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="src" output="target/classes" path="src/main/java">
+               <attributes>
+                       <attribute name="optional" value="true"/>
+                       <attribute name="maven.pomderived" value="true"/>
+               </attributes>
+       </classpathentry>
+       <classpathentry kind="src" output="target/test-classes" 
path="src/test/java">
+               <attributes>
+                       <attribute name="optional" value="true"/>
+                       <attribute name="maven.pomderived" value="true"/>
+               </attributes>
+       </classpathentry>
+       <classpathentry kind="con" 
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
+               <attributes>
+                       <attribute name="maven.pomderived" value="true"/>
+               </attributes>
+       </classpathentry>
+       <classpathentry kind="con" 
path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
+               <attributes>
+                       <attribute name="maven.pomderived" value="true"/>
+               </attributes>
+       </classpathentry>
+       <classpathentry kind="output" path="target/classes"/>
+</classpath>

Added: gate/branches/sawdust2/build/Plugin_Base/.project
===================================================================
--- gate/branches/sawdust2/build/Plugin_Base/.project                           
(rev 0)
+++ gate/branches/sawdust2/build/Plugin_Base/.project   2016-04-13 17:28:56 UTC 
(rev 19239)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>GATE-plugin-Plugin_Base</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.m2e.core.maven2Builder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+               <nature>org.eclipse.m2e.core.maven2Nature</nature>
+       </natures>
+</projectDescription>

Added: gate/branches/sawdust2/build/Plugin_Base/pom.xml
===================================================================
--- gate/branches/sawdust2/build/Plugin_Base/pom.xml                            
(rev 0)
+++ gate/branches/sawdust2/build/Plugin_Base/pom.xml    2016-04-13 17:28:56 UTC 
(rev 19239)
@@ -0,0 +1,141 @@
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+
+       <properties>
+               <maven.compiler.source>1.8</maven.compiler.source>
+               <maven.compiler.target>1.8</maven.compiler.target>
+               
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+       </properties>
+       
+       <modelVersion>4.0.0</modelVersion>
+       <groupId>uk.ac.gate.plugins</groupId>
+       <artifactId>base-plugin</artifactId>
+       <version>9.0-SNAPSHOT</version>
+       <packaging>pom</packaging>
+
+       <dependencies>
+               <dependency>
+                       <groupId>uk.ac.gate</groupId>
+                       <artifactId>gate-core</artifactId>
+                       <version>9.0-SNAPSHOT</version>
+                       <scope>provided</scope>
+               </dependency>
+
+               <dependency>
+                       <groupId>uk.ac.gate</groupId>
+                       <artifactId>test-utils</artifactId>
+                       <version>9.0-SNAPSHOT</version>
+                       <scope>test</scope>
+               </dependency>
+
+       </dependencies>
+
+       <repositories>
+               <repository>
+                       <id>gate.ac.uk</id>
+                       <name>GATE Development Repository</name>
+                       <url>http://repo.gate.ac.uk/content/groups/public/</url>
+               </repository>
+       </repositories>
+
+       <build>
+               <testResources>
+                       <!-- this adds the maven coordinates into the test 
resource file creole.properties 
+                               which is used to help load this plugin for 
testing -->
+                       <testResource>
+                               <directory>src/test/resources</directory>
+                               <filtering>true</filtering>
+                               <includes>
+                                       <include>creole.properties</include>
+                               </includes>
+                       </testResource>
+
+                       <!-- copy all the other resources without altering them 
so we don't accidentally 
+                               corrupt datastores or other binary formats -->
+                       <testResource>
+                               <directory>src/test/resources</directory>
+                               <filtering>false</filtering>
+                               <excludes>
+                                       <exclude>creole.properties</exclude>
+                               </excludes>
+                       </testResource>
+               </testResources>
+
+               <plugins>
+                       <plugin>
+                               <groupId>org.jacoco</groupId>
+                               <artifactId>jacoco-maven-plugin</artifactId>
+                               <version>0.7.6.201602180812</version>
+                               <executions>
+                                       <execution>
+                                               <id>default-prepare-agent</id>
+                                               <goals>
+                                                       
<goal>prepare-agent</goal>
+                                               </goals>
+                                       </execution>
+                                       <execution>
+                                               <id>default-report</id>
+                                               <phase>prepare-package</phase>
+                                               <goals>
+                                                       <goal>report</goal>
+                                               </goals>
+                                       </execution>
+                               </executions>
+                       </plugin>
+               </plugins>
+       </build>
+
+       <reporting>
+               <plugins>
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               
<artifactId>maven-surefire-report-plugin</artifactId>
+                               <version>2.19.1</version>
+                       </plugin>
+                       <plugin>
+                               <groupId>org.codehaus.mojo</groupId>
+                               <artifactId>findbugs-maven-plugin</artifactId>
+                               <version>3.0.3</version>
+                               <configuration>
+                                       <xmlOutput>true</xmlOutput>
+                                       <effort>Max</effort>
+                                       <threshold>Low</threshold>
+                               </configuration>
+                       </plugin>
+                       <plugin>
+                               <groupId>org.jacoco</groupId>
+                               <artifactId>jacoco-maven-plugin</artifactId>
+                               <version>0.7.6.201602180812</version>
+                               <configuration>
+                                       <excludes>
+                                               <!-- this excludes known GUI 
code from the code coverage results as 
+                                                       we know we aren't 
testing them so will likely have a 0% coverage -->
+                                               <exclude>**/gui/**/*</exclude>
+                                               <exclude>**/swing/**/*</exclude>
+                                       </excludes>
+                               </configuration>
+                       </plugin>
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               
<artifactId>maven-project-info-reports-plugin</artifactId>
+                               <version>2.9</version>
+                               <configuration>
+                                       
<dependencyLocationsEnabled>false</dependencyLocationsEnabled>
+                                       <systemPropertyVariables>
+                                               
<jacoco-agent.destfile>target/jacoco.exec</jacoco-agent.destfile>
+                                       </systemPropertyVariables>
+                               </configuration>
+                       </plugin>
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-javadoc-plugin</artifactId>
+                               <version>2.9.1</version>
+                               <configuration>
+                                       <failOnError>false</failOnError>
+                               </configuration>
+                       </plugin>
+               </plugins>
+       </reporting>
+
+</project>
\ No newline at end of file

Added: gate/branches/sawdust2/build/Test-Utils/.classpath
===================================================================
--- gate/branches/sawdust2/build/Test-Utils/.classpath                          
(rev 0)
+++ gate/branches/sawdust2/build/Test-Utils/.classpath  2016-04-13 17:28:56 UTC 
(rev 19239)
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="src" output="target/classes" path="src/main/java">
+               <attributes>
+                       <attribute name="optional" value="true"/>
+                       <attribute name="maven.pomderived" value="true"/>
+               </attributes>
+       </classpathentry>
+       <classpathentry excluding="**" kind="src" output="target/classes" 
path="src/main/resources">
+               <attributes>
+                       <attribute name="maven.pomderived" value="true"/>
+               </attributes>
+       </classpathentry>
+       <classpathentry kind="src" output="target/test-classes" 
path="src/test/java">
+               <attributes>
+                       <attribute name="optional" value="true"/>
+                       <attribute name="maven.pomderived" value="true"/>
+               </attributes>
+       </classpathentry>
+       <classpathentry excluding="**" kind="src" output="target/test-classes" 
path="src/test/resources">
+               <attributes>
+                       <attribute name="maven.pomderived" value="true"/>
+               </attributes>
+       </classpathentry>
+       <classpathentry kind="con" 
path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
+               <attributes>
+                       <attribute name="maven.pomderived" value="true"/>
+               </attributes>
+       </classpathentry>
+       <classpathentry kind="con" 
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
+               <attributes>
+                       <attribute name="maven.pomderived" value="true"/>
+               </attributes>
+       </classpathentry>
+       <classpathentry kind="output" path="target/classes"/>
+</classpath>

Added: gate/branches/sawdust2/build/Test-Utils/.project
===================================================================
--- gate/branches/sawdust2/build/Test-Utils/.project                            
(rev 0)
+++ gate/branches/sawdust2/build/Test-Utils/.project    2016-04-13 17:28:56 UTC 
(rev 19239)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>GATE-Test_Utils</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.m2e.core.maven2Builder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+               <nature>org.eclipse.m2e.core.maven2Nature</nature>
+       </natures>
+</projectDescription>

Added: gate/branches/sawdust2/build/Test-Utils/pom.xml
===================================================================
--- gate/branches/sawdust2/build/Test-Utils/pom.xml                             
(rev 0)
+++ gate/branches/sawdust2/build/Test-Utils/pom.xml     2016-04-13 17:28:56 UTC 
(rev 19239)
@@ -0,0 +1,42 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+       <modelVersion>4.0.0</modelVersion>
+       <groupId>uk.ac.gate</groupId>
+       <artifactId>test-utils</artifactId>
+       <version>9.0-SNAPSHOT</version>
+       
+       <licenses>
+               <license>
+                       <name>GNU Lesser General Public License (LGPL), Version 
3</name>
+                       <url>http://www.gnu.org/licenses/lgpl-3.0.txt</url>
+                       <distribution>repo</distribution>
+               </license>
+       </licenses>
+
+       <organization>
+               <name>GATE</name>
+               <url>http://gate.ac.uk</url>
+       </organization>
+
+       <dependencies>
+               <dependency>
+                       <groupId>uk.ac.gate</groupId>
+                       <artifactId>gate-core</artifactId>
+                       <version>9.0-SNAPSHOT</version>
+               </dependency>
+       </dependencies>
+       
+       <repositories>
+               <repository>
+                       <id>gate.ac.uk</id>
+                       <name>GATE Development Repository</name>
+                       <url>http://repo.gate.ac.uk/content/groups/public/</url>
+               </repository>
+       </repositories>
+
+       <properties>
+               <maven.compiler.source>1.8</maven.compiler.source>
+               <maven.compiler.target>1.8</maven.compiler.target>
+               
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+       </properties>
+</project>
\ No newline at end of file

Added: 
gate/branches/sawdust2/build/Test-Utils/src/main/java/gate/test/GATEPluginTestCase.java
===================================================================
--- 
gate/branches/sawdust2/build/Test-Utils/src/main/java/gate/test/GATEPluginTestCase.java
                             (rev 0)
+++ 
gate/branches/sawdust2/build/Test-Utils/src/main/java/gate/test/GATEPluginTestCase.java
     2016-04-13 17:28:56 UTC (rev 19239)
@@ -0,0 +1,120 @@
+package gate.test;
+
+import gate.Gate;
+import gate.Plugin;
+import gate.Gate.ResourceInfo;
+import gate.util.Files;
+import gate.util.asm.ClassReader;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.HashSet;
+import java.util.Properties;
+import java.util.Set;
+
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.input.SAXBuilder;
+
+import junit.framework.TestCase;
+
+public class GATEPluginTestCase extends TestCase {
+
+       @Override
+       public void setUp() throws Exception {
+
+               if (!Gate.isInitialised()) {
+                       Gate.runInSandbox(true);
+                       Gate.init();
+               }
+
+               URL url = this.getClass().getResource("/creole.xml");
+
+               Properties properties = new Properties();
+               
properties.load(this.getClass().getResource("/creole.properties")
+                               .openStream());
+
+               Plugin plugin = new PluginUnderTest(Files.fileFromURL(url),
+                               properties.getProperty("groupId"),
+                               properties.getProperty("artifactId"),
+                               properties.getProperty("version"));
+
+               if (!Gate.getCreoleRegister().getPlugins().contains(plugin)) {
+                       Gate.getCreoleRegister().registerPlugin(plugin);
+               }
+       }
+
+       class PluginUnderTest extends Plugin.Maven {
+
+               private File creoleFile;
+
+               public PluginUnderTest(File creoleFile, String group, String 
artifact,
+                               String version) throws MalformedURLException {
+                       super(group, artifact, version);
+                       this.creoleFile = creoleFile;
+                       this.baseURL = new URL(creoleFile.toURI().toURL(), ".");
+               }
+
+               @Override
+               public Document getCreoleXML() throws Exception {
+                       SAXBuilder builder = new SAXBuilder(false);
+
+                       Document jdomDoc = builder.build(new 
FileInputStream(creoleFile),
+                                       baseURL.toExternalForm());
+
+                       Element creoleRoot = jdomDoc.getRootElement();
+
+                       Set<String> resources = new HashSet<String>();
+
+                       String dir = creoleFile.getParent();
+                       if (!dir.endsWith(File.separator))
+                               dir = dir + File.separator;
+
+                       scanDir(dir.length(), creoleFile.getParentFile(), 
resources);
+
+                       for (String resource : resources) {
+                               Element resourceElement = new 
Element("RESOURCE");
+                               Element classElement = new Element("CLASS");
+                               classElement.setText(resource);
+                               resourceElement.addContent(classElement);
+                               creoleRoot.addContent(resourceElement);
+                       }
+
+                       return jdomDoc;
+               }
+
+               private void scanDir(int prefix, File dir, Set<String> 
resources)
+                               throws IOException {
+
+                       for (File file : dir.listFiles()) {
+                               if (file.isDirectory()) {
+                                       scanDir(prefix, file, resources);
+                               } else if (file.getName().endsWith((".class"))) 
{
+
+                                       String className = 
file.getAbsolutePath().substring(prefix);
+                                       className = className.substring(0, 
className.length() - 6)
+                                                       .replace('/', '.');
+
+                                       ClassReader classReader = new 
ClassReader(
+                                                       new 
FileInputStream(file));
+
+                                       ResourceInfo resInfo = new 
ResourceInfo(null, className,
+                                                       null);
+                                       ResourceInfoVisitor visitor = new 
ResourceInfoVisitor(
+                                                       resInfo);
+
+                                       classReader.accept(visitor, 
ClassReader.SKIP_CODE
+                                                       | 
ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES);
+                                       if (visitor.isCreoleResource()) {
+                                               resources.add(className);
+                                       }
+                               }
+                       }
+
+               }
+
+       }
+}

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs

Reply via email to