[stringtemplate4] Initial version of the package

Stanislav Ochotnicky sochotni at fedoraproject.org
Mon Jan 23 15:54:40 UTC 2012


commit 0f465762b31d332f9794b195428c5d6c11dfde82
Author: Stanislav Ochotnicky <sochotnicky at redhat.com>
Date:   Mon Jan 23 16:54:32 2012 +0100

    Initial version of the package

 .gitignore           |    1 +
 DoubleKeyMap.java    |   62 +++++++++++++
 STLexer.tokens       |   58 ++++++++++++
 pom.xml              |  246 ++++++++++++++++++++++++++++++++++++++++++++++++++
 sources              |    1 +
 stringtemplate4.spec |   91 +++++++++++++++++++
 6 files changed, 459 insertions(+), 0 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index e69de29..31fe918 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
+/ST-4.0.4-src.zip
diff --git a/DoubleKeyMap.java b/DoubleKeyMap.java
new file mode 100644
index 0000000..b69ae32
--- /dev/null
+++ b/DoubleKeyMap.java
@@ -0,0 +1,62 @@
+package org.antlr.runtime.misc;
+
+import java.util.*;
+
+/** Sometimes we need to map a key to a value but key is two pieces of data.
+ *  This nested hash table saves creating a single key each time we access
+ *  map; avoids mem creation.
+ */
+public class DoubleKeyMap<Key1, Key2, Value> {
+	Map<Key1, Map<Key2, Value>> data = new LinkedHashMap<Key1, Map<Key2, Value>>();
+
+	public Value put(Key1 k1, Key2 k2, Value v) {
+		Map<Key2, Value> data2 = data.get(k1);
+		Value prev = null;
+		if ( data2==null ) {
+			data2 = new LinkedHashMap<Key2, Value>();
+			data.put(k1, data2);
+		}
+		else {
+			prev = data2.get(k2);
+		}
+		data2.put(k2, v);
+		return prev;
+	}
+
+	public Value get(Key1 k1, Key2 k2) {
+		Map<Key2, Value> data2 = data.get(k1);
+		if ( data2==null ) return null;
+		return data2.get(k2);
+	}
+
+	public Map<Key2, Value> get(Key1 k1) { return data.get(k1); }
+
+	/** Get all values associated with primary key */
+	public Collection<Value> values(Key1 k1) {
+		Map<Key2, Value> data2 = data.get(k1);
+		if ( data2==null ) return null;
+		return data2.values();
+	}
+
+	/** get all primary keys */
+	public Set<Key1> keySet() {
+		return data.keySet();
+	}
+
+	/** get all secondary keys associated with a primary key */
+	public Set<Key2> keySet(Key1 k1) {
+		Map<Key2, Value> data2 = data.get(k1);
+		if ( data2==null ) return null;
+		return data2.keySet();
+	}
+
+	public Collection<Value> values() {
+		Set<Value> s = new HashSet<Value>();
+		for (Map<Key2, Value> k2 : data.values()) {
+			for (Value v : k2.values()) {
+				s.add(v);
+			}
+		}
+		return s;
+	}
+}
diff --git a/STLexer.tokens b/STLexer.tokens
new file mode 100644
index 0000000..7d530b6
--- /dev/null
+++ b/STLexer.tokens
@@ -0,0 +1,58 @@
+RBRACK=17
+LBRACK=16
+ELSE=5
+ELLIPSIS=11
+LCURLY=20
+BANG=10
+EQUALS=12
+TEXT=22
+ID=25
+SEMI=9
+LPAREN=14
+IF=4
+ELSEIF=6
+COLON=13
+RPAREN=15
+WS=27
+COMMA=18
+RCURLY=21
+ENDIF=7
+RDELIM=24
+SUPER=8
+DOT=19
+LDELIM=23
+STRING=26
+PIPE=28
+OR=29
+AND=30
+INDENT=31
+NEWLINE=32
+AT=33
+END=34
+TRUE=35
+FALSE=36
+COMMENT=37
+'...'=11
+'super'=8
+'|'=28
+'!'=10
+'}'=21
+'else'=5
+'if'=4
+'{'=20
+'...'=11
+'elseif'=6
+';'=9
+'='=12
+':'=13
+'('=14
+'['=16
+','=18
+'.'=19
+'endif'=7
+')'=15
+']'=17
+'||'=29
+'&&'=30
+'@'=33
+'@end'=34
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..d3f012b
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,246 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<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/maven-v4_0_0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.antlr</groupId>
+    <artifactId>ST4</artifactId>
+    <packaging>jar</packaging>
+
+    <!--
+        The version number defined here in the version tag indicates how the
+        jar is named and released. When it ends with SNAPSHOT, it will be stored
+        in your local repository (~/m2 on UNIX) as stringtemplate-X.Y-SNAPSHOT, but
+        will be deplyed to the ANTLR snapshot repository at antlr.org with the word
+        SNAPSHOT replaced with the the data, time and unique number.
+    -->
+
+    <version>4.0.4-SNAPSHOT</version>
+
+    <!--
+        The name of the project as seen by IDEs and release documentation etc.
+    -->
+
+    <name>ANTLR ST4 4.0.4-SNAPSHOT</name>
+    <description>StringTemplate is a java template engine for generating source code,
+web pages, emails, or any other formatted text output.
+
+StringTemplate is particularly good at multi-targeted code generators,
+multiple site skins, and internationalization/localization. 
+
+It evolved over years of effort developing jGuru.com. 
+
+StringTemplate also generates the stringtemplate website: http://www.stringtemplate.org
+and powers the ANTLR v3 code generator. Its distinguishing characteristic 
+is that unlike other engines, it strictly enforces model-view separation.
+
+Strict separation makes websites and code generators more flexible
+and maintainable; it also provides an excellent defense against malicious
+template authors.
+
+There are currently about 600 StringTemplate source downloads a month.
+    </description>
+    
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+    
+    <!--
+        The URL of the base project
+      -->
+
+    <url>http://www.stringtemplate.org</url>
+    <developers>
+        <developer>
+            <name>Terence Parr</name>
+            <organization>USFCA</organization>
+            <organizationUrl>http://www.cs.usfca.edu</organizationUrl>
+            <email>parrt at antlr.org</email>
+            <roles>
+                <role>Project Leader</role>
+                <role>Developer - Java Target</role>
+            </roles>
+            <timezone>PST</timezone>
+        </developer>
+        <developer>
+            <name>Jim Idle</name>
+            <organization>Temporal Wave LLC</organization>
+            <organizationUrl>http://www.temporal-wave.com</organizationUrl>
+            <email>jimi at temporal-wave.com</email>
+            <roles>
+                <role>Developer - Maven stuff</role>
+            </roles>
+            <timezone>PST</timezone>
+        </developer>
+    </developers>
+
+    <licenses>
+        <license>
+            <name>BSD licence</name>
+            <url>http://antlr.org/license.html</url>
+            <distribution>repo</distribution>
+        </license>
+    </licenses>
+
+    <scm>
+        <url>http://fisheye2.cenqua.com/browse/stringtemplate</url>
+        <connection>http://fisheye2.cenqua.com/browse/stringtemplate</connection>
+    </scm>
+
+    
+  <!--
+    Definition of the ANTLR repositories. Note that you can only deploy
+    to the repositories via scp, and so the server must already know about
+    your public key. Only StringTemplate developers are allowed to deploy to the
+    release and snapshot repositories, which are synced with the Maven central
+    repository.
+  -->
+  <distributionManagement>
+      <repository>
+          <id>antlr-repo</id>
+          <name>ANTLR Testing repository</name>
+          <url>scpexe://antlr.org/home/mavensync/antlr-repo</url>
+      </repository>
+      <snapshotRepository>
+            <id>antlr-snapshot</id>
+            <name>ANTLR Testing Snapshot Repository</name>
+            <url>scpexe://antlr.org/home/mavensync/antlr-snapshot</url>
+      </snapshotRepository>
+  </distributionManagement>
+
+    <dependencies>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.8.2</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.antlr</groupId>
+            <artifactId>antlr-runtime</artifactId>
+            <version>3.3</version>
+            <scope>compile</scope>
+        </dependency>
+            
+    </dependencies>
+
+    <build>
+        <defaultGoal>install</defaultGoal>
+        <extensions>
+            <extension>
+                <groupId>org.apache.maven.wagon</groupId>
+                <artifactId>wagon-ssh-external</artifactId>
+                <version>1.0-beta-2</version>
+            </extension>
+        </extensions>
+
+        <!--
+            The root of the source code for StringTemplate
+        -->
+        <sourceDirectory>src</sourceDirectory>
+
+        <!--
+            The root of the test source code for StringTemplate.
+        -->
+        <testSourceDirectory>test</testSourceDirectory>
+
+        <!--
+            All the resources that should be on the classpath, when 
+            the junit tests are run. Here we need to include the test
+            source code directory as the .st files loaded dynamically
+            by the tests, are located underneath this tree.
+        -->
+        <testResources>
+            <testResource>
+                <directory>test</directory>
+            </testResource>
+        </testResources>
+
+        <plugins>
+           <plugin>
+                <groupId>org.antlr</groupId>
+                <artifactId>antlr3-maven-plugin</artifactId>
+                <version>3.3</version>
+                <configuration>
+                    <libDirectory>src/org/stringtemplate/v4/compiler</libDirectory>
+                    <sourceDirectory>src</sourceDirectory>
+                    <verbose>true</verbose>
+                </configuration>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>antlr</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+
+            <plugin>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>2.3.2</version>
+                <configuration>
+                    <source>1.6</source>
+                    <!--
+                        NB: If you want to generate 1.4 compatible classes then change
+                            the target to:
+                        <target>jsr14</target>
+
+                        However, the junit tests will then all be hidden from junit and
+                        none will run, hence this is not done by default.
+                     -->
+                    <target>1.6</target>
+                    <sourceDirectory>src</sourceDirectory>
+                </configuration>
+            </plugin>
+
+            <plugin>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <version>2.8.1</version>
+                <configuration>
+                    <additionalClasspathElements>
+                        <additionalClasspathElement>${basedir}/src</additionalClasspathElement>
+                    </additionalClasspathElements>
+                </configuration>
+            </plugin>
+
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>findbugs-maven-plugin</artifactId>
+                <version>2.3.2</version>
+                <configuration>
+                    <findbugsXmlOutput>true</findbugsXmlOutput>
+                    <findbugsXmlWithMessages>true</findbugsXmlWithMessages>
+                    <xmlOutput>true</xmlOutput>
+                </configuration>
+            </plugin>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-source-plugin</artifactId>
+                <version>2.1.2</version>
+				<executions>
+					<execution>
+						<id>attach-sources</id>
+						<goals>
+							<goal>jar</goal>
+						</goals>
+					</execution>
+				</executions>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-javadoc-plugin</artifactId>
+                <version>2.8</version>
+				<executions>
+					<execution>
+						<id>attach-javadocs</id>
+						<goals>
+							<goal>jar</goal>
+						</goals>
+					</execution>
+				</executions>
+			</plugin>
+	</plugins>
+    </build>
+</project>
+
diff --git a/sources b/sources
index e69de29..d7c6320 100644
--- a/sources
+++ b/sources
@@ -0,0 +1 @@
+de12e824036d04c7fe21a4b056a0957f  ST-4.0.4-src.zip
diff --git a/stringtemplate4.spec b/stringtemplate4.spec
new file mode 100644
index 0000000..ec081d0
--- /dev/null
+++ b/stringtemplate4.spec
@@ -0,0 +1,91 @@
+%global pkgname ST
+
+Name:      stringtemplate4
+Version:   4.0.4
+Release:   1%{?dist}
+Summary:   A Java template engine
+URL:       http://www.stringtemplate.org/
+Source0:   http://www.stringtemplate.org/download/%{pkgname}-%{version}-src.zip
+
+# missing from source tarball so we add it here for now
+Source1:   https://raw.github.com/antlr/stringtemplate4/master/src/org/stringtemplate/v4/compiler/STLexer.tokens
+Source2:   https://raw.github.com/antlr/antlr/revision-3.4/runtime/Java/src/main/java/org/antlr/runtime/misc/DoubleKeyMap.java
+Source3:   https://raw.github.com/antlr/stringtemplate4/master/pom.xml
+
+License:   BSD
+Group:     Development/Libraries
+BuildArch: noarch
+
+BuildRequires: ant-antlr3, ant-junit
+BuildRequires: antlr3
+BuildRequires: stringtemplate
+# Standard deps
+BuildRequires: java-devel >= 1:1.6.0
+BuildRequires: jpackage-utils
+Requires:      java >= 1:1.6.0
+Requires:      jpackage-utils
+
+%description
+StringTemplate is a java template engine (with ports for
+C# and Python) for generating source code, web pages,
+emails, or any other formatted text output. StringTemplate
+is particularly good at multi-targeted code generators,
+multiple site skins, and internationalization/localization.
+
+%package javadoc
+Group:          Documentation
+Summary:        API documentation for %{name}
+Requires:       jpackage-utils
+
+%description javadoc
+%{summary}.
+
+%prep
+%setup -q -n %{pkgname}-%{version}
+
+# copy sources missing in source archive into places
+cp %{SOURCE1} src/org/stringtemplate/v4/compiler/STLexer.tokens
+mkdir -p src/org/antlr/runtime/misc
+# this is temporary until we build new antlr3 properly
+cp %{SOURCE2} src/org/antlr/runtime/misc/DoubleKeyMap.java
+cp %{SOURCE3} pom.xml
+
+rm -rf lib/* target
+ln -sf $(build-classpath antlr3) lib/antlr-3.3-complete.jar
+ln -sf $(build-classpath ant/ant-antlr3) lib/ant-antlr3.jar
+
+sed -i \
+'s:location="${ant-antlr3.jar}":location="/usr/share/java/antlr3-runtime.jar":' build.xml
+
+%build
+export CLASSPATH="`build-classpath ant/ant-antlr3 antlr3 antlr3-runtime antlr stringtemplate`"
+ant build-jar
+
+%javadoc -d javadoc -public `find build/src build/gen -name '*.java'`
+
+%install
+install -D dist/ST-%{version}.jar \
+    %{buildroot}%{_datadir}/java/%{name}.jar
+
+
+install -Dpm 644 pom.xml %{buildroot}%{_mavenpomdir}/JPP-%{name}.pom
+%add_maven_depmap JPP-%{name}.pom %{name}.jar
+
+mkdir -p %{buildroot}%{_javadocdir}/%{name}
+cp -pr javadoc/* %{buildroot}%{_javadocdir}/%{name}/
+
+
+%files
+%doc LICENSE.txt README.txt
+%{_datadir}/java/%{name}.jar
+%{_mavenpomdir}/JPP-%{name}.pom
+%{_mavendepmapfragdir}/%{name}
+
+%files javadoc
+%doc LICENSE.txt
+%{_javadocdir}/%{name}
+
+%changelog
+* Fri Jan 13 2012 Stanislav Ochotnicky <sochotnicky at redhat.com> - 4.0.4-1
+- Initial version of the package
+


More information about the scm-commits mailing list