|
1 |
| -# 🌈 JVM Rainbow |
| 1 | +# 🌈 JVM Rainbow |
| 2 | +## Using Java, Scala, Kotlin and Groovy |
| 3 | + |
| 4 | +This projects demonstrates the possibility of writing and using multiple JVM languages in a single project and single root package with Maven. It serves to help others to easily configure their project if they need a subset or the whole configuration. |
| 5 | +This small project has been extracted from the following project: [hakky54/mutual-tls-ssl](https://github.com/Hakky54/mutual-tls-ssl) which contains example http client configuration and example http requests written in Java, Scala, Kotlin and Groovy. |
| 6 | + |
| 7 | +On this page you can find the [dependency](#required-dependencies) and [compiler/plugin configuration](#compiler-configuration) however, the detailed project configuration can be found in the [pom](pom.xml) file which contains the exact dependency/plugin version and configuration for unit testing. |
| 8 | +Unit tests are also present and integrated in the maven test phase. Run `mvn verify` to see it in action |
| 9 | + |
| 10 | +## Compiler configuration |
| 11 | +```xml |
| 12 | +<plugin> |
| 13 | + <groupId>org.apache.maven.plugins</groupId> |
| 14 | + <artifactId>maven-compiler-plugin</artifactId> |
| 15 | + <version>${version.maven-compiler-plugin}</version> |
| 16 | + <executions> |
| 17 | + <execution> |
| 18 | + <id>default-compile</id> |
| 19 | + <phase>none</phase> |
| 20 | + </execution> |
| 21 | + <execution> |
| 22 | + <id>default-testCompile</id> |
| 23 | + <phase>none</phase> |
| 24 | + </execution> |
| 25 | + <execution> |
| 26 | + <id>java-compile</id> |
| 27 | + <phase>compile</phase> |
| 28 | + <goals> |
| 29 | + <goal>compile</goal> |
| 30 | + </goals> |
| 31 | + </execution> |
| 32 | + <execution> |
| 33 | + <id>java-test-compile</id> |
| 34 | + <phase>test-compile</phase> |
| 35 | + <goals> |
| 36 | + <goal>testCompile</goal> |
| 37 | + </goals> |
| 38 | + </execution> |
| 39 | + </executions> |
| 40 | +</plugin> |
| 41 | + |
| 42 | +<plugin> |
| 43 | + <groupId>org.jetbrains.kotlin</groupId> |
| 44 | + <artifactId>kotlin-maven-plugin</artifactId> |
| 45 | + <version>${version.kotlin}</version> |
| 46 | + <configuration> |
| 47 | + <jvmTarget>11</jvmTarget> |
| 48 | + </configuration> |
| 49 | + <executions> |
| 50 | + <execution> |
| 51 | + <id>compile</id> |
| 52 | + <goals> |
| 53 | + <goal>compile</goal> |
| 54 | + </goals> |
| 55 | + <configuration> |
| 56 | + <sourceDirs> |
| 57 | + <sourceDir>${project.basedir}/src/main/java</sourceDir> |
| 58 | + </sourceDirs> |
| 59 | + </configuration> |
| 60 | + </execution> |
| 61 | + <execution> |
| 62 | + <id>test-compile</id> |
| 63 | + <goals> |
| 64 | + <goal>test-compile</goal> |
| 65 | + </goals> |
| 66 | + <configuration> |
| 67 | + <sourceDirs> |
| 68 | + <sourceDir>${project.basedir}/src/test/java</sourceDir> |
| 69 | + </sourceDirs> |
| 70 | + </configuration> |
| 71 | + </execution> |
| 72 | + </executions> |
| 73 | +</plugin> |
| 74 | + |
| 75 | +<plugin> |
| 76 | + <groupId>net.alchim31.maven</groupId> |
| 77 | + <artifactId>scala-maven-plugin</artifactId> |
| 78 | + <version>${version.scala-maven-plugin}</version> |
| 79 | + <executions> |
| 80 | + <execution> |
| 81 | + <goals> |
| 82 | + <goal>compile</goal> |
| 83 | + <goal>testCompile</goal> |
| 84 | + </goals> |
| 85 | + </execution> |
| 86 | + </executions> |
| 87 | +</plugin> |
| 88 | + |
| 89 | +<plugin> |
| 90 | + <groupId>org.codehaus.gmavenplus</groupId> |
| 91 | + <artifactId>gmavenplus-plugin</artifactId> |
| 92 | + <version>${version.gmavenplus-plugin}</version> |
| 93 | + <executions> |
| 94 | + <execution> |
| 95 | + <id>groovy</id> |
| 96 | + <goals> |
| 97 | + <goal>addSources</goal> |
| 98 | + <goal>addTestSources</goal> |
| 99 | + <goal>generateStubs</goal> |
| 100 | + <goal>compile</goal> |
| 101 | + <goal>generateTestStubs</goal> |
| 102 | + <goal>compileTests</goal> |
| 103 | + <goal>removeStubs</goal> |
| 104 | + <goal>removeTestStubs</goal> |
| 105 | + </goals> |
| 106 | + </execution> |
| 107 | + </executions> |
| 108 | + <configuration> |
| 109 | + <sources> |
| 110 | + <source> |
| 111 | + <directory>${project.basedir}/src/main/java</directory> |
| 112 | + <includes> |
| 113 | + <include>**/*.groovy</include> |
| 114 | + </includes> |
| 115 | + </source> |
| 116 | + </sources> |
| 117 | + <testSources> |
| 118 | + <testSource> |
| 119 | + <directory>${project.basedir}/src/test/java</directory> |
| 120 | + <includes> |
| 121 | + <include>**/*.groovy</include> |
| 122 | + </includes> |
| 123 | + </testSource> |
| 124 | + </testSources> |
| 125 | + </configuration> |
| 126 | + <dependencies> |
| 127 | + <dependency> |
| 128 | + <groupId>org.apache.groovy</groupId> |
| 129 | + <artifactId>groovy</artifactId> |
| 130 | + <version>${version.groovy}</version> |
| 131 | + <scope>runtime</scope> |
| 132 | + </dependency> |
| 133 | + </dependencies> |
| 134 | +</plugin> |
| 135 | + |
| 136 | +<plugin> |
| 137 | + <groupId>org.scalatest</groupId> |
| 138 | + <artifactId>scalatest-maven-plugin</artifactId> |
| 139 | + <version>${version.scalatest-maven-plugin}</version> |
| 140 | + <executions> |
| 141 | + <execution> |
| 142 | + <id>test</id> |
| 143 | + <goals> |
| 144 | + <goal>test</goal> |
| 145 | + </goals> |
| 146 | + </execution> |
| 147 | + </executions> |
| 148 | +</plugin> |
| 149 | +``` |
| 150 | + |
| 151 | +## Required dependencies |
| 152 | +```xml |
| 153 | +<dependency> |
| 154 | + <groupId>org.jetbrains.kotlin</groupId> |
| 155 | + <artifactId>kotlin-stdlib</artifactId> |
| 156 | + <version>${version.kotlin}</version> |
| 157 | +</dependency> |
| 158 | +<dependency> |
| 159 | + <groupId>org.scala-lang</groupId> |
| 160 | + <artifactId>scala-library</artifactId> |
| 161 | + <version>${version.scala-compiler}</version> |
| 162 | +</dependency> |
| 163 | +<dependency> |
| 164 | + <groupId>org.scala-lang</groupId> |
| 165 | + <artifactId>scala-compiler</artifactId> |
| 166 | + <version>${version.scala-compiler}</version> |
| 167 | +</dependency> |
| 168 | +<dependency> |
| 169 | + <groupId>org.apache.groovy</groupId> |
| 170 | + <artifactId>groovy</artifactId> |
| 171 | + <version>${version.groovy}</version> |
| 172 | +</dependency> |
| 173 | +``` |
0 commit comments