forked from phoedos/pmd
Release preps
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@1674 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@ -5,9 +5,9 @@ Addin0: net.sourceforge.pmd.jdeveloper.Plugin
|
||||
|
||||
Name: net/sourceforge/pmd/jdeveloper/
|
||||
Specification-Title: PMD Static Code Analyzer
|
||||
Specification-Version: 0.1
|
||||
Specification-Version: 0.2
|
||||
Specification-Vendor: Tom Copeland
|
||||
Implementation-Title: net.sourceforge.pmd.jdeveloper
|
||||
Implementation-Version: 0.1
|
||||
Implementation-Version: 0.2
|
||||
Implementation-Vendor: Tom Copeland
|
||||
Implementation-URL: http://pmd.sf.net/
|
@ -6,7 +6,7 @@
|
||||
<property name="etc" value="etc/"/>
|
||||
<property name="build" value="build/"/>
|
||||
<property name="pmdjar" value="pmd-1.04.jar"/>
|
||||
<property name="pluginversion" value="0.1"/>
|
||||
<property name="pluginversion" value="0.2"/>
|
||||
<property name="jdeveloper.install.dir" value="/home/tom/jdev/jdev/lib/ext/${ant.project.name}-${pluginversion}"/>
|
||||
|
||||
<path id="project.class.path">
|
||||
@ -45,12 +45,16 @@
|
||||
<mkdir dir="${jdeveloper.install.dir}/lib"/>
|
||||
<copy file="${lib}/${ant.project.name}-${pluginversion}.jar" todir="${jdeveloper.install.dir}/lib"/>
|
||||
<copy file="${lib}/${pmdjar}" todir="${jdeveloper.install.dir}/lib"/>
|
||||
<copy file="${lib}/saxpath-1.0-fcs.jar" todir="${jdeveloper.install.dir}/lib"/>
|
||||
<copy file="${lib}/jaxen-core-1.0-fcs.jar" todir="${jdeveloper.install.dir}/lib"/>
|
||||
</target>
|
||||
|
||||
<target name="release" depends="clean,jar">
|
||||
<mkdir dir="tmp/${ant.project.name}-${pluginversion}/lib"/>
|
||||
<copy file="${lib}/${ant.project.name}-${pluginversion}.jar" todir="tmp/${ant.project.name}-${pluginversion}/lib/"/>
|
||||
<copy file="${lib}/${pmdjar}" todir="tmp/${ant.project.name}-${pluginversion}/lib/"/>
|
||||
<copy file="${lib}/saxpath-1.0-fcs.jar" todir="tmp/${ant.project.name}-${pluginversion}/lib"/>
|
||||
<copy file="${lib}/jaxen-core-1.0-fcs.jar" todir="tmp/${ant.project.name}-${pluginversion}/lib"/>
|
||||
<zip zipfile="pmd-jdeveloper-bin-${pluginversion}.zip" basedir="tmp"/>
|
||||
<move file="pmd-jdeveloper-bin-${pluginversion}.zip" todir="/home/tom/tmp"/>
|
||||
<delete dir="tmp"/>
|
||||
|
@ -1,2 +1,6 @@
|
||||
April 1, 2003 - 0.2:
|
||||
Updated to work with pmd-1.04.
|
||||
Implemented several of Ronald Kinion's suggestions.
|
||||
|
||||
February 25, 2003 - 0.1:
|
||||
Initial release
|
||||
|
@ -4,8 +4,11 @@ import net.sourceforge.pmd.ExternalRuleID;
|
||||
import net.sourceforge.pmd.Rule;
|
||||
import net.sourceforge.pmd.RuleSet;
|
||||
import net.sourceforge.pmd.RuleSetFactory;
|
||||
import net.sourceforge.pmd.util.ResourceLoader;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
@ -14,26 +17,30 @@ import java.io.InputStream;
|
||||
public class JDeveloperRuleSetFactory extends RuleSetFactory {
|
||||
|
||||
public RuleSet createRuleSet(InputStream inputStream) {
|
||||
return this.createRuleSet(inputStream, getClass().getClassLoader());
|
||||
}
|
||||
|
||||
public RuleSet createRuleSet(InputStream inputStream, ClassLoader classLoader) {
|
||||
try {
|
||||
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
||||
org.w3c.dom.Document doc = builder.parse(inputStream);
|
||||
org.w3c.dom.Element root = doc.getDocumentElement();
|
||||
Document doc = builder.parse(inputStream);
|
||||
Element root = doc.getDocumentElement();
|
||||
|
||||
RuleSet ruleSet = new RuleSet();
|
||||
ruleSet.setName(root.getAttribute("name"));
|
||||
ruleSet.setDescription(root.getChildNodes().item(1).getFirstChild().getNodeValue());
|
||||
|
||||
NodeList rules = root.getElementsByTagName("rule");
|
||||
for (int i =0; i<rules.getLength(); i++) {
|
||||
for (int i = 0; i < rules.getLength(); i++) {
|
||||
Node ruleNode = rules.item(i);
|
||||
Rule rule = null;
|
||||
Rule rule;
|
||||
if (ruleNode.getAttributes().getNamedItem("ref") != null) {
|
||||
ExternalRuleID externalRuleID = new ExternalRuleID(ruleNode.getAttributes().getNamedItem("ref").getNodeValue());
|
||||
RuleSetFactory rsf = new RuleSetFactory();
|
||||
RuleSet externalRuleSet = rsf.createRuleSet(getClass().getClassLoader().getResourceAsStream(externalRuleID.getFilename()));
|
||||
RuleSet externalRuleSet = rsf.createRuleSet(ResourceLoader.loadResourceAsStream(externalRuleID.getFilename()));
|
||||
rule = externalRuleSet.getRuleByName(externalRuleID.getRuleName());
|
||||
} else {
|
||||
rule = (Rule)Class.forName(ruleNode.getAttributes().getNamedItem("class").getNodeValue()).newInstance();
|
||||
rule = (Rule) Class.forName(ruleNode.getAttributes().getNamedItem("class").getNodeValue(), true, classLoader).newInstance();
|
||||
rule.setName(ruleNode.getAttributes().getNamedItem("name").getNodeValue());
|
||||
rule.setMessage(ruleNode.getAttributes().getNamedItem("message").getNodeValue());
|
||||
}
|
||||
@ -44,16 +51,21 @@ public class JDeveloperRuleSetFactory extends RuleSetFactory {
|
||||
if (node.getNodeName() != null && node.getNodeName().equals("description")) {
|
||||
rule.setDescription(node.getFirstChild().getNodeValue());
|
||||
} else if (node.getNodeName() != null && node.getNodeName().equals("priority")) {
|
||||
rule.setPriority(Integer.parseInt(node.getFirstChild().getNodeValue()));
|
||||
rule.setPriority(Integer.parseInt(node.getFirstChild().getNodeValue().trim()));
|
||||
} else if (node.getNodeName() != null && node.getNodeName().equals("example")) {
|
||||
rule.setExample((node.getFirstChild().getNodeValue()));
|
||||
rule.setExample(node.getFirstChild().getNodeValue());
|
||||
}
|
||||
|
||||
if (node.getNodeName().equals("properties")) {
|
||||
Node propNode = node.getFirstChild().getNextSibling();
|
||||
while (propNode != null && propNode.getAttributes() != null) {
|
||||
String propName = propNode.getAttributes().getNamedItem("name").getNodeValue();
|
||||
String propValue = propNode.getAttributes().getNamedItem("value").getNodeValue();
|
||||
String propValue;
|
||||
if (propName.equals("xpath")) {
|
||||
Node xpathExprNode = propNode.getFirstChild().getNextSibling();
|
||||
propValue = xpathExprNode.getFirstChild().getNodeValue();
|
||||
} else {
|
||||
propValue = propNode.getAttributes().getNamedItem("value").getNodeValue();
|
||||
}
|
||||
rule.addProperty(propName, propValue);
|
||||
propNode = propNode.getNextSibling().getNextSibling();
|
||||
}
|
||||
@ -69,7 +81,4 @@ public class JDeveloperRuleSetFactory extends RuleSetFactory {
|
||||
throw new RuntimeException("Couldn't read from that source: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user