On Thu, Apr 8, 2010 at 4:57 PM, Armando Blancas
<armando_blan...@yahoo.com> wrote:
>> Looks cool. This should help the XML-allergic :)
>
> Though I don't like it, the XML is the least of my problems. Don't
> know what to do or even where to start. I want to do the following in
> maven or pmaven, but anything beyond their Hello World example has
> been a real struggle :-(    Any pointers?
>

The steps are:
Add antlr3-maven-plugin to your Project Object Model (pom).

In maven xml it looks like:

<project>
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>antlr3-maven-plugin</artifactId>
        <version>1.0</version>
        <executions>
          <execution>
            <goals>
              <goal>antlr</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  ...
</project>

I'm guessing that in the new polyglot world it would look something like:

(defmaven
; ... other stuff that defines your project name, version, etc
 :build [:plugins [['org.codehaus.mojo/antlr3-maven-plugin "1.0"
                         :executions [[:goals ["antlr"]]]]]]]) ; Who
knows if I got the braces correct


Which already seems like a pretty big improvement to me.

As a result you would be able to:

(The following all assumes that your *.g files are in src/main/antlr,
where maven looks by default, more details at:
http://mojo.codehaus.org/antlr3-maven-plugin/)
> -- Generate Java code from an ANTLR lexer:
> java -cp ...  org.antlr.Tool Scanner.g

mvn -f project.clj generate-sources

(the resulting java files end up in the
"target/generated-sources/antlr" directory by default)

> -- Compile the scanner and an exception class:
> javac -cp ... Scanner.java ExitException.java

I'm not sure how you'd do this in a maven-only world. I guess you'd
have to do "java -cp target/generated-sources/antlr/*.java", not sure
why you'd want to though.

I guess one way would be to put your antlr stuff in its own
sub-project and then "mvn -f project.clj compile".

> -- Compile the clojure program using the above classes
> java -Dclojure.compile.path=... -cp ... clojure.lang.Compile prog.main

mvn -f project.clj compile

(You can also skip straight to this if you want, the antlr files
should be processed automatically into java for you, you'd also need
to add the maven-clojure-plugin to your plugins to be able to do
compile clojure code and do something like "mvn repl")

> -- Package incl. the antlr runtime inside the jar
> jar -x ...
> jar cMf prog.jar ... *.class

mvn -f project.clj package

(The resulting jar file ends up in
"target\project_name-module_name-<version>.jar by default. A file
called "target\project_name-module-name-<version>-sources.jar" is also
automatically created containing all your source code. I don't think,
however, that it adds the antlr runtime to your jar)

For more complicated packaging (such as adding the antlr runtime),
you'd use the maven-assembly-plugin to add arbitrary stuff to your
resulting jar. It's a little more complicated, and requires its own
xml.
http://maven.apache.org/plugins/maven-assembly-plugin/

> - clean up: delete the generated Java classes, the .tokens file, the
> expanded antl runtime, all .class files

mvn -f project.clj clean

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to