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

View File

@ -18,12 +18,42 @@
<xsl:stylesheet version="1.0" <xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:str="http://exslt.org/strings" xmlns:str="http://exslt.org/strings"
extension-element-prefixes="str"> xmlns:common="http://exslt.org/common"
extension-element-prefixes="str common">
<xsl:param name="netbeans.fileset.sourcefolders"/> <xsl:param name="netbeans.fileset.sourcefolders"/>
<xsl:param name="netbeans.fileset.testfolders"/> <xsl:param name="netbeans.path.libs"/>
<xsl:param name="netbeans.fileset.resourcefolders"/> <xsl:param name="netbeans.source-level"/>
<xsl:param name="netbeans.fileset.libs"/>
<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! NOTE: This template matches the root element of any given input XML document!
@ -37,63 +67,14 @@
<name>lucene</name> <name>lucene</name>
<properties/> <properties/>
<folders> <folders>
<xsl:for-each select="str:split($netbeans.fileset.sourcefolders,'|')"> <xsl:for-each select="$netbeans.fileset.sourcefolders.sorted">
<!-- 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> <source-folder>
<label> <label>
<xsl:value-of select="."/> <xsl:value-of select="."/>
</label> </label>
<xsl:if test="contains(text(), '/src/java') or contains(text(), '/src/test')">
<type>java</type> <type>java</type>
<location> </xsl:if>
<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> <location>
<xsl:value-of select="."/> <xsl:value-of select="."/>
</location> </location>
@ -120,58 +101,14 @@
</ide-actions> </ide-actions>
<view> <view>
<items> <items>
<xsl:for-each select="str:split($netbeans.fileset.sourcefolders,'|')"> <xsl:for-each select="$netbeans.fileset.sourcefolders.sorted">
<!-- hack to sort the list, starts-with() returns "true" which sorts before "false" if descending: --> <source-folder>
<xsl:sort select="string(starts-with(text(), 'lucene/core/'))" order="descending" lang="en"/> <xsl:attribute name="style">
<xsl:sort select="string(starts-with(text(), 'lucene/test-framework/'))" order="descending" lang="en"/> <xsl:choose>
<xsl:sort select="string(starts-with(text(), 'lucene/'))" order="descending" lang="en"/> <xsl:when test="contains(text(), '/src/java') or contains(text(), '/src/test')">packages</xsl:when>
<xsl:sort select="string(starts-with(text(), 'solr/core/'))" order="descending" lang="en"/> <xsl:otherwise>tree</xsl:otherwise>
<xsl:sort select="string(starts-with(text(), 'solr/solrj/'))" order="descending" lang="en"/> </xsl:choose>
<xsl:sort select="string(starts-with(text(), 'solr/test-framework/'))" order="descending" lang="en"/> </xsl:attribute>
<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> <label>
<xsl:value-of select="."/> <xsl:value-of select="."/>
</label> </label>
@ -197,81 +134,29 @@
</general-data> </general-data>
<java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/3"> <java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/3">
<compilation-unit> <compilation-unit>
<xsl:for-each select="str:split($netbeans.fileset.sourcefolders,'|')"> <xsl:for-each select="$netbeans.fileset.sourcefolders.sorted[contains(text(), '/src/java')]">
<!-- 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> <package-root>
<xsl:value-of select="."/> <xsl:value-of select="."/>
</package-root> </package-root>
</xsl:for-each> </xsl:for-each>
<classpath mode="compile"> <xsl:copy-of select="$netbeans.full.classpath.frag"/>
<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> <built-to>nb-build/classes</built-to>
<source-level>1.7</source-level> <source-level>
<xsl:value-of select="$netbeans.source-level"/>
</source-level>
</compilation-unit> </compilation-unit>
<compilation-unit> <compilation-unit>
<xsl:for-each select="str:split($netbeans.fileset.testfolders,'|')"> <xsl:for-each select="$netbeans.fileset.sourcefolders.sorted[contains(text(), '/src/test')]">
<!-- 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> <package-root>
<xsl:value-of select="."/> <xsl:value-of select="."/>
</package-root> </package-root>
</xsl:for-each> </xsl:for-each>
<unit-tests/> <unit-tests/>
<classpath mode="compile"> <xsl:copy-of select="$netbeans.full.classpath.frag"/>
<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> <built-to>nb-build/test-classes</built-to>
<source-level>1.7</source-level> <source-level>
<xsl:value-of select="$netbeans.source-level"/>
</source-level>
</compilation-unit> </compilation-unit>
</java-data> </java-data>
</configuration> </configuration>

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) (Steve Rowe)
* LUCENE-5360: Add support for developing in Netbeans IDE. * LUCENE-5360: Add support for developing in Netbeans IDE.
(Michal Hlavac via Steve Rowe) (Michal Hlavac, Uwe Schindler, Steve Rowe)
Bug fixes Bug fixes