LUCENE-5360: Netbeans support: streamline XSLT stylesheet; add basic code style

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1550178 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Steven Rowe 2013-12-11 15:53:18 +00:00
parent bee606588d
commit 36fd83b0df
4 changed files with 164 additions and 273 deletions

View File

@ -193,32 +193,29 @@
<target name="netbeans" depends="resolve" description="Setup Netbeans configuration">
<pathconvert property="netbeans.fileset.sourcefolders" pathsep="|" dirsep="/">
<dirset dir="${basedir}/lucene" includes="**/src/java, **/src/examples" excludes="tools/**, build/**, backwards/**" />
<dirset dir="${basedir}/solr" includes="**/src/java, **/src/examples" excludes="build/**" />
<dirset dir="${basedir}/lucene" includes="**/src/java, **/src/examples, **/src/test, **/src/resources"
excludes="tools/**, build/**, backwards/**" />
<dirset dir="${basedir}/solr" includes="**/src/java, **/src/examples, **/src/test, **/src/resources"
excludes="build/**" />
<map from="${basedir}/" to=""/>
</pathconvert>
<pathconvert property="netbeans.fileset.testfolders" pathsep="|" dirsep="/">
<dirset dir="${basedir}/lucene" includes="**/src/test" excludes="tools/**, build/**, backwards/**" />
<dirset dir="${basedir}/solr" includes="**/src/test" excludes="build/**" />
<map from="${basedir}/" to=""/>
</pathconvert>
<pathconvert property="netbeans.fileset.resourcefolders" pathsep="|" dirsep="/">
<dirset dir="${basedir}/lucene" includes="**/src/resources" excludes="tools/**, build/**, backwards/**" />
<dirset dir="${basedir}/solr" includes="**/src/resources" excludes="build/**" />
<map from="${basedir}/" to=""/>
</pathconvert>
<pathconvert property="netbeans.fileset.libs" pathsep="|" dirsep="/">
<fileset dir="${basedir}/lucene" includes="**/lib/*.jar" excludes="**/*servlet-api*.jar, analysis/uima/**, tools/**, build/**"/>
<fileset dir="${basedir}/solr" includes="**/test-lib/*.jar,**/lib/*.jar" excludes="core/test-lib/*servlet-api*.jar, contrib/analysis-extras/**, test-framework/lib/junit*, test-framework/lib/ant*, test-framework/lib/randomizedtesting*, build/**, dist/**, package/**" />
<!-- TODO: find a better way to exclude duplicate JAR files & fix the servlet-api mess! -->
<pathconvert property="netbeans.path.libs" pathsep=":" dirsep="/">
<fileset dir="${basedir}/lucene" includes="**/lib/*.jar"
excludes="**/*servlet-api*.jar, analysis/uima/**, tools/**, build/**"/>
<fileset dir="${basedir}/solr" includes="**/test-lib/*.jar,**/lib/*.jar"
excludes="core/test-lib/*servlet-api*.jar, contrib/analysis-extras/**, test-framework/lib/junit*, test-framework/lib/ant*, test-framework/lib/randomizedtesting*, build/**, dist/**, package/**, example/solr-webapp/**" />
<map from="${basedir}/" to=""/>
</pathconvert>
<mkdir dir="nbproject"/>
<copy todir="nbproject" overwrite="true">
<fileset dir="dev-tools/netbeans/nbproject"/>
</copy>
<xslt in="${ant.file}" out="nbproject/project.xml" style="dev-tools/netbeans/nb-project.xsl" force="true">
<outputproperty name="indent" value="yes"/>
<param name="netbeans.fileset.sourcefolders" expression="${netbeans.fileset.sourcefolders}"/>
<param name="netbeans.fileset.testfolders" expression="${netbeans.fileset.testfolders}"/>
<param name="netbeans.fileset.resourcefolders" expression="${netbeans.fileset.resourcefolders}"/>
<param name="netbeans.fileset.libs" expression="${netbeans.fileset.libs}"/>
<param name="netbeans.path.libs" expression="${netbeans.path.libs}"/>
<param name="netbeans.source-level" expression="1.7"/>
</xslt>
</target>

View File

@ -18,263 +18,148 @@
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:str="http://exslt.org/strings"
extension-element-prefixes="str">
<xsl:param name="netbeans.fileset.sourcefolders"/>
<xsl:param name="netbeans.fileset.testfolders"/>
<xsl:param name="netbeans.fileset.resourcefolders"/>
<xsl:param name="netbeans.fileset.libs"/>
xmlns:common="http://exslt.org/common"
extension-element-prefixes="str common">
<xsl:param name="netbeans.fileset.sourcefolders"/>
<xsl:param name="netbeans.path.libs"/>
<xsl:param name="netbeans.source-level"/>
<xsl:variable name="netbeans.fileset.sourcefolders.sortedfrag">
<xsl:for-each select="str:split($netbeans.fileset.sourcefolders,'|')">
<!-- hack to sort **/src/java before **/src/test before **/src/resources : contains() returns "true" which sorts before "false" if descending: -->
<xsl:sort select="string(contains(text(), '/src/java'))" order="descending" lang="en"/>
<xsl:sort select="string(contains(text(), '/src/test'))" order="descending" lang="en"/>
<xsl:sort select="string(contains(text(), '/src/resources'))" order="descending" lang="en"/>
<!-- hack to sort the list, starts-with() returns "true" which sorts before "false" if descending: -->
<xsl:sort select="string(starts-with(text(), 'lucene/core/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'lucene/test-framework/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'lucene/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'solr/core/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'solr/solrj/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'solr/test-framework/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'solr/'))" order="descending" lang="en"/>
<!-- all others in one group above are sorted by path name: -->
<xsl:sort select="text()" order="ascending" lang="en"/>
<xsl:copy-of select="."/>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="netbeans.fileset.sourcefolders.sorted" select="common:node-set($netbeans.fileset.sourcefolders.sortedfrag)/*"/>
<xsl:variable name="netbeans.full.classpath.frag">
<classpath mode="compile" xmlns="http://www.netbeans.org/ns/freeform-project-java/3">
<xsl:value-of select="$netbeans.path.libs"/>
<xsl:for-each select="$netbeans.fileset.sourcefolders.sorted[contains(text(), '/src/java')]">
<xsl:text>:</xsl:text>
<xsl:value-of select="."/>
</xsl:for-each>
</classpath>
</xsl:variable>
<!--
<!--
NOTE: This template matches the root element of any given input XML document!
The XSL input file is ignored completely.
-->
<xsl:template match="/">
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.ant.freeform</type>
<configuration>
<general-data xmlns="http://www.netbeans.org/ns/freeform-project/1">
<name>lucene</name>
<properties/>
<folders>
<xsl:for-each select="str:split($netbeans.fileset.sourcefolders,'|')">
<!-- hack to sort the list, starts-with() returns "true" which sorts before "false" if descending: -->
<xsl:sort select="string(starts-with(text(), 'lucene/core/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'lucene/test-framework/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'lucene/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'solr/core/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'solr/solrj/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'solr/test-framework/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'solr/'))" order="descending" lang="en"/>
<!-- all others in one group above are sorted by path name: -->
<xsl:sort select="text()" order="ascending" lang="en"/>
<source-folder>
<label>
<xsl:value-of select="."/>
</label>
<type>java</type>
<location>
<xsl:value-of select="."/>
</location>
</source-folder>
</xsl:for-each>
<xsl:for-each select="str:split($netbeans.fileset.testfolders,'|')">
<!-- hack to sort the list, starts-with() returns "true" which sorts before "false" if descending: -->
<xsl:sort select="string(starts-with(text(), 'lucene/core/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'lucene/test-framework/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'lucene/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'solr/core/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'solr/solrj/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'solr/test-framework/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'solr/'))" order="descending" lang="en"/>
<!-- all others in one group above are sorted by path name: -->
<xsl:sort select="text()" order="ascending" lang="en"/>
<source-folder>
<label>
<xsl:value-of select="."/>
</label>
<type>java</type>
<location>
<xsl:value-of select="."/>
</location>
</source-folder>
</xsl:for-each>
<xsl:for-each select="str:split($netbeans.fileset.resourcefolders,'|')">
<!-- hack to sort the list, starts-with() returns "true" which sorts before "false" if descending: -->
<xsl:sort select="string(starts-with(text(), 'lucene/core/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'lucene/test-framework/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'lucene/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'solr/core/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'solr/solrj/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'solr/test-framework/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'solr/'))" order="descending" lang="en"/>
<!-- all others in one group above are sorted by path name: -->
<xsl:sort select="text()" order="ascending" lang="en"/>
<source-folder>
<label>
<xsl:value-of select="."/>
</label>
<location>
<xsl:value-of select="."/>
</location>
</source-folder>
</xsl:for-each>
</folders>
<ide-actions>
<action name="build">
<target>compile</target>
</action>
<action name="clean">
<target>clean</target>
</action>
<action name="javadoc">
<target>documentation</target>
</action>
<action name="test">
<target>test</target>
</action>
<action name="rebuild">
<target>clean</target>
<target>compile</target>
</action>
</ide-actions>
<view>
<items>
<xsl:for-each select="str:split($netbeans.fileset.sourcefolders,'|')">
<!-- hack to sort the list, starts-with() returns "true" which sorts before "false" if descending: -->
<xsl:sort select="string(starts-with(text(), 'lucene/core/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'lucene/test-framework/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'lucene/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'solr/core/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'solr/solrj/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'solr/test-framework/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'solr/'))" order="descending" lang="en"/>
<!-- all others in one group above are sorted by path name: -->
<xsl:sort select="text()" order="ascending" lang="en"/>
<source-folder style="packages">
<label>
<xsl:value-of select="."/>
</label>
<location>
<xsl:value-of select="."/>
</location>
</source-folder>
</xsl:for-each>
<xsl:for-each select="str:split($netbeans.fileset.testfolders,'|')">
<!-- hack to sort the list, starts-with() returns "true" which sorts before "false" if descending: -->
<xsl:sort select="string(starts-with(text(), 'lucene/core/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'lucene/test-framework/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'lucene/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'solr/core/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'solr/solrj/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'solr/test-framework/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'solr/'))" order="descending" lang="en"/>
<!-- all others in one group above are sorted by path name: -->
<xsl:sort select="text()" order="ascending" lang="en"/>
<source-folder style="packages">
<label>
<xsl:value-of select="."/>
</label>
<location>
<xsl:value-of select="."/>
</location>
</source-folder>
</xsl:for-each>
<xsl:for-each select="str:split($netbeans.fileset.resourcefolders,'|')">
<!-- hack to sort the list, starts-with() returns "true" which sorts before "false" if descending: -->
<xsl:sort select="string(starts-with(text(), 'lucene/core/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'lucene/test-framework/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'lucene/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'solr/core/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'solr/solrj/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'solr/test-framework/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'solr/'))" order="descending" lang="en"/>
<!-- all others in one group above are sorted by path name: -->
<xsl:sort select="text()" order="ascending" lang="en"/>
<source-folder style="tree">
<label>
<xsl:value-of select="."/>
</label>
<location>
<xsl:value-of select="."/>
</location>
</source-folder>
</xsl:for-each>
<source-file>
<label>Project Build Script</label>
<location>build.xml</location>
</source-file>
</items>
<context-menu>
<ide-action name="build"/>
<ide-action name="rebuild"/>
<ide-action name="clean"/>
<ide-action name="javadoc"/>
<ide-action name="test"/>
</context-menu>
</view>
<subprojects/>
</general-data>
<java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/3">
<compilation-unit>
<xsl:for-each select="str:split($netbeans.fileset.sourcefolders,'|')">
<!-- hack to sort the list, starts-with() returns "true" which sorts before "false" if descending: -->
<xsl:sort select="string(starts-with(text(), 'lucene/core/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'lucene/test-framework/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'lucene/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'solr/core/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'solr/solrj/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'solr/test-framework/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'solr/'))" order="descending" lang="en"/>
<!-- all others in one group above are sorted by path name: -->
<xsl:sort select="text()" order="ascending" lang="en"/>
<package-root>
<xsl:value-of select="."/>
</package-root>
</xsl:for-each>
<classpath mode="compile">
<xsl:for-each select="str:split($netbeans.fileset.libs,'|')">
<!-- sort the jars by path name: -->
<xsl:sort select="text()" order="ascending" lang="en"/>
<xsl:value-of select="."/>
<xsl:if test="not(position() = last())">
<xsl:text>:</xsl:text>
</xsl:if>
</xsl:for-each>
<xsl:text>:</xsl:text>
<xsl:for-each select="str:split($netbeans.fileset.sourcefolders,'|')">
<!-- sort the jars by path name: -->
<xsl:sort select="text()" order="ascending" lang="en"/>
<xsl:value-of select="."/>
<xsl:if test="not(position() = last())">
<xsl:text>:</xsl:text>
</xsl:if>
</xsl:for-each>
</classpath>
<built-to>nb-build/classes</built-to>
<source-level>1.7</source-level>
</compilation-unit>
<compilation-unit>
<xsl:for-each select="str:split($netbeans.fileset.testfolders,'|')">
<!-- hack to sort the list, starts-with() returns "true" which sorts before "false" if descending: -->
<xsl:sort select="string(starts-with(text(), 'lucene/core/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'lucene/test-framework/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'lucene/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'solr/core/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'solr/solrj/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'solr/test-framework/'))" order="descending" lang="en"/>
<xsl:sort select="string(starts-with(text(), 'solr/'))" order="descending" lang="en"/>
<!-- all others in one group above are sorted by path name: -->
<xsl:sort select="text()" order="ascending" lang="en"/>
<package-root>
<xsl:value-of select="."/>
</package-root>
</xsl:for-each>
<unit-tests/>
<classpath mode="compile">
<xsl:for-each select="str:split($netbeans.fileset.libs,'|')">
<!-- sort the jars by path name: -->
<xsl:sort select="text()" order="ascending" lang="en"/>
<xsl:value-of select="."/>
<xsl:if test="not(position() = last())">
<xsl:text>:</xsl:text>
</xsl:if>
</xsl:for-each>
<xsl:text>:</xsl:text>
<xsl:for-each select="str:split($netbeans.fileset.sourcefolders,'|')">
<!-- sort the jars by path name: -->
<xsl:sort select="text()" order="ascending" lang="en"/>
<xsl:value-of select="."/>
<xsl:if test="not(position() = last())">
<xsl:text>:</xsl:text>
</xsl:if>
</xsl:for-each>
</classpath>
<built-to>nb-build/test-classes</built-to>
<source-level>1.7</source-level>
</compilation-unit>
</java-data>
</configuration>
</project>
</xsl:template>
<xsl:template match="/">
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.ant.freeform</type>
<configuration>
<general-data xmlns="http://www.netbeans.org/ns/freeform-project/1">
<name>lucene</name>
<properties/>
<folders>
<xsl:for-each select="$netbeans.fileset.sourcefolders.sorted">
<source-folder>
<label>
<xsl:value-of select="."/>
</label>
<xsl:if test="contains(text(), '/src/java') or contains(text(), '/src/test')">
<type>java</type>
</xsl:if>
<location>
<xsl:value-of select="."/>
</location>
</source-folder>
</xsl:for-each>
</folders>
<ide-actions>
<action name="build">
<target>compile</target>
</action>
<action name="clean">
<target>clean</target>
</action>
<action name="javadoc">
<target>documentation</target>
</action>
<action name="test">
<target>test</target>
</action>
<action name="rebuild">
<target>clean</target>
<target>compile</target>
</action>
</ide-actions>
<view>
<items>
<xsl:for-each select="$netbeans.fileset.sourcefolders.sorted">
<source-folder>
<xsl:attribute name="style">
<xsl:choose>
<xsl:when test="contains(text(), '/src/java') or contains(text(), '/src/test')">packages</xsl:when>
<xsl:otherwise>tree</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<label>
<xsl:value-of select="."/>
</label>
<location>
<xsl:value-of select="."/>
</location>
</source-folder>
</xsl:for-each>
<source-file>
<label>Project Build Script</label>
<location>build.xml</location>
</source-file>
</items>
<context-menu>
<ide-action name="build"/>
<ide-action name="rebuild"/>
<ide-action name="clean"/>
<ide-action name="javadoc"/>
<ide-action name="test"/>
</context-menu>
</view>
<subprojects/>
</general-data>
<java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/3">
<compilation-unit>
<xsl:for-each select="$netbeans.fileset.sourcefolders.sorted[contains(text(), '/src/java')]">
<package-root>
<xsl:value-of select="."/>
</package-root>
</xsl:for-each>
<xsl:copy-of select="$netbeans.full.classpath.frag"/>
<built-to>nb-build/classes</built-to>
<source-level>
<xsl:value-of select="$netbeans.source-level"/>
</source-level>
</compilation-unit>
<compilation-unit>
<xsl:for-each select="$netbeans.fileset.sourcefolders.sorted[contains(text(), '/src/test')]">
<package-root>
<xsl:value-of select="."/>
</package-root>
</xsl:for-each>
<unit-tests/>
<xsl:copy-of select="$netbeans.full.classpath.frag"/>
<built-to>nb-build/test-classes</built-to>
<source-level>
<xsl:value-of select="$netbeans.source-level"/>
</source-level>
</compilation-unit>
</java-data>
</configuration>
</project>
</xsl:template>
</xsl:stylesheet>

View File

@ -0,0 +1,9 @@
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.expand-tabs=true
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.indent-shift-width=2
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.spaces-per-tab=2
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=2
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=80
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-line-wrap=none
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=project
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.continuationIndentSize=4
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceAfterTypeCast=false

View File

@ -97,7 +97,7 @@ Build
(Steve Rowe)
* LUCENE-5360: Add support for developing in Netbeans IDE.
(Michal Hlavac via Steve Rowe)
(Michal Hlavac, Uwe Schindler, Steve Rowe)
Bug fixes