Last active
July 24, 2021 04:22
-
-
Save pfmiles/2f2ab77f06d48384f113 to your computer and use it in GitHub Desktop.
groovy与java混编的jar工程的maven pom.xml配置
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> | |
<groupId>com.github.pfmiles</groupId> | |
<artifactId>jar.groovy</artifactId> | |
<version>1.0-SNAPSHOT</version> | |
<packaging>jar</packaging> | |
<name>jar.groovy</name> | |
<url>http://maven.apache.org</url> | |
<properties> | |
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | |
<maven.compiler.source>1.6</maven.compiler.source> | |
<maven.compiler.target>1.6</maven.compiler.target> | |
</properties> | |
<dependencies> | |
<dependency> | |
<groupId>org.codehaus.groovy</groupId> | |
<artifactId>groovy-all</artifactId> | |
<version>2.4.1</version> | |
<!-- Uncomment line below to use invokedynamic version of Groovy (requires | |
Java 7 or higher). --> | |
<!-- <classifier>indy</classifier> --> | |
</dependency> | |
<dependency> | |
<groupId>junit</groupId> | |
<artifactId>junit</artifactId> | |
<version>3.8.1</version> | |
<scope>test</scope> | |
</dependency> | |
</dependencies> | |
<!-- 使用maven-antrun-plugin好处是可以使用最新版groovy-all,缺点是目前无法满足java和groovy源码分开放置的编译方式,只能全部放在main/groovy或main/java中 --> | |
<build> | |
<plugins> | |
<plugin> | |
<artifactId>maven-antrun-plugin</artifactId> | |
<version>1.8</version> | |
<executions> | |
<execution> | |
<id>compile</id> | |
<phase>generate-sources</phase> | |
<configuration> | |
<target> | |
<taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc"> | |
<classpath refid="maven.compile.classpath" /> | |
</taskdef> | |
<mkdir dir="${project.build.outputDirectory}" /> | |
<groovyc srcdir="${basedir}/src/main/groovy" destdir="${project.build.outputDirectory}" | |
encoding="${project.build.sourceEncoding}"> | |
<classpath refid="maven.compile.classpath" /> | |
</groovyc> | |
</target> | |
</configuration> | |
<goals> | |
<goal>run</goal> | |
</goals> | |
</execution> | |
<execution> | |
<id>test-compile</id> | |
<phase>generate-test-sources</phase> | |
<configuration> | |
<target> | |
<taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc"> | |
<classpath refid="maven.test.classpath" /> | |
</taskdef> | |
<mkdir dir="${project.build.testOutputDirectory}" /> | |
<groovyc srcdir="${basedir}/src/test/groovy" destdir="${project.build.testOutputDirectory}" | |
encoding="${project.build.sourceEncoding}"> | |
<classpath refid="maven.test.classpath" /> | |
</groovyc> | |
</target> | |
</configuration> | |
<goals> | |
<goal>run</goal> | |
</goals> | |
</execution> | |
</executions> | |
</plugin> | |
<plugin> | |
<groupId>org.codehaus.mojo</groupId> | |
<artifactId>build-helper-maven-plugin</artifactId> | |
<version>1.9.1</version> | |
<executions> | |
<execution> | |
<id>add-source</id> | |
<phase>generate-sources</phase> | |
<goals> | |
<goal>add-source</goal> | |
</goals> | |
<configuration> | |
<sources> | |
<source>${basedir}/src/main/groovy</source> | |
</sources> | |
</configuration> | |
</execution> | |
<execution> | |
<id>add-test-source</id> | |
<phase>generate-test-sources</phase> | |
<goals> | |
<goal>add-test-source</goal> | |
</goals> | |
<configuration> | |
<sources> | |
<source>${basedir}/src/test/groovy</source> | |
</sources> | |
</configuration> | |
</execution> | |
</executions> | |
</plugin> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-eclipse-plugin</artifactId> | |
<version>2.9</version> | |
<configuration> | |
<additionalProjectnatures> | |
<projectnature>org.eclipse.jdt.groovy.core.groovyNature</projectnature> | |
</additionalProjectnatures> | |
<sourceIncludes> | |
<sourceInclude>**/*.groovy</sourceInclude> | |
</sourceIncludes> | |
<downloadSources>true</downloadSources> | |
<downloadJavadocs>true</downloadJavadocs> | |
</configuration> | |
</plugin> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-compiler-plugin</artifactId> | |
<version>3.2</version> | |
</plugin> | |
</plugins> | |
</build> | |
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> | |
<groupId>com.github.pfmiles</groupId> | |
<artifactId>kan-java</artifactId> | |
<version>0.1</version> | |
<packaging>jar</packaging> | |
<name>kan-java</name> | |
<url>https://github.com/pfmiles/kan-java</url> | |
<properties> | |
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | |
<maven.compiler.source>1.6</maven.compiler.source> | |
<maven.compiler.target>1.6</maven.compiler.target> | |
</properties> | |
<profiles> | |
<profile> | |
<id>unix_profile</id> | |
<activation> | |
<os> | |
<family>unix</family> | |
</os> | |
</activation> | |
<properties> | |
<toolsjar>${java.home}/../lib/tools.jar</toolsjar> | |
</properties> | |
</profile> | |
<profile> | |
<id>windows_profile</id> | |
<activation> | |
<os> | |
<family>windows</family> | |
</os> | |
</activation> | |
<properties> | |
<toolsjar>${java.home}/../lib/tools.jar</toolsjar> | |
</properties> | |
</profile> | |
<profile> | |
<id>osx_profile</id> | |
<activation> | |
<os> | |
<family>mac</family> | |
</os> | |
</activation> | |
<properties> | |
<toolsjar>${java.home}/../Classes/classes.jar</toolsjar> | |
</properties> | |
</profile> | |
</profiles> | |
<dependencies> | |
<dependency> | |
<groupId>org.codehaus.groovy</groupId> | |
<artifactId>groovy-all</artifactId> | |
<version>2.3.7</version> | |
<!-- Uncomment line below to use invokedynamic version of Groovy (requires | |
Java 7 or higher). --> | |
<!-- <classifier>indy</classifier> --> | |
</dependency> | |
<dependency> | |
<groupId>com.sun</groupId> | |
<artifactId>tools</artifactId> | |
<version>1.6.0</version> | |
<scope>system</scope> | |
<systemPath>${toolsjar}</systemPath> | |
</dependency> | |
<dependency> | |
<groupId>junit</groupId> | |
<artifactId>junit</artifactId> | |
<version>3.8.1</version> | |
<scope>test</scope> | |
</dependency> | |
</dependencies> | |
<build> | |
<plugins> | |
<plugin> | |
<groupId>org.codehaus.mojo</groupId> | |
<artifactId>build-helper-maven-plugin</artifactId> | |
<version>1.9.1</version> | |
<executions> | |
<execution> | |
<id>add-source</id> | |
<phase>generate-sources</phase> | |
<goals> | |
<goal>add-source</goal> | |
</goals> | |
<configuration> | |
<sources> | |
<source>${basedir}/src/main/groovy</source> | |
</sources> | |
</configuration> | |
</execution> | |
<execution> | |
<id>add-test-source</id> | |
<phase>generate-test-sources</phase> | |
<goals> | |
<goal>add-test-source</goal> | |
</goals> | |
<configuration> | |
<sources> | |
<source>${basedir}/src/test/groovy</source> | |
</sources> | |
</configuration> | |
</execution> | |
</executions> | |
</plugin> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-eclipse-plugin</artifactId> | |
<version>2.9</version> | |
<configuration> | |
<additionalProjectnatures> | |
<projectnature>org.eclipse.jdt.groovy.core.groovyNature</projectnature> | |
</additionalProjectnatures> | |
<sourceIncludes> | |
<sourceInclude>**/*.groovy</sourceInclude> | |
</sourceIncludes> | |
<downloadSources>true</downloadSources> | |
<downloadJavadocs>true</downloadJavadocs> | |
</configuration> | |
</plugin> | |
<!-- 使用groovy-eclipse-compiler的好处是java和groovy源码可分别放置在main/java和main/groovy下,缺点是没法使用最新的groovy(限制于groovy-eclipse-batch的支持版本) --> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-compiler-plugin</artifactId> | |
<version>3.2</version> | |
<configuration> | |
<compilerId>groovy-eclipse-compiler</compilerId> | |
</configuration> | |
<dependencies> | |
<dependency> | |
<groupId>org.codehaus.groovy</groupId> | |
<artifactId>groovy-eclipse-compiler</artifactId> | |
<version>2.9.1-01</version> | |
</dependency> | |
<!-- for 2.8.0-01 and later you must have an explicit dependency on groovy-eclipse-batch --> | |
<dependency> | |
<groupId>org.codehaus.groovy</groupId> | |
<artifactId>groovy-eclipse-batch</artifactId> | |
<version>2.3.7-01</version> | |
</dependency> | |
</dependencies> | |
</plugin> | |
</plugins> | |
</build> | |
</project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment