在java的基础上包装了一层语法糖。虽然语法上比java要轻便灵活,但实际上会生成很多辅助类,内存消耗会更多。
idea 通过引入groovy-sdk 可以完成groovy的编译
若想要通过maven 编译项目
maven 配置一览
<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>SocketServer</groupId>
<artifactId>SocketServer</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>maven</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<name>Maven Central Repository</name>
<url>https://maven.aliyun.com/repository/central</url>
</pluginRepository>
<pluginRepository>
<id>jcenter</id>
<name>Java Center Repository</name>
<url>https://maven.aliyun.com/repository/jcenter</url>
</pluginRepository>
</pluginRepositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.8.1</version>
<executions>
<execution>
<goals>
<goal>addSources</goal>
<goal>addTestSources</goal>
<goal>generateStubs</goal>
<goal>compile</goal>
<goal>generateTestStubs</goal>
<goal>compileTests</goal>
<goal>removeStubs</goal>
<goal>removeTestStubs</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>org.robin.Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>central</id>
<name>Maven Central Repository</name>
<url>https://maven.aliyun.com/repository/central</url>
</repository>
<repository>
<id>jcenter</id>
<name>Java Center Repository</name>
<url>https://maven.aliyun.com/repository/jcenter</url>
</repository>
</repositories>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.codehaus.groovy/groovy-bsf -->
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-bsf</artifactId>
<version>3.0.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.codehaus.groovy/groovy-cli-commons -->
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-cli-commons</artifactId>
<version>3.0.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.codehaus.groovy/groovy-yaml -->
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-yaml</artifactId>
<version>3.0.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.codehaus.groovy/groovy-jaxb -->
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-jaxb</artifactId>
<version>3.0.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.codehaus.groovy/groovy-dateutil -->
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-dateutil</artifactId>
<version>3.0.5</version>
</dependency>
</dependencies>
</project>
大致说明 第一引入 groovy-all 包 但groovy-all 比groovy-sdk 少了一些依赖包 需要手动引入groovy-xxx的包
第二 引入打包配置与方式 添加gmaven插件以编译打包groovy文件
另一个就是可执行jar包 和 第三方依赖包的问题了