我正在寻找一个不那么简单的 java / clojure 互操作示例

发布于 2024-09-24 11:05:20 字数 206 浏览 4 评论 0原文

有人想回答我在这里链接的问题 how-to -从 clojure 到 java 传递类型化集合 为我们这些试图将 clojure 潜入现有 java 堆栈的人提供一个清晰的示例?

Does anybody want to answer my question linked here how-to-pass-a-typed-collection-from-clojure-to-java
, by providing a clear example, for the rest of us who are trying to sneak clojure in their existing java stack?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

烙印 2024-10-01 11:05:20

只需传递一个原始(无类型)集合。您实际上不需要关心类型 - 它们只是编译器技巧并在运行时被丢弃。

Just pass a raw(untyped) collections. You don't really need to care about the types - they are just a compiler trick and are discarded at runtime.

夜深人未静 2024-10-01 11:05:20

来自 Chas Emerick 对我的原始问题的回答,我设置了这个小 Maven 项目:

interop ---- domainobjects ---- IFoo.java
                           ---- TypedObject.java
                           ---- pom.xml

        ---- functional    ---- fooimpl.clj
                           ---- pom.xml

        ---- consumer      ---- JavaConsumer.java
                           ---- JavaConsumerTest.groovy
                           ---- pom.xml
        ---- pom.xml

######################################################################################

package com.tobeconsumed.byjava;

import java.util.List;

public interface IFoo {
    List<TypedObject> createListOfTypedObjects(String message);
}


package com.tobeconsumed.byjava;

public class TypedObject {

    private String property;

    public String getProperty() {
        return property;
    }

    public void setProperty(String property) {
        this.property = property;
    }
}

<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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <artifactId>interop</artifactId>
    <groupId>interop</groupId>
    <version>0.0.1-SNAPSHOT</version>
  </parent>
  <groupId>interop</groupId>
  <artifactId>domainobjects</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>domainobjects</name>
  <description>Contains all of the domain objects.</description>

  <dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.8.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-all</artifactId>
      <version>1.7.4</version>
    </dependency>    
  </dependencies>

  <build>

    <finalName>domainobjects</finalName>

    <plugins>
        <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.1</version>
        <configuration>
          <source>1.6</source>
          <target>1.6</target>
          <project>
            <build>
                <scriptSourceDirectory>src/main/java</scriptSourceDirectory>
                <testSourceDirectory>src/test/java</testSourceDirectory>
            </build>
          </project>
        </configuration>
        <executions>
         <execution>
           <id>compile</id>
           <phase>compile</phase>
           <goals>
             <goal>compile</goal>
           </goals>
         </execution>
         <execution>
           <id>test-java</id>
           <phase>test</phase>
           <goals>
             <goal>testCompile</goal>
           </goals>
         </execution>
       </executions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.gmaven</groupId>
        <artifactId>gmaven-plugin</artifactId>
        <version>1.2</version>
        <extensions>true</extensions>
        <configuration>
            <project>
            <build>
                <sourceDirectory>src/main/groovy</sourceDirectory>
                <testSourceDirectory>src/test/groovy</testSourceDirectory>
            </build>
            </project>
        </configuration>
      </plugin>
      <plugin>
    <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
            <executions>
                <execution>
                    <id>compile</id>
                    <phase>compile</phase>
                    <configuration>
                        <tasks>
                            <mkdir dir="${basedir}/src/main/groovy"/>
                            <taskdef name="groovyc"
                                classname="org.codehaus.groovy.ant.Groovyc">
                                <classpath refid="maven.compile.classpath"/>
                            </taskdef>
                            <mkdir dir="${project.build.outputDirectory}"/>
                            <groovyc destdir="${project.build.outputDirectory}"
                                srcdir="${basedir}/src/main/groovy/" listfiles="true">
                                <classpath refid="maven.compile.classpath"/>
                            </groovyc>
                        </tasks>
                    </configuration>
                    <goals>
                        <goal>run</goal>
                    </goals>
                </execution>
                <execution>
                    <id>test-compile</id>
                    <phase>test-compile</phase>
                    <configuration>
                        <tasks>
                            <mkdir dir="${basedir}/src/test/groovy"/>
                            <taskdef name="groovyc"
                                classname="org.codehaus.groovy.ant.Groovyc">
                                <classpath refid="maven.compile.classpath"/>
                            </taskdef>
                            <mkdir dir="${project.build.testOutputDirectory}"/>
                            <groovyc destdir="${project.build.testOutputDirectory}"
                                srcdir="${basedir}/src/test/groovy/" listfiles="true">
                                <classpath refid="maven.test.classpath"/>
                            </groovyc>
                        </tasks>
                    </configuration>
                    <goals>
                        <goal>run</goal>
                    </goals>
                </execution>
            </executions>
       </plugin>      
    </plugins>
  </build>

</project>


######################################################################################

(ns com.tobeconsumed.byjava.fooimpl
  (:import com.tobeconsumed.byjava.IFoo)
  (:gen-class
    :implements [com.tobeconsumed.byjava.IFoo]))

(defn -createListOfTypedObjects
  "Creates and returns a list of TypedObjects"
  [this message]
  (println message)
  [(TypedObject.), (TypedObject.), (TypedObject.), (TypedObject.)])

<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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <artifactId>interop</artifactId>
    <groupId>interop</groupId>
    <version>0.0.1-SNAPSHOT</version>
  </parent>
  <groupId>interop</groupId>
  <artifactId>functional</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>functional</name>
  <description>Some functional code.</description>

  <repositories>
    <repository>
      <id>clojars</id>
      <url>http://clojars.org/repo/</url>
    </repository>
    <repository>
      <id>clojure-releases</id>
      <url>http://build.clojure.org/releases</url>
    </repository>
    <repository>
      <id>clojure-snapshots</id>
      <url>http://build.clojure.org/snapshots</url>
    </repository>
    <repository>
      <id>central</id>
      <url>http://repo1.maven.org/maven2</url>
    </repository>
  </repositories>

  <dependencies>
    <dependency>
      <groupId>interop</groupId>
      <artifactId>domainobjects</artifactId>
      <version>0.0.1-SNAPSHOT</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.clojure</groupId>
      <artifactId>clojure</artifactId>
      <version>1.2.0</version>
      <type>pom</type>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.clojure</groupId>
      <artifactId>clojure-contrib</artifactId>
      <version>1.2.0</version>
      <type>pom</type>
      <scope>compile</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
        <plugin>
        <groupId>com.theoryinpractise</groupId>
        <artifactId>clojure-maven-plugin</artifactId>
        <version>1.3.3</version>
        <configuration>
            <project>
                <build>
                    <sourceDirectory>src/main/clojure</sourceDirectory>
                    <testSourceDirectory>src/test/clojure</testSourceDirectory>
                </build>
            </project>
        </configuration>
        <executions>
         <execution>
           <id>compile</id>
           <phase>compile</phase>
           <goals>
             <goal>compile</goal>
           </goals>
         </execution>
         <execution>
           <id>test-clojure</id>
           <phase>test</phase>
           <goals>
             <goal>test</goal>
           </goals>
         </execution>
       </executions>
      </plugin>
    </plugins>
  </build>

</project>


######################################################################################



package consumer;

import java.util.List;

import com.tobeconsumed.byjava.IFoo;
import com.tobeconsumed.byjava.TypedObject;
import com.tobeconsumed.byjava.fooimpl;

public class JavaConsumer {

    public List<TypedObject> callCreateListOfTypedObjects() {
        IFoo foo = new fooimpl();
        List<TypedObject> listOfTypedObject = foo.createListOfTypedObjects("Returning typed a list");
        return listOfTypedObject;
    }

}


package consumer;

import junit.framework.TestCase;

public class JavaConsumerTest extends TestCase {

    private JavaConsumer javaConsumer;

    protected void setUp() throws Exception {
        javaConsumer = new JavaConsumer();
        super.setUp();
    }

    protected void tearDown() throws Exception {
        javaConsumer = null;
        super.tearDown();
    }

    public void testCallShowMessage() {
        assertNotNull(javaConsumer);
        def result = javaConsumer.callCreateListOfTypedObjects();

        assert 4 == result.size()
    }

}


<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <artifactId>interop</artifactId>
    <groupId>interop</groupId>
    <version>0.0.1-SNAPSHOT</version>
  </parent>
  <groupId>interop</groupId>
  <artifactId>consumer</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>
  <name>consumer</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>interop</groupId>
      <artifactId>functional</artifactId>
      <version>0.0.1-SNAPSHOT</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>interop</groupId>
      <artifactId>domainobjects</artifactId>
      <version>0.0.1-SNAPSHOT</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.8.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-all</artifactId>
      <version>1.7.4</version>
    </dependency>    
  </dependencies>
  <build>

    <finalName>consumer</finalName>

    <plugins>
        <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.1</version>
        <configuration>
          <source>1.6</source>
          <target>1.6</target>
          <project>
            <build>
                <scriptSourceDirectory>src/main/java</scriptSourceDirectory>
                <testSourceDirectory>src/test/java</testSourceDirectory>
            </build>
          </project>
        </configuration>
        <executions>
         <execution>
           <id>compile</id>
           <phase>compile</phase>
           <goals>
             <goal>compile</goal>
           </goals>
         </execution>
         <execution>
           <id>test-java</id>
           <phase>test</phase>
           <goals>
             <goal>testCompile</goal>
           </goals>
         </execution>
       </executions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.gmaven</groupId>
        <artifactId>gmaven-plugin</artifactId>
        <version>1.2</version>
        <extensions>true</extensions>
        <configuration>
            <project>
            <build>
                <sourceDirectory>src/main/groovy</sourceDirectory>
                <testSourceDirectory>src/test/groovy</testSourceDirectory>
            </build>
            </project>
        </configuration>
      </plugin>
      <plugin>
    <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
            <executions>
                <execution>
                    <id>compile</id>
                    <phase>compile</phase>
                    <configuration>
                        <tasks>
                            <mkdir dir="${basedir}/src/main/groovy"/>
                            <taskdef name="groovyc"
                                classname="org.codehaus.groovy.ant.Groovyc">
                                <classpath refid="maven.compile.classpath"/>
                            </taskdef>
                            <mkdir dir="${project.build.outputDirectory}"/>
                            <groovyc destdir="${project.build.outputDirectory}"
                                srcdir="${basedir}/src/main/groovy/" listfiles="true">
                                <classpath refid="maven.compile.classpath"/>
                            </groovyc>
                        </tasks>
                    </configuration>
                    <goals>
                        <goal>run</goal>
                    </goals>
                </execution>
                <execution>
                    <id>test-compile</id>
                    <phase>test-compile</phase>
                    <configuration>
                        <tasks>
                            <mkdir dir="${basedir}/src/test/groovy"/>
                            <taskdef name="groovyc"
                                classname="org.codehaus.groovy.ant.Groovyc">
                                <classpath refid="maven.compile.classpath"/>
                            </taskdef>
                            <mkdir dir="${project.build.testOutputDirectory}"/>
                            <groovyc destdir="${project.build.testOutputDirectory}"
                                srcdir="${basedir}/src/test/groovy/" listfiles="true">
                                <classpath refid="maven.test.classpath"/>
                            </groovyc>
                        </tasks>
                    </configuration>
                    <goals>
                        <goal>run</goal>
                    </goals>
                </execution>
            </executions>
       </plugin>      
    </plugins>
  </build>
</project>

######################################################################################

<?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>interop</groupId>
  <artifactId>interop</artifactId>
  <packaging>pom</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>interop</name>

  <repositories>
    <repository>
      <id>central</id>
      <url>http://repo1.maven.org/maven2</url>
    </repository>
  </repositories>

  <dependencies>
  </dependencies>

  <build>
    <plugins>
    </plugins>
  </build>
  <modules>
    <module>functional</module>
    <module>consumer</module>
    <module>domainobjects</module>
  </modules>

</project>

From Chas Emerick's answer to my original question, I have setup this small maven project:

interop ---- domainobjects ---- IFoo.java
                           ---- TypedObject.java
                           ---- pom.xml

        ---- functional    ---- fooimpl.clj
                           ---- pom.xml

        ---- consumer      ---- JavaConsumer.java
                           ---- JavaConsumerTest.groovy
                           ---- pom.xml
        ---- pom.xml

######################################################################################

package com.tobeconsumed.byjava;

import java.util.List;

public interface IFoo {
    List<TypedObject> createListOfTypedObjects(String message);
}


package com.tobeconsumed.byjava;

public class TypedObject {

    private String property;

    public String getProperty() {
        return property;
    }

    public void setProperty(String property) {
        this.property = property;
    }
}

<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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <artifactId>interop</artifactId>
    <groupId>interop</groupId>
    <version>0.0.1-SNAPSHOT</version>
  </parent>
  <groupId>interop</groupId>
  <artifactId>domainobjects</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>domainobjects</name>
  <description>Contains all of the domain objects.</description>

  <dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.8.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-all</artifactId>
      <version>1.7.4</version>
    </dependency>    
  </dependencies>

  <build>

    <finalName>domainobjects</finalName>

    <plugins>
        <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.1</version>
        <configuration>
          <source>1.6</source>
          <target>1.6</target>
          <project>
            <build>
                <scriptSourceDirectory>src/main/java</scriptSourceDirectory>
                <testSourceDirectory>src/test/java</testSourceDirectory>
            </build>
          </project>
        </configuration>
        <executions>
         <execution>
           <id>compile</id>
           <phase>compile</phase>
           <goals>
             <goal>compile</goal>
           </goals>
         </execution>
         <execution>
           <id>test-java</id>
           <phase>test</phase>
           <goals>
             <goal>testCompile</goal>
           </goals>
         </execution>
       </executions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.gmaven</groupId>
        <artifactId>gmaven-plugin</artifactId>
        <version>1.2</version>
        <extensions>true</extensions>
        <configuration>
            <project>
            <build>
                <sourceDirectory>src/main/groovy</sourceDirectory>
                <testSourceDirectory>src/test/groovy</testSourceDirectory>
            </build>
            </project>
        </configuration>
      </plugin>
      <plugin>
    <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
            <executions>
                <execution>
                    <id>compile</id>
                    <phase>compile</phase>
                    <configuration>
                        <tasks>
                            <mkdir dir="${basedir}/src/main/groovy"/>
                            <taskdef name="groovyc"
                                classname="org.codehaus.groovy.ant.Groovyc">
                                <classpath refid="maven.compile.classpath"/>
                            </taskdef>
                            <mkdir dir="${project.build.outputDirectory}"/>
                            <groovyc destdir="${project.build.outputDirectory}"
                                srcdir="${basedir}/src/main/groovy/" listfiles="true">
                                <classpath refid="maven.compile.classpath"/>
                            </groovyc>
                        </tasks>
                    </configuration>
                    <goals>
                        <goal>run</goal>
                    </goals>
                </execution>
                <execution>
                    <id>test-compile</id>
                    <phase>test-compile</phase>
                    <configuration>
                        <tasks>
                            <mkdir dir="${basedir}/src/test/groovy"/>
                            <taskdef name="groovyc"
                                classname="org.codehaus.groovy.ant.Groovyc">
                                <classpath refid="maven.compile.classpath"/>
                            </taskdef>
                            <mkdir dir="${project.build.testOutputDirectory}"/>
                            <groovyc destdir="${project.build.testOutputDirectory}"
                                srcdir="${basedir}/src/test/groovy/" listfiles="true">
                                <classpath refid="maven.test.classpath"/>
                            </groovyc>
                        </tasks>
                    </configuration>
                    <goals>
                        <goal>run</goal>
                    </goals>
                </execution>
            </executions>
       </plugin>      
    </plugins>
  </build>

</project>


######################################################################################

(ns com.tobeconsumed.byjava.fooimpl
  (:import com.tobeconsumed.byjava.IFoo)
  (:gen-class
    :implements [com.tobeconsumed.byjava.IFoo]))

(defn -createListOfTypedObjects
  "Creates and returns a list of TypedObjects"
  [this message]
  (println message)
  [(TypedObject.), (TypedObject.), (TypedObject.), (TypedObject.)])

<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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <artifactId>interop</artifactId>
    <groupId>interop</groupId>
    <version>0.0.1-SNAPSHOT</version>
  </parent>
  <groupId>interop</groupId>
  <artifactId>functional</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>functional</name>
  <description>Some functional code.</description>

  <repositories>
    <repository>
      <id>clojars</id>
      <url>http://clojars.org/repo/</url>
    </repository>
    <repository>
      <id>clojure-releases</id>
      <url>http://build.clojure.org/releases</url>
    </repository>
    <repository>
      <id>clojure-snapshots</id>
      <url>http://build.clojure.org/snapshots</url>
    </repository>
    <repository>
      <id>central</id>
      <url>http://repo1.maven.org/maven2</url>
    </repository>
  </repositories>

  <dependencies>
    <dependency>
      <groupId>interop</groupId>
      <artifactId>domainobjects</artifactId>
      <version>0.0.1-SNAPSHOT</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.clojure</groupId>
      <artifactId>clojure</artifactId>
      <version>1.2.0</version>
      <type>pom</type>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.clojure</groupId>
      <artifactId>clojure-contrib</artifactId>
      <version>1.2.0</version>
      <type>pom</type>
      <scope>compile</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
        <plugin>
        <groupId>com.theoryinpractise</groupId>
        <artifactId>clojure-maven-plugin</artifactId>
        <version>1.3.3</version>
        <configuration>
            <project>
                <build>
                    <sourceDirectory>src/main/clojure</sourceDirectory>
                    <testSourceDirectory>src/test/clojure</testSourceDirectory>
                </build>
            </project>
        </configuration>
        <executions>
         <execution>
           <id>compile</id>
           <phase>compile</phase>
           <goals>
             <goal>compile</goal>
           </goals>
         </execution>
         <execution>
           <id>test-clojure</id>
           <phase>test</phase>
           <goals>
             <goal>test</goal>
           </goals>
         </execution>
       </executions>
      </plugin>
    </plugins>
  </build>

</project>


######################################################################################



package consumer;

import java.util.List;

import com.tobeconsumed.byjava.IFoo;
import com.tobeconsumed.byjava.TypedObject;
import com.tobeconsumed.byjava.fooimpl;

public class JavaConsumer {

    public List<TypedObject> callCreateListOfTypedObjects() {
        IFoo foo = new fooimpl();
        List<TypedObject> listOfTypedObject = foo.createListOfTypedObjects("Returning typed a list");
        return listOfTypedObject;
    }

}


package consumer;

import junit.framework.TestCase;

public class JavaConsumerTest extends TestCase {

    private JavaConsumer javaConsumer;

    protected void setUp() throws Exception {
        javaConsumer = new JavaConsumer();
        super.setUp();
    }

    protected void tearDown() throws Exception {
        javaConsumer = null;
        super.tearDown();
    }

    public void testCallShowMessage() {
        assertNotNull(javaConsumer);
        def result = javaConsumer.callCreateListOfTypedObjects();

        assert 4 == result.size()
    }

}


<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <artifactId>interop</artifactId>
    <groupId>interop</groupId>
    <version>0.0.1-SNAPSHOT</version>
  </parent>
  <groupId>interop</groupId>
  <artifactId>consumer</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>
  <name>consumer</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>interop</groupId>
      <artifactId>functional</artifactId>
      <version>0.0.1-SNAPSHOT</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>interop</groupId>
      <artifactId>domainobjects</artifactId>
      <version>0.0.1-SNAPSHOT</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.8.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-all</artifactId>
      <version>1.7.4</version>
    </dependency>    
  </dependencies>
  <build>

    <finalName>consumer</finalName>

    <plugins>
        <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.1</version>
        <configuration>
          <source>1.6</source>
          <target>1.6</target>
          <project>
            <build>
                <scriptSourceDirectory>src/main/java</scriptSourceDirectory>
                <testSourceDirectory>src/test/java</testSourceDirectory>
            </build>
          </project>
        </configuration>
        <executions>
         <execution>
           <id>compile</id>
           <phase>compile</phase>
           <goals>
             <goal>compile</goal>
           </goals>
         </execution>
         <execution>
           <id>test-java</id>
           <phase>test</phase>
           <goals>
             <goal>testCompile</goal>
           </goals>
         </execution>
       </executions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.gmaven</groupId>
        <artifactId>gmaven-plugin</artifactId>
        <version>1.2</version>
        <extensions>true</extensions>
        <configuration>
            <project>
            <build>
                <sourceDirectory>src/main/groovy</sourceDirectory>
                <testSourceDirectory>src/test/groovy</testSourceDirectory>
            </build>
            </project>
        </configuration>
      </plugin>
      <plugin>
    <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
            <executions>
                <execution>
                    <id>compile</id>
                    <phase>compile</phase>
                    <configuration>
                        <tasks>
                            <mkdir dir="${basedir}/src/main/groovy"/>
                            <taskdef name="groovyc"
                                classname="org.codehaus.groovy.ant.Groovyc">
                                <classpath refid="maven.compile.classpath"/>
                            </taskdef>
                            <mkdir dir="${project.build.outputDirectory}"/>
                            <groovyc destdir="${project.build.outputDirectory}"
                                srcdir="${basedir}/src/main/groovy/" listfiles="true">
                                <classpath refid="maven.compile.classpath"/>
                            </groovyc>
                        </tasks>
                    </configuration>
                    <goals>
                        <goal>run</goal>
                    </goals>
                </execution>
                <execution>
                    <id>test-compile</id>
                    <phase>test-compile</phase>
                    <configuration>
                        <tasks>
                            <mkdir dir="${basedir}/src/test/groovy"/>
                            <taskdef name="groovyc"
                                classname="org.codehaus.groovy.ant.Groovyc">
                                <classpath refid="maven.compile.classpath"/>
                            </taskdef>
                            <mkdir dir="${project.build.testOutputDirectory}"/>
                            <groovyc destdir="${project.build.testOutputDirectory}"
                                srcdir="${basedir}/src/test/groovy/" listfiles="true">
                                <classpath refid="maven.test.classpath"/>
                            </groovyc>
                        </tasks>
                    </configuration>
                    <goals>
                        <goal>run</goal>
                    </goals>
                </execution>
            </executions>
       </plugin>      
    </plugins>
  </build>
</project>

######################################################################################

<?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>interop</groupId>
  <artifactId>interop</artifactId>
  <packaging>pom</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>interop</name>

  <repositories>
    <repository>
      <id>central</id>
      <url>http://repo1.maven.org/maven2</url>
    </repository>
  </repositories>

  <dependencies>
  </dependencies>

  <build>
    <plugins>
    </plugins>
  </build>
  <modules>
    <module>functional</module>
    <module>consumer</module>
    <module>domainobjects</module>
  </modules>

</project>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文