mirror of https://github.com/apache/lucene.git
LUCENE-4415: Port javascript in build files to Groovy (JSR-223)
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1388813 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
14f3c55ca3
commit
a3e03b78f3
|
@ -59,60 +59,59 @@
|
|||
</mvn>
|
||||
</target>
|
||||
|
||||
<target xmlns:ivy="antlib:org.apache.ivy.ant" name="check-svn-working-copy" depends="ivy-availability-check,ivy-fail,ivy-configure">
|
||||
<target xmlns:ivy="antlib:org.apache.ivy.ant" name="check-svn-working-copy" depends="ivy-availability-check,ivy-fail,ivy-configure,resolve-groovy">
|
||||
<ivy:cachepath organisation="org.tmatesoft.svnkit" module="svnkit" revision="1.7.5-v1"
|
||||
inline="true" conf="default" type="jar" transitive="true" pathid="svnkit.classpath"/>
|
||||
<script language="javascript" classpathref="svnkit.classpath" taskname="svn"><![CDATA[
|
||||
importClass(java.io.File);
|
||||
importClass(java.util.TreeSet);
|
||||
importPackage(org.tmatesoft.svn.core);
|
||||
importPackage(org.tmatesoft.svn.core.wc);
|
||||
var manager = SVNClientManager.newInstance();
|
||||
var statusClient = manager.getStatusClient();
|
||||
var wcClient = manager.getWCClient();
|
||||
<script language="groovy" taskname="svn">
|
||||
<classpath>
|
||||
<path refid="groovy.classpath"/>
|
||||
<path refid="svnkit.classpath"/>
|
||||
</classpath><![CDATA[
|
||||
import org.tmatesoft.svn.core.*;
|
||||
import org.tmatesoft.svn.core.wc.*;
|
||||
|
||||
var basedir = new File(project.getProperty("basedir")).getAbsoluteFile();
|
||||
var baseLen = basedir.toString().length();
|
||||
var convertRelative = function(file) {
|
||||
return file.getAbsolutePath().substring(baseLen + 1).replace(File.separatorChar, '/');
|
||||
SVNClientManager manager = SVNClientManager.newInstance();
|
||||
SVNStatusClient statusClient = manager.getStatusClient();
|
||||
SVNWCClient wcClient = manager.getWCClient();
|
||||
|
||||
File basedir = new File(project.getProperty('basedir')).getAbsoluteFile();
|
||||
int baseLen = basedir.toString().length();
|
||||
def convertRelative = {
|
||||
file -> file.getAbsolutePath().substring(baseLen + 1).replace(File.separatorChar, (char)'/');
|
||||
}
|
||||
|
||||
var missingProps = new TreeSet(), unversioned = new TreeSet();
|
||||
Set missingProps = new TreeSet(), unversioned = new TreeSet();
|
||||
|
||||
self.log("Getting all versioned and unversioned files...");
|
||||
statusClient.doStatus(basedir, SVNRevision.WORKING, SVNDepth.fromRecurse(true), false, true, false, false, new ISVNStatusHandler({
|
||||
handleStatus: function(status) {
|
||||
var nodeStatus = status.getNodeStatus();
|
||||
self.log('Getting all versioned and unversioned files...');
|
||||
statusClient.doStatus(basedir, SVNRevision.WORKING, SVNDepth.fromRecurse(true), false, true, false, false, {
|
||||
status ->
|
||||
SVNStatusType nodeStatus = status.getNodeStatus();
|
||||
if (nodeStatus == SVNStatusType.STATUS_UNVERSIONED) {
|
||||
unversioned.add(convertRelative(status.getFile()));
|
||||
} else if (status.getKind() == SVNNodeKind.FILE && nodeStatus != SVNStatusType.STATUS_DELETED) {
|
||||
missingProps.add(convertRelative(status.getFile()));
|
||||
}
|
||||
}
|
||||
}), null);
|
||||
} as ISVNStatusHandler, null);
|
||||
|
||||
self.log("Filtering files with existing svn:eol-style...");
|
||||
wcClient.doGetProperty(basedir, "svn:eol-style", SVNRevision.WORKING, SVNRevision.WORKING, true, new ISVNPropertyHandler({
|
||||
handleProperty: function(file, prop) {
|
||||
missingProps.remove(convertRelative(file));
|
||||
}
|
||||
}));
|
||||
self.log('Filtering files with existing svn:eol-style...');
|
||||
wcClient.doGetProperty(basedir, 'svn:eol-style', SVNRevision.WORKING, SVNRevision.WORKING, true, {
|
||||
file, prop -> missingProps.remove(convertRelative(file));
|
||||
} as ISVNPropertyHandler);
|
||||
|
||||
self.log("Filtering files with binary svn:mime-type...");
|
||||
wcClient.doGetProperty(basedir, "svn:mime-type", SVNRevision.WORKING, SVNRevision.WORKING, true, new ISVNPropertyHandler({
|
||||
handleProperty: function(file, prop) {
|
||||
self.log('Filtering files with binary svn:mime-type...');
|
||||
wcClient.doGetProperty(basedir, 'svn:mime-type', SVNRevision.WORKING, SVNRevision.WORKING, true, {
|
||||
file, prop ->
|
||||
prop = SVNPropertyValue.getPropertyAsString(prop.getValue());
|
||||
if (prop.startsWith("application/") || prop.startsWith("image/")) {
|
||||
if (prop.startsWith('application/') || prop.startsWith('image/')) {
|
||||
missingProps.remove(convertRelative(file));
|
||||
}
|
||||
}
|
||||
}));
|
||||
} as ISVNPropertyHandler);
|
||||
|
||||
var convertSet2String = function(set) {
|
||||
return set.isEmpty() ? null : ("* " + set.toArray().join(project.getProperty("line.separator") + "* "))
|
||||
def convertSet2String = {
|
||||
set -> set.isEmpty() ? null : ('* ' + set.toArray().join(project.getProperty('line.separator') + '* '))
|
||||
};
|
||||
project.setProperty("svn.checkprops.failed", convertSet2String(missingProps));
|
||||
project.setProperty("svn.unversioned.failed", convertSet2String(unversioned));
|
||||
project.setProperty('svn.checkprops.failed', convertSet2String(missingProps));
|
||||
project.setProperty('svn.unversioned.failed', convertSet2String(unversioned));
|
||||
]]></script>
|
||||
<fail if="svn.checkprops.failed"
|
||||
message="The following files are missing svn:eol-style (or binary svn:mime-type):${line.separator}${svn.checkprops.failed}"/>
|
||||
|
|
|
@ -269,7 +269,7 @@
|
|||
</sequential>
|
||||
</target>
|
||||
|
||||
<target name="process-webpages" depends="resolve-pegdown">
|
||||
<target name="process-webpages" depends="resolve-groovy,resolve-pegdown">
|
||||
<makeurl property="process-webpages.buildfiles" separator="|">
|
||||
<fileset dir="." includes="**/build.xml" excludes="build.xml,analysis/*,build/**,tools/**,backwards/**,site/**"/>
|
||||
</makeurl>
|
||||
|
|
|
@ -240,6 +240,7 @@
|
|||
<propertyref regex=".*\.uptodate$$"/>
|
||||
<propertyref regex=".*\.compiled$$"/>
|
||||
<propertyref regex=".*\.loaded$$"/>
|
||||
<propertyref name="lucene.javadoc.url"/><!-- for Solr -->
|
||||
</propertyset>
|
||||
|
||||
<patternset id="lucene.local.src.package.patterns"
|
||||
|
@ -1750,6 +1751,13 @@ ${tests-output}/junit4-*.suites - per-JVM executed suites
|
|||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
<!-- GROOVY scripting engine for ANT tasks -->
|
||||
<target name="resolve-groovy" unless="groovy.loaded" depends="ivy-availability-check,ivy-fail,ivy-configure">
|
||||
<ivy:cachepath organisation="org.codehaus.groovy" module="groovy-all" revision="2.0.4"
|
||||
inline="true" conf="default" type="jar" transitive="true" pathid="groovy.classpath"/>
|
||||
<property name="groovy.loaded" value="true"/>
|
||||
</target>
|
||||
|
||||
<!-- PEGDOWN macro: Before using depend on the target "resolve-pegdown" -->
|
||||
|
||||
<target name="resolve-pegdown" unless="pegdown.loaded" depends="ivy-availability-check,ivy-fail,ivy-configure">
|
||||
|
@ -1771,24 +1779,25 @@ ${tests-output}/junit4-*.suites - per-JVM executed suites
|
|||
<tokenfilter>
|
||||
<filetokenizer/>
|
||||
<replaceregex pattern="\b(LUCENE|SOLR)\-\d+\b" replace="[\0](https://issues.apache.org/jira/browse/\0)" flags="gs"/>
|
||||
<scriptfilter language="javascript" classpathref="pegdown.classpath"><![CDATA[
|
||||
importClass(java.lang.StringBuilder);
|
||||
importClass(org.pegdown.PegDownProcessor);
|
||||
importClass(org.pegdown.Extensions);
|
||||
importClass(org.pegdown.FastEncoder);
|
||||
var markdownSource = self.getToken();
|
||||
var title = undefined;
|
||||
// match the first heading in markdown and use as title:
|
||||
if (markdownSource.search(/^#+\s*(.+)$/m) >= 0) {
|
||||
title = RegExp.$1;
|
||||
}
|
||||
var processor = new PegDownProcessor(
|
||||
<scriptfilter language="groovy">
|
||||
<classpath>
|
||||
<path refid="groovy.classpath"/>
|
||||
<path refid="pegdown.classpath"/>
|
||||
</classpath><![CDATA[
|
||||
import org.pegdown.PegDownProcessor;
|
||||
import org.pegdown.Extensions;
|
||||
import org.pegdown.FastEncoder;
|
||||
|
||||
String markdownSource = self.getToken();
|
||||
PegDownProcessor processor = new PegDownProcessor(
|
||||
Extensions.ABBREVIATIONS | Extensions.AUTOLINKS |
|
||||
Extensions.FENCED_CODE_BLOCKS | Extensions.SMARTS
|
||||
);
|
||||
var html = new StringBuilder('<html>\n<head>\n');
|
||||
if (title) {
|
||||
html.append('<title>').append(FastEncoder.encode(title)).append('</title>\n');
|
||||
StringBuilder html = new StringBuilder('<html>\n<head>\n');
|
||||
// match the first heading in markdown and use as title:
|
||||
def matcher = (markdownSource =~ /(?m)^#+\s*(.+)$/);
|
||||
if (matcher.find()) {
|
||||
html.append('<title>').append(FastEncoder.encode(matcher.group(1))).append('</title>\n');
|
||||
}
|
||||
html.append('<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">\n')
|
||||
.append('</head>\n<body>\n')
|
||||
|
|
|
@ -138,12 +138,12 @@
|
|||
<target name="compile-test" description="Compile unit tests."
|
||||
depends="compile-solr-test-framework, compile-test-solr-core, compile-test-solrj, compile-test-contrib"/>
|
||||
<target name="javadocs" description="Calls javadocs-all, javadocs-solrj, and javadocs-test-framework"
|
||||
depends="javadocs-solr-core,javadocs-solrj,javadocs-test-framework,javadocs-contrib"/>
|
||||
depends="define-lucene-javadoc-url,javadocs-solr-core,javadocs-solrj,javadocs-test-framework,javadocs-contrib"/>
|
||||
<target name="documentation" description="Generate all documentation"
|
||||
depends="javadocs,changes-to-html,process-webpages"/>
|
||||
<target name="compile-core" depends="compile-solr-core" unless="solr.core.compiled"/>
|
||||
|
||||
<target name="process-webpages" depends="define-lucene-javadoc-url"> <!--depends="resolve-pegdown">-->
|
||||
<target name="process-webpages" depends="define-lucene-javadoc-url"><!--depends="resolve-groovy,resolve-pegdown">-->
|
||||
<makeurl property="process-webpages.buildfiles" separator="|">
|
||||
<fileset dir="." includes="core/build.xml,test-framework/build.xml,solrj/build.xml,contrib/**/build.xml"/>
|
||||
</makeurl>
|
||||
|
@ -505,10 +505,6 @@
|
|||
<sign-artifacts-macro artifacts.dir="${package.dir}"/>
|
||||
</target>
|
||||
|
||||
<target name="javadocs-dep">
|
||||
<!-- NOOP -->
|
||||
</target>
|
||||
|
||||
<target name="resolve" depends="resolve-example">
|
||||
<sequential>
|
||||
<ant dir="core" target="resolve" inheritall="false">
|
||||
|
|
|
@ -275,17 +275,17 @@
|
|||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
<target name="define-lucene-javadoc-url" unless="lucene.javadoc.url">
|
||||
<script language="javascript"><![CDATA[
|
||||
var url, version = project.getProperty('version');
|
||||
<target name="define-lucene-javadoc-url" depends="resolve-groovy" unless="lucene.javadoc.url">
|
||||
<script language="groovy" classpathref="groovy.classpath"><![CDATA[
|
||||
String url, version = project.getProperty('version');
|
||||
if (version.contains('-SNAPSHOT')) {
|
||||
importClass(java.io.File);
|
||||
url = new File(project.getProperty('common.dir'), 'build' + File.separator + 'docs').toURI().toASCIIString();
|
||||
if (!(/\/$/.test(url))) url += '/';
|
||||
if (!(url =~ /\/$/)) url += '/';
|
||||
} else {
|
||||
version = version.replace('.', '_');
|
||||
url = 'http://lucene.apache.org/core/' + version + '/';
|
||||
}
|
||||
self.log('Using the following URL to refer to Lucene Javadocs: ' + url);
|
||||
project.setProperty('lucene.javadoc.url', url);
|
||||
]]></script>
|
||||
</target>
|
||||
|
|
Loading…
Reference in New Issue