diff --git a/.github/workflows/job.build.yml b/.github/workflows/job.build.yml index 6dfbbd1..922621d 100644 --- a/.github/workflows/job.build.yml +++ b/.github/workflows/job.build.yml @@ -43,8 +43,13 @@ jobs: java-version: "24" - name: "Setup: Elide" uses: elide-dev/setup-elide@990b915b2974a70e7654acb1303607b4cd1d3538 # v2.0.0 - - name: "Build: Plugin" - run: ./gradlew build publishToMavenLocal - - name: "Test: Plugin" - working-directory: sample - run: ./mvnw clean package + - name: "Build: Java Compiler" + run: ./mvnw clean install -pl plexus-compilers + - name: "Build: Kotlin Plugin" + run: ./mvnw clean install -pl kotlin-plugin + - name: "Test: Java Compiler" + run: ./mvnw clean package -pl sample-java + - name: "Test: Kotlin Plugin" + run: ./mvnw clean package -pl sample-kotlin + - name: "Test: Mixed source" + run: ./mvnw clean package -pl sample-mixed diff --git a/.github/workflows/on.pr.yml b/.github/workflows/on.pr.yml index 31314cd..a33445a 100644 --- a/.github/workflows/on.pr.yml +++ b/.github/workflows/on.pr.yml @@ -1,7 +1,7 @@ name: "PR" "on": - pull_request: {} + pull_request: { } permissions: contents: "read" diff --git a/.gitignore b/.gitignore index 108d567..b425f09 100644 --- a/.gitignore +++ b/.gitignore @@ -1,20 +1,13 @@ -.gradle -build/ -!gradle/wrapper/gradle-wrapper.jar -!**/src/main/**/build/ -!**/src/test/**/build/ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ ### IntelliJ IDEA ### .idea/ *.iws *.iml *.ipr -out/ -!**/src/main/**/out/ -!**/src/test/**/out/ - -### Kotlin ### -.kotlin ### Eclipse ### .apt_generated @@ -24,9 +17,6 @@ out/ .settings .springBeans .sts4-cache -bin/ -!**/src/main/**/bin/ -!**/src/test/**/bin/ ### NetBeans ### /nbproject/private/ @@ -34,6 +24,9 @@ bin/ /dist/ /nbdist/ /.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ ### VS Code ### .vscode/ diff --git a/sample/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties similarity index 100% rename from sample/.mvn/wrapper/maven-wrapper.properties rename to .mvn/wrapper/maven-wrapper.properties diff --git a/README.md b/README.md index d2bb4da..2b07ea1 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Elide Maven Plugin -This plugin can be consumed in a Maven project to use [Elide](https://elide.dev). +This plugin can be consumed in a Maven project to use [Elide](https://elide.dev) for compiling Java and Kotlin sources. > [!WARNING] > This plugin is currently under development. @@ -9,44 +9,170 @@ This plugin can be consumed in a Maven project to use [Elide](https://elide.dev) - [x] Swap out `javac ...` for `elide javac -- ...` - [x] Supports explicit path to `elide` -- [ ] Resolve `elide` via the `PATH` -- [ ] Swap out `kotlinc ...` for `elide kotlinc -- ...` +- [x] Resolve `elide` via the `PATH` +- [x] Swap out `kotlinc ...` for `elide kotlinc -- ...` - [ ] Usability of Elide as a Maven toolchain ## Usage +### Java + Configuring Elide as your `javac` compiler: **`pom.xml`** ```xml - - - - maven-compiler-plugin - 3.13.0 - - - dev.elide - elide-plexus-compilers - 1.0.0-SNAPSHOT - - - - elide - - - - + + + + maven-compiler-plugin + 3.14.0 + + + dev.elide + elide-plexus-compilers + 1.0.0 + + + + elide + + + + +``` + +> [!TIP] +> See the [Java sample project](sample-java) for a usage example. Elide also provides +> a [Gradle plugin](https://github.com/elide-dev/gradle). + +### Kotlin + +Configuring the Elide Kotlin plugin is done the exact same way as configuring the Kotlin Maven plugin, just replacing +the plugin coordinates: + +**`pom.xml`** +```xml + + src/main/kotlin + src/test/kotlin + + + dev.elide + elide-kotlin-maven-plugin + 1.0.0 + + + compile + + compile + + + + test-compile + + test-compile + + + + + + + + + + org.jetbrains.kotlin + kotlin-stdlib + 2.2.0 + + ``` -Properties needed: +> [!TIP] +> See the [Kotlin sample project](sample-kotlin) for a usage example. + +### Mixed Java and Kotlin + +By combining the Kotlin configuration and Java compiler replacement, mixed Java and Kotlin sources can be compiled with +Elide: + +**`pom.xml`** + ```xml - - 24 - 24 - UTF-8 - + + + + dev.elide + elide-kotlin-maven-plugin + 1.0.0 + + + compile + + compile + + + + ${project.basedir}/src/main/kotlin + ${project.basedir}/src/main/java + + + + + test-compile + + test-compile + + + + ${project.basedir}/src/test/kotlin + ${project.basedir}/src/test/java + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.14.0 + + + dev.elide + elide-plexus-compilers + 1.0.0 + + + + elide + + + + default-compile + none + + + default-testCompile + none + + + java-compile + compile + + compile + + + + java-test-compile + test-compile + + testCompile + + + + + + ``` > [!TIP] -> See the [sample project](./sample) for a usage example. Elide also provides a [Gradle plugin](https://github.com/elide-dev/gradle). +> See the [Mixed sources sample project](sample-mixed) for a usage example. \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts deleted file mode 100644 index 8c80f1b..0000000 --- a/build.gradle.kts +++ /dev/null @@ -1,49 +0,0 @@ -import org.jetbrains.kotlin.gradle.dsl.JvmTarget - -plugins { - kotlin("jvm") version "2.1.21" - `java-library` - `maven-publish` -} - -group = "dev.elide" -version = "1.0.0-SNAPSHOT" - -repositories { - mavenCentral() - mavenLocal() -} - -java { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 -} - -kotlin { - jvmToolchain(24) - compilerOptions { - jvmTarget = JvmTarget.JVM_1_8 - } -} - -dependencies { - implementation(libs.plexus.compiler.api) - implementation(libs.javax.inject) - testImplementation(kotlin("test")) -} - -tasks.test { - useJUnitPlatform() -} - -publishing { - publications { - create("maven") { - groupId = "dev.elide" - artifactId = "elide-plexus-compilers" - version = version - - from(components["kotlin"]) - } - } -} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties deleted file mode 100644 index 7fc6f1f..0000000 --- a/gradle.properties +++ /dev/null @@ -1 +0,0 @@ -kotlin.code.style=official diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml deleted file mode 100644 index 5c5893e..0000000 --- a/gradle/libs.versions.toml +++ /dev/null @@ -1,9 +0,0 @@ -[versions] -plexus-compiler = "2.15.0" -javax-inject = "1" - -[libraries] -plexus-compiler-api = { module = "org.codehaus.plexus:plexus-compiler-api", version.ref = "plexus-compiler" } -javax-inject = { module = "javax.inject:javax.inject", version.ref = "javax-inject" } - -[plugins] \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 249e583..0000000 Binary files a/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index c342135..0000000 --- a/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Fri Jun 06 10:21:52 EEST 2025 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.1-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew deleted file mode 100755 index 1b6c787..0000000 --- a/gradlew +++ /dev/null @@ -1,234 +0,0 @@ -#!/bin/sh - -# -# Copyright © 2015-2021 the original authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -############################################################################## -# -# Gradle start up script for POSIX generated by Gradle. -# -# Important for running: -# -# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is -# noncompliant, but you have some other compliant shell such as ksh or -# bash, then to run this script, type that shell name before the whole -# command line, like: -# -# ksh Gradle -# -# Busybox and similar reduced shells will NOT work, because this script -# requires all of these POSIX shell features: -# * functions; -# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», -# «${var#prefix}», «${var%suffix}», and «$( cmd )»; -# * compound commands having a testable exit status, especially «case»; -# * various built-in commands including «command», «set», and «ulimit». -# -# Important for patching: -# -# (2) This script targets any POSIX shell, so it avoids extensions provided -# by Bash, Ksh, etc; in particular arrays are avoided. -# -# The "traditional" practice of packing multiple parameters into a -# space-separated string is a well documented source of bugs and security -# problems, so this is (mostly) avoided, by progressively accumulating -# options in "$@", and eventually passing that to Java. -# -# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, -# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; -# see the in-line comments for details. -# -# There are tweaks for specific operating systems such as AIX, CygWin, -# Darwin, MinGW, and NonStop. -# -# (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt -# within the Gradle project. -# -# You can find Gradle at https://github.com/gradle/gradle/. -# -############################################################################## - -# Attempt to set APP_HOME - -# Resolve links: $0 may be a link -app_path=$0 - -# Need this for daisy-chained symlinks. -while - APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path - [ -h "$app_path" ] -do - ls=$( ls -ld "$app_path" ) - link=${ls#*' -> '} - case $link in #( - /*) app_path=$link ;; #( - *) app_path=$APP_HOME$link ;; - esac -done - -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" -APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD=maximum - -warn () { - echo "$*" -} >&2 - -die () { - echo - echo "$*" - echo - exit 1 -} >&2 - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "$( uname )" in #( - CYGWIN* ) cygwin=true ;; #( - Darwin* ) darwin=true ;; #( - MSYS* | MINGW* ) msys=true ;; #( - NONSTOP* ) nonstop=true ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD=$JAVA_HOME/jre/sh/java - else - JAVACMD=$JAVA_HOME/bin/java - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then - case $MAX_FD in #( - max*) - MAX_FD=$( ulimit -H -n ) || - warn "Could not query maximum file descriptor limit" - esac - case $MAX_FD in #( - '' | soft) :;; #( - *) - ulimit -n "$MAX_FD" || - warn "Could not set maximum file descriptor limit to $MAX_FD" - esac -fi - -# Collect all arguments for the java command, stacking in reverse order: -# * args from the command line -# * the main class name -# * -classpath -# * -D...appname settings -# * --module-path (only if needed) -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. - -# For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) - - JAVACMD=$( cygpath --unix "$JAVACMD" ) - - # Now convert the arguments - kludge to limit ourselves to /bin/sh - for arg do - if - case $arg in #( - -*) false ;; # don't mess with options #( - /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath - [ -e "$t" ] ;; #( - *) false ;; - esac - then - arg=$( cygpath --path --ignore --mixed "$arg" ) - fi - # Roll the args list around exactly as many times as the number of - # args, so each arg winds up back in the position where it started, but - # possibly modified. - # - # NB: a `for` loop captures its iteration list before it begins, so - # changing the positional parameters here affects neither the number of - # iterations, nor the values presented in `arg`. - shift # remove old arg - set -- "$@" "$arg" # push replacement arg - done -fi - -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. - -set -- \ - "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ - "$@" - -# Use "xargs" to parse quoted args. -# -# With -n1 it outputs one arg per line, with the quotes and backslashes removed. -# -# In Bash we could simply go: -# -# readarray ARGS < <( xargs -n1 <<<"$var" ) && -# set -- "${ARGS[@]}" "$@" -# -# but POSIX shell has neither arrays nor command substitution, so instead we -# post-process each arg (as a line of input to sed) to backslash-escape any -# character that might be a shell metacharacter, then use eval to reverse -# that process (while maintaining the separation between arguments), and wrap -# the whole thing up as a single "set" statement. -# -# This will of course break if any of these variables contains a newline or -# an unmatched quote. -# - -eval "set -- $( - printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | - xargs -n1 | - sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | - tr '\n' ' ' - )" '"$@"' - -exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat deleted file mode 100644 index 107acd3..0000000 --- a/gradlew.bat +++ /dev/null @@ -1,89 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/kotlin-plugin/pom.xml b/kotlin-plugin/pom.xml new file mode 100644 index 0000000..32410af --- /dev/null +++ b/kotlin-plugin/pom.xml @@ -0,0 +1,245 @@ + + + 4.0.0 + + dev.elide + elide-kotlin-maven-plugin + 1.0.0 + maven-plugin + + Elide Kotlin Maven Plugin + A drop-in replacement for the Kotlin Maven Plugin that uses Elide to compile Kotlin sources. + https://elide.dev + + + + MIT License + https://www.opensource.org/licenses/mit-license.php + + + + + + Lauri Heino + datafox@datafox.me + Elide + https://elide.dev + + + + + scm:git:git://github.com/elide-dev/maven.git + scm:git:ssh://github.com:elide-dev/maven.git + https://github.com/elide-dev/maven/tree/main + + + + UTF-8 + official + 11 + + 1.0.0 + 2.2.0 + 1 + 2.15.0 + 5.11.1 + 3.9.10 + 3.15.1 + 2.22.2 + 3.14.0 + + + + + mavenCentral + https://repo1.maven.org/maven2/ + + + + + + + org.apache.maven.plugins + maven-plugin-plugin + ${mavenToolsVersion} + + + default-descriptor + + descriptor + + process-classes + + + help-descriptor + + helpmojo + + process-classes + + + + + org.jetbrains.kotlin + kotlin-maven-plugin + ${kotlinVersion} + + + compile + + compile + + + + ${project.basedir}/src/main/kotlin + ${project.basedir}/src/main/java + + + + + test-compile + + test-compile + + + + ${project.basedir}/src/test/kotlin + ${project.basedir}/src/test/java + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${mavenCompilerVersion} + + + dev.elide + elide-plexus-compilers + ${compilerVersion} + + + + elide + 11 + + + + default-compile + none + + + default-testCompile + none + + + java-compile + compile + + compile + + + + java-test-compile + test-compile + + testCompile + + + + + + maven-surefire-plugin + ${mavenTestPluginVersion} + + + maven-failsafe-plugin + ${mavenTestPluginVersion} + + + + + + + org.jetbrains.kotlin + kotlin-test-junit5 + ${kotlinVersion} + test + + + org.junit.jupiter + junit-jupiter + ${junitVersion} + test + + + org.jetbrains.kotlin + kotlin-stdlib + ${kotlinVersion} + + + org.jetbrains.kotlin + kotlin-maven-plugin + ${kotlinVersion} + + + org.apache.maven + maven-plugin-api + ${mavenVersion} + provided + + + org.apache.maven + maven-core + ${mavenVersion} + provided + + + * + * + + + + + org.apache.maven.plugin-tools + maven-plugin-annotations + ${mavenToolsVersion} + + + org.jetbrains.kotlin + kotlin-build-tools-api + ${kotlinVersion} + compile + + + org.jetbrains.kotlin + kotlin-build-tools-impl + ${kotlinVersion} + runtime + + + org.jetbrains.kotlin + kotlin-compiler-embeddable + ${kotlinVersion} + + + org.jetbrains.kotlin + kotlin-scripting-compiler-embeddable + ${kotlinVersion} + + + dev.elide + elide-plexus-compilers + ${compilerVersion} + + + javax.inject + javax.inject + ${injectVersion} + + + \ No newline at end of file diff --git a/kotlin-plugin/src/main/java/dev/elide/maven/plugin/kotlin/ElideKotlinJSCompileMojo.java b/kotlin-plugin/src/main/java/dev/elide/maven/plugin/kotlin/ElideKotlinJSCompileMojo.java new file mode 100644 index 0000000..66955a9 --- /dev/null +++ b/kotlin-plugin/src/main/java/dev/elide/maven/plugin/kotlin/ElideKotlinJSCompileMojo.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024-2025 Elide Technologies, Inc. + * + * Licensed under the MIT license (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * https://opensource.org/license/mit/ + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under the License. + */ +package dev.elide.maven.plugin.kotlin; + +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.ResolutionScope; + +/** + * Elide Kotlin to Javascript compiler Mojo. + * + * @author Lauri Heino + * @since 1.0.0 + */ +/* +Disabled until support exists. + +@Mojo(name = "js", + defaultPhase = LifecyclePhase.COMPILE, + requiresDependencyResolution = ResolutionScope.COMPILE, + threadSafe = true) + */ +public class ElideKotlinJSCompileMojo extends ElideKotlinJSCompileMojoImpl { +} diff --git a/kotlin-plugin/src/main/java/dev/elide/maven/plugin/kotlin/ElideKotlinJSTestCompileMojo.java b/kotlin-plugin/src/main/java/dev/elide/maven/plugin/kotlin/ElideKotlinJSTestCompileMojo.java new file mode 100644 index 0000000..265b833 --- /dev/null +++ b/kotlin-plugin/src/main/java/dev/elide/maven/plugin/kotlin/ElideKotlinJSTestCompileMojo.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024-2025 Elide Technologies, Inc. + * + * Licensed under the MIT license (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * https://opensource.org/license/mit/ + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under the License. + */ +package dev.elide.maven.plugin.kotlin; + +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.ResolutionScope; + +/** + * Elide Kotlin to Javascript test compiler Mojo. + * + * @author Lauri Heino + * @since 1.0.0 + */ +/* +Disabled until support exists. + +@Mojo(name = "test-js", + defaultPhase = LifecyclePhase.TEST_COMPILE, + requiresDependencyResolution = ResolutionScope.TEST, + threadSafe = true) + */ +public class ElideKotlinJSTestCompileMojo extends ElideKotlinJSCompileMojoImpl { +} diff --git a/kotlin-plugin/src/main/java/dev/elide/maven/plugin/kotlin/ElideKotlinJVMCompileMojo.java b/kotlin-plugin/src/main/java/dev/elide/maven/plugin/kotlin/ElideKotlinJVMCompileMojo.java new file mode 100644 index 0000000..df28ea9 --- /dev/null +++ b/kotlin-plugin/src/main/java/dev/elide/maven/plugin/kotlin/ElideKotlinJVMCompileMojo.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024-2025 Elide Technologies, Inc. + * + * Licensed under the MIT license (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * https://opensource.org/license/mit/ + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under the License. + */ +package dev.elide.maven.plugin.kotlin; + +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.ResolutionScope; + +/** + * Elide Kotlin to JVM compiler Mojo. + * + * @author Lauri Heino + * @since 1.0.0 + */ +@Mojo(name = "compile", + defaultPhase = LifecyclePhase.COMPILE, + requiresDependencyResolution = ResolutionScope.COMPILE, + threadSafe = true) +public class ElideKotlinJVMCompileMojo extends ElideKotlinJVMCompileMojoImpl { +} diff --git a/kotlin-plugin/src/main/java/dev/elide/maven/plugin/kotlin/ElideKotlinJVMTestCompileMojo.java b/kotlin-plugin/src/main/java/dev/elide/maven/plugin/kotlin/ElideKotlinJVMTestCompileMojo.java new file mode 100644 index 0000000..074ca72 --- /dev/null +++ b/kotlin-plugin/src/main/java/dev/elide/maven/plugin/kotlin/ElideKotlinJVMTestCompileMojo.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024-2025 Elide Technologies, Inc. + * + * Licensed under the MIT license (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * https://opensource.org/license/mit/ + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under the License. + */ +package dev.elide.maven.plugin.kotlin; + +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.ResolutionScope; + +/** + * Elide Kotlin to JVM test compiler Mojo. + * + * @author Lauri Heino + * @since 1.0.0 + */ +@Mojo(name = "test-compile", + defaultPhase = LifecyclePhase.TEST_COMPILE, + requiresDependencyResolution = ResolutionScope.TEST, + threadSafe = true) +public class ElideKotlinJVMTestCompileMojo extends ElideKotlinJVMTestCompileMojoImpl { +} diff --git a/kotlin-plugin/src/main/java/dev/elide/maven/plugin/kotlin/ElideKotlinKaptJVMCompileMojo.java b/kotlin-plugin/src/main/java/dev/elide/maven/plugin/kotlin/ElideKotlinKaptJVMCompileMojo.java new file mode 100644 index 0000000..0b618e1 --- /dev/null +++ b/kotlin-plugin/src/main/java/dev/elide/maven/plugin/kotlin/ElideKotlinKaptJVMCompileMojo.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024-2025 Elide Technologies, Inc. + * + * Licensed under the MIT license (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * https://opensource.org/license/mit/ + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under the License. + */ +package dev.elide.maven.plugin.kotlin; + +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.ResolutionScope; + +/** + * Elide Kotlin Kapt JVM compiler Mojo. + * + * @author Lauri Heino + * @since 1.0.0 + */ +@Mojo(name = "kapt", + defaultPhase = LifecyclePhase.PROCESS_SOURCES, + requiresDependencyResolution = ResolutionScope.COMPILE) +public class ElideKotlinKaptJVMCompileMojo extends ElideKotlinKaptJVMCompileMojoImpl { +} diff --git a/kotlin-plugin/src/main/java/dev/elide/maven/plugin/kotlin/ElideKotlinKaptJVMTestCompileMojo.java b/kotlin-plugin/src/main/java/dev/elide/maven/plugin/kotlin/ElideKotlinKaptJVMTestCompileMojo.java new file mode 100644 index 0000000..046d513 --- /dev/null +++ b/kotlin-plugin/src/main/java/dev/elide/maven/plugin/kotlin/ElideKotlinKaptJVMTestCompileMojo.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024-2025 Elide Technologies, Inc. + * + * Licensed under the MIT license (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * https://opensource.org/license/mit/ + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under the License. + */ +package dev.elide.maven.plugin.kotlin; + +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.ResolutionScope; + +/** + * Elide Kotlin Kapt JVM test compiler Mojo. + * + * @author Lauri Heino + * @since 1.0.0 + */ +@Mojo(name = "test-kapt", + defaultPhase = LifecyclePhase.PROCESS_TEST_SOURCES, + requiresDependencyResolution = ResolutionScope.TEST) +public class ElideKotlinKaptJVMTestCompileMojo extends ElideKotlinKaptJVMTestCompileMojoImpl { +} diff --git a/kotlin-plugin/src/main/kotlin/dev/elide/maven/plugin/kotlin/ArgumentParser.kt b/kotlin-plugin/src/main/kotlin/dev/elide/maven/plugin/kotlin/ArgumentParser.kt new file mode 100644 index 0000000..78ddd9e --- /dev/null +++ b/kotlin-plugin/src/main/kotlin/dev/elide/maven/plugin/kotlin/ArgumentParser.kt @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2024-2025 Elide Technologies, Inc. + * + * Licensed under the MIT license (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * https://opensource.org/license/mit/ + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under the License. + */ +package dev.elide.maven.plugin.kotlin + +import org.apache.maven.project.MavenProject +import org.jetbrains.kotlin.cli.common.arguments.Argument +import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments +import java.lang.reflect.Field +import java.util.* + +/** + * Parser for Kotlin compiler arguments. + * + * @author Lauri Heino + * @since 1.0.0 + */ +object ArgumentParser { + /** + * Parses [A] into a list of Elide Kotlin compiler command line arguments. + */ + fun parseArguments( + compiler: String, + arguments: A, + project: MavenProject, + java: Boolean, + ): Array { + val list: MutableList = LinkedList() + list.add(compiler) + list.add("--") + getAllFields(arguments::class.java).forEach { list.parseArgument(arguments, it) } + if (java && "-d" !in list) { + list.add("-d") + list.add(project.build.outputDirectory) + } + list.add("--") + list.addAll(arguments.freeArgs) + return list.toTypedArray() + } + + private fun getAllFields(type: Class): List { + var type: Class = type + val fields: MutableList = LinkedList() + fields.addAll(type.declaredFields.filter { it.trySetAccessible() && it.isAnnotationPresent(Argument::class.java) }) + while(type != CommonCompilerArguments::class.java) { + type = type.superclass as Class + fields.addAll(type.declaredFields.filter { it.trySetAccessible() && it.isAnnotationPresent(Argument::class.java) }) + } + return fields + } + + private fun MutableList.parseArgument( + arguments: A, + field: Field, + ) { + val argument = field.getAnnotation(Argument::class.java) ?: return + val element: Any = field.get(arguments) ?: return + when (element) { + is Boolean -> if (element) add(argument.value) + is String -> { + add(argument.value + "=" + element) + } + is Array<*> -> { + element.forEach { + if (it !is String) throw IllegalArgumentException() + add(argument.value + "=" + it) + } + } + else -> throw IllegalArgumentException() + } + } +} diff --git a/kotlin-plugin/src/main/kotlin/dev/elide/maven/plugin/kotlin/ElideKotlinJSCompileMojoImpl.kt b/kotlin-plugin/src/main/kotlin/dev/elide/maven/plugin/kotlin/ElideKotlinJSCompileMojoImpl.kt new file mode 100644 index 0000000..20b1c78 --- /dev/null +++ b/kotlin-plugin/src/main/kotlin/dev/elide/maven/plugin/kotlin/ElideKotlinJSCompileMojoImpl.kt @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024-2025 Elide Technologies, Inc. + * + * Licensed under the MIT license (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * https://opensource.org/license/mit/ + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under the License. + */ +package dev.elide.maven.plugin.kotlin + +import org.apache.maven.plugins.annotations.Parameter +import org.jetbrains.kotlin.cli.common.CLICompiler +import org.jetbrains.kotlin.cli.common.ExitCode +import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments +import org.jetbrains.kotlin.cli.common.messages.MessageCollector +import org.jetbrains.kotlin.maven.K2JSCompilerMojo +import java.io.File + +/** + * Elide Kotlin to Javascript compiler. + * + * @author Lauri Heino + * @since 1.0.0 + */ +internal open class ElideKotlinJSCompileMojoImpl : K2JSCompilerMojo() { + /** + * Elide executable location. + */ + @Parameter(name = "executable") var executable: String? = null + + override fun execCompiler( + compiler: CLICompiler?, + messageCollector: MessageCollector, + arguments: K2JSCompilerArguments, + sourceRoots: List, + ): ExitCode = + ElideRunner.runCompiler( + messageCollector, + arguments, + sourceRoots, + project, + executable, + "kotlinc-js", + false, + ) +} diff --git a/kotlin-plugin/src/main/kotlin/dev/elide/maven/plugin/kotlin/ElideKotlinJSTestCompileMojoImpl.kt b/kotlin-plugin/src/main/kotlin/dev/elide/maven/plugin/kotlin/ElideKotlinJSTestCompileMojoImpl.kt new file mode 100644 index 0000000..59dd66c --- /dev/null +++ b/kotlin-plugin/src/main/kotlin/dev/elide/maven/plugin/kotlin/ElideKotlinJSTestCompileMojoImpl.kt @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024-2025 Elide Technologies, Inc. + * + * Licensed under the MIT license (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * https://opensource.org/license/mit/ + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under the License. + */ +package dev.elide.maven.plugin.kotlin + +import org.apache.maven.plugins.annotations.Parameter +import org.jetbrains.kotlin.cli.common.CLICompiler +import org.jetbrains.kotlin.cli.common.ExitCode +import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments +import org.jetbrains.kotlin.cli.common.messages.MessageCollector +import org.jetbrains.kotlin.maven.KotlinTestJSCompilerMojo +import java.io.File + +/** + * Elide Kotlin to Javascript test compiler. + * + * @author Lauri Heino + * @since 1.0.0 + */ +internal open class ElideKotlinJSTestCompileMojoImpl : KotlinTestJSCompilerMojo() { + /** + * Elide executable location. + */ + @Parameter(name = "executable") var executable: String? = null + + override fun execCompiler( + compiler: CLICompiler?, + messageCollector: MessageCollector, + arguments: K2JSCompilerArguments, + sourceRoots: List, + ): ExitCode = + ElideRunner.runCompiler( + messageCollector, + arguments, + sourceRoots, + project, + executable, + "kotlinc-js", + false, + ) +} diff --git a/kotlin-plugin/src/main/kotlin/dev/elide/maven/plugin/kotlin/ElideKotlinJVMCompileMojoImpl.kt b/kotlin-plugin/src/main/kotlin/dev/elide/maven/plugin/kotlin/ElideKotlinJVMCompileMojoImpl.kt new file mode 100644 index 0000000..ad5444c --- /dev/null +++ b/kotlin-plugin/src/main/kotlin/dev/elide/maven/plugin/kotlin/ElideKotlinJVMCompileMojoImpl.kt @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024-2025 Elide Technologies, Inc. + * + * Licensed under the MIT license (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * https://opensource.org/license/mit/ + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under the License. + */ +package dev.elide.maven.plugin.kotlin + +import org.apache.maven.plugins.annotations.Parameter +import org.jetbrains.kotlin.cli.common.CLICompiler +import org.jetbrains.kotlin.cli.common.ExitCode +import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments +import org.jetbrains.kotlin.cli.common.messages.MessageCollector +import org.jetbrains.kotlin.maven.K2JVMCompileMojo +import java.io.File + +/** + * Elide Kotlin to JVM compiler. + * + * @author Lauri Heino + * @since 1.0.0 + */ +internal open class ElideKotlinJVMCompileMojoImpl : K2JVMCompileMojo() { + /** + * Elide executable location. + */ + @Parameter(name = "executable") var executable: String? = null + + override fun execCompiler( + compiler: CLICompiler?, + messageCollector: MessageCollector, + arguments: K2JVMCompilerArguments, + sourceRoots: List, + ): ExitCode = + ElideRunner.runCompiler( + messageCollector, + arguments, + sourceRoots, + project, + executable, + "kotlinc", + true, + ) +} diff --git a/kotlin-plugin/src/main/kotlin/dev/elide/maven/plugin/kotlin/ElideKotlinJVMTestCompileMojoImpl.kt b/kotlin-plugin/src/main/kotlin/dev/elide/maven/plugin/kotlin/ElideKotlinJVMTestCompileMojoImpl.kt new file mode 100644 index 0000000..b1cc550 --- /dev/null +++ b/kotlin-plugin/src/main/kotlin/dev/elide/maven/plugin/kotlin/ElideKotlinJVMTestCompileMojoImpl.kt @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024-2025 Elide Technologies, Inc. + * + * Licensed under the MIT license (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * https://opensource.org/license/mit/ + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under the License. + */ +package dev.elide.maven.plugin.kotlin + +import org.apache.maven.plugins.annotations.Parameter +import org.jetbrains.kotlin.cli.common.CLICompiler +import org.jetbrains.kotlin.cli.common.ExitCode +import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments +import org.jetbrains.kotlin.cli.common.messages.MessageCollector +import org.jetbrains.kotlin.maven.KotlinTestCompileMojo +import java.io.File + +/** + * Elide Kotlin to JVM test compiler. + * + * @author Lauri Heino + * @since 1.0.0 + */ +internal open class ElideKotlinJVMTestCompileMojoImpl : KotlinTestCompileMojo() { + /** + * Elide executable location. + */ + @Parameter(name = "executable") var executable: String? = null + + override fun execCompiler( + compiler: CLICompiler?, + messageCollector: MessageCollector, + arguments: K2JVMCompilerArguments, + sourceRoots: List, + ): ExitCode = + ElideRunner.runCompiler( + messageCollector, + arguments, + sourceRoots, + project, + executable, + "kotlinc", + true, + ) +} diff --git a/kotlin-plugin/src/main/kotlin/dev/elide/maven/plugin/kotlin/ElideKotlinKaptJVMCompileMojoImpl.kt b/kotlin-plugin/src/main/kotlin/dev/elide/maven/plugin/kotlin/ElideKotlinKaptJVMCompileMojoImpl.kt new file mode 100644 index 0000000..90a2c1c --- /dev/null +++ b/kotlin-plugin/src/main/kotlin/dev/elide/maven/plugin/kotlin/ElideKotlinKaptJVMCompileMojoImpl.kt @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024-2025 Elide Technologies, Inc. + * + * Licensed under the MIT license (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * https://opensource.org/license/mit/ + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under the License. + */ +package dev.elide.maven.plugin.kotlin + +import org.apache.maven.plugins.annotations.Parameter +import org.jetbrains.kotlin.cli.common.CLICompiler +import org.jetbrains.kotlin.cli.common.ExitCode +import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments +import org.jetbrains.kotlin.cli.common.messages.MessageCollector +import org.jetbrains.kotlin.maven.kapt.KaptJVMCompilerMojo +import java.io.File + +/** + * Elide Kotlin Kapt JVM compiler. + * + * @author Lauri Heino + * @since 1.0.0 + */ +internal open class ElideKotlinKaptJVMCompileMojoImpl : KaptJVMCompilerMojo() { + /** + * Elide executable location. + */ + @Parameter(name = "executable") var executable: String? = null + + override fun execCompiler( + compiler: CLICompiler?, + messageCollector: MessageCollector, + arguments: K2JVMCompilerArguments, + sourceRoots: List, + ): ExitCode = + ElideRunner.runCompiler( + messageCollector, + arguments, + sourceRoots, + project, + executable, + "kotlinc", + true, + ) +} diff --git a/kotlin-plugin/src/main/kotlin/dev/elide/maven/plugin/kotlin/ElideKotlinKaptJVMTestCompileMojoImpl.kt b/kotlin-plugin/src/main/kotlin/dev/elide/maven/plugin/kotlin/ElideKotlinKaptJVMTestCompileMojoImpl.kt new file mode 100644 index 0000000..eea0176 --- /dev/null +++ b/kotlin-plugin/src/main/kotlin/dev/elide/maven/plugin/kotlin/ElideKotlinKaptJVMTestCompileMojoImpl.kt @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024-2025 Elide Technologies, Inc. + * + * Licensed under the MIT license (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * https://opensource.org/license/mit/ + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under the License. + */ +package dev.elide.maven.plugin.kotlin + +import org.apache.maven.plugins.annotations.Parameter +import org.jetbrains.kotlin.cli.common.CLICompiler +import org.jetbrains.kotlin.cli.common.ExitCode +import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments +import org.jetbrains.kotlin.cli.common.messages.MessageCollector +import org.jetbrains.kotlin.maven.kapt.KaptTestJvmCompilerMojo +import java.io.File + +/** + * Elide Kotlin Kapt JVM test compiler. + * + * @author Lauri Heino + * @since 1.0.0 + */ +internal open class ElideKotlinKaptJVMTestCompileMojoImpl : KaptTestJvmCompilerMojo() { + /** + * Elide executable location. + */ + @Parameter(name = "executable") var executable: String? = null + + override fun execCompiler( + compiler: CLICompiler?, + messageCollector: MessageCollector, + arguments: K2JVMCompilerArguments, + sourceRoots: List, + ): ExitCode = + ElideRunner.runCompiler( + messageCollector, + arguments, + sourceRoots, + project, + executable, + "kotlinc", + true, + ) +} diff --git a/kotlin-plugin/src/main/kotlin/dev/elide/maven/plugin/kotlin/ElideRunner.kt b/kotlin-plugin/src/main/kotlin/dev/elide/maven/plugin/kotlin/ElideRunner.kt new file mode 100644 index 0000000..364a00d --- /dev/null +++ b/kotlin-plugin/src/main/kotlin/dev/elide/maven/plugin/kotlin/ElideRunner.kt @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2024-2025 Elide Technologies, Inc. + * + * Licensed under the MIT license (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * https://opensource.org/license/mit/ + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under the License. + */ +package dev.elide.maven.plugin.kotlin + +import dev.elide.maven.compiler.ElideLocator +import org.apache.maven.project.MavenProject +import org.codehaus.plexus.compiler.CompilerException +import org.codehaus.plexus.util.cli.CommandLineException +import org.codehaus.plexus.util.cli.CommandLineUtils +import org.codehaus.plexus.util.cli.Commandline +import org.jetbrains.kotlin.cli.common.ExitCode +import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments +import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity +import org.jetbrains.kotlin.cli.common.messages.MessageCollector +import java.io.File +import java.io.IOException +import kotlin.io.path.absolutePathString + +/** + * Tools for running Elide's Kotlin compiler. + * + * @author Lauri Heino + * @since 1.0.0 + */ +object ElideRunner { + /** + * Executes the Elide Kotlin compiler according to [arguments]. + */ + fun runCompiler( + messageCollector: MessageCollector, + arguments: A, + sourceRoots: List, + project: MavenProject, + executable: String?, + compiler: String, + java: Boolean, + ): ExitCode { + val freeArgs = arguments.freeArgs.toMutableList() + for (sourceRoot in sourceRoots) { + freeArgs.add(sourceRoot.path) + } + arguments.freeArgs = freeArgs + val cli = Commandline() + cli.workingDirectory = project.basedir + cli.executable = executable ?: ElideLocator.locate()?.absolutePathString() ?: "elide" + cli.addArguments(ArgumentParser.parseArguments(compiler, arguments, project, java)) + val out = CommandLineUtils.StringStreamConsumer() + var returnCode: Int + try { + returnCode = CommandLineUtils.executeCommandLine(cli, out, out) + out.output.lines().forEach { + messageCollector.report( + if (returnCode == 0) CompilerMessageSeverity.INFO + else CompilerMessageSeverity.ERROR, + it, + ) + } + } catch (e: CommandLineException) { + throw CompilerException("Error while executing Elide $compiler compiler.", e) + } catch (e: IOException) { + throw CompilerException("Error while executing Elide $compiler compiler.", e) + } + return if (returnCode == 0) ExitCode.OK else ExitCode.COMPILATION_ERROR + } +} diff --git a/kotlin-plugin/src/test/kotlin/.gitkeep b/kotlin-plugin/src/test/kotlin/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/sample/mvnw b/mvnw similarity index 100% rename from sample/mvnw rename to mvnw diff --git a/sample/mvnw.cmd b/mvnw.cmd similarity index 97% rename from sample/mvnw.cmd rename to mvnw.cmd index b150b91..249bdf3 100644 --- a/sample/mvnw.cmd +++ b/mvnw.cmd @@ -1,149 +1,149 @@ -<# : batch portion -@REM ---------------------------------------------------------------------------- -@REM Licensed to the Apache Software Foundation (ASF) under one -@REM or more contributor license agreements. See the NOTICE file -@REM distributed with this work for additional information -@REM regarding copyright ownership. The ASF licenses this file -@REM to you under the Apache License, Version 2.0 (the -@REM "License"); you may not use this file except in compliance -@REM with the License. You may obtain a copy of the License at -@REM -@REM http://www.apache.org/licenses/LICENSE-2.0 -@REM -@REM Unless required by applicable law or agreed to in writing, -@REM software distributed under the License is distributed on an -@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -@REM KIND, either express or implied. See the License for the -@REM specific language governing permissions and limitations -@REM under the License. -@REM ---------------------------------------------------------------------------- - -@REM ---------------------------------------------------------------------------- -@REM Apache Maven Wrapper startup batch script, version 3.3.2 -@REM -@REM Optional ENV vars -@REM MVNW_REPOURL - repo url base for downloading maven distribution -@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven -@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output -@REM ---------------------------------------------------------------------------- - -@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0) -@SET __MVNW_CMD__= -@SET __MVNW_ERROR__= -@SET __MVNW_PSMODULEP_SAVE=%PSModulePath% -@SET PSModulePath= -@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @( - IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B) -) -@SET PSModulePath=%__MVNW_PSMODULEP_SAVE% -@SET __MVNW_PSMODULEP_SAVE= -@SET __MVNW_ARG0_NAME__= -@SET MVNW_USERNAME= -@SET MVNW_PASSWORD= -@IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*) -@echo Cannot start maven from wrapper >&2 && exit /b 1 -@GOTO :EOF -: end batch / begin powershell #> - -$ErrorActionPreference = "Stop" -if ($env:MVNW_VERBOSE -eq "true") { - $VerbosePreference = "Continue" -} - -# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties -$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl -if (!$distributionUrl) { - Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" -} - -switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) { - "maven-mvnd-*" { - $USE_MVND = $true - $distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip" - $MVN_CMD = "mvnd.cmd" - break - } - default { - $USE_MVND = $false - $MVN_CMD = $script -replace '^mvnw','mvn' - break - } -} - -# apply MVNW_REPOURL and calculate MAVEN_HOME -# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ -if ($env:MVNW_REPOURL) { - $MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" } - $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')" -} -$distributionUrlName = $distributionUrl -replace '^.*/','' -$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$','' -$MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain" -if ($env:MAVEN_USER_HOME) { - $MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain" -} -$MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' -$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME" - -if (Test-Path -Path "$MAVEN_HOME" -PathType Container) { - Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME" - Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" - exit $? -} - -if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) { - Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl" -} - -# prepare tmp dir -$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile -$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir" -$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null -trap { - if ($TMP_DOWNLOAD_DIR.Exists) { - try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } - catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } - } -} - -New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null - -# Download and Install Apache Maven -Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." -Write-Verbose "Downloading from: $distributionUrl" -Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" - -$webclient = New-Object System.Net.WebClient -if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) { - $webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD) -} -[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 -$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null - -# If specified, validate the SHA-256 sum of the Maven distribution zip file -$distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum -if ($distributionSha256Sum) { - if ($USE_MVND) { - Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." - } - Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash - if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) { - Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property." - } -} - -# unzip and move -Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null -Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null -try { - Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null -} catch { - if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) { - Write-Error "fail to move MAVEN_HOME" - } -} finally { - try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } - catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } -} - -Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" +<# : batch portion +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Apache Maven Wrapper startup batch script, version 3.3.2 +@REM +@REM Optional ENV vars +@REM MVNW_REPOURL - repo url base for downloading maven distribution +@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output +@REM ---------------------------------------------------------------------------- + +@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0) +@SET __MVNW_CMD__= +@SET __MVNW_ERROR__= +@SET __MVNW_PSMODULEP_SAVE=%PSModulePath% +@SET PSModulePath= +@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @( + IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B) +) +@SET PSModulePath=%__MVNW_PSMODULEP_SAVE% +@SET __MVNW_PSMODULEP_SAVE= +@SET __MVNW_ARG0_NAME__= +@SET MVNW_USERNAME= +@SET MVNW_PASSWORD= +@IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*) +@echo Cannot start maven from wrapper >&2 && exit /b 1 +@GOTO :EOF +: end batch / begin powershell #> + +$ErrorActionPreference = "Stop" +if ($env:MVNW_VERBOSE -eq "true") { + $VerbosePreference = "Continue" +} + +# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties +$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl +if (!$distributionUrl) { + Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" +} + +switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) { + "maven-mvnd-*" { + $USE_MVND = $true + $distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip" + $MVN_CMD = "mvnd.cmd" + break + } + default { + $USE_MVND = $false + $MVN_CMD = $script -replace '^mvnw','mvn' + break + } +} + +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +if ($env:MVNW_REPOURL) { + $MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" } + $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')" +} +$distributionUrlName = $distributionUrl -replace '^.*/','' +$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$','' +$MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain" +if ($env:MAVEN_USER_HOME) { + $MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain" +} +$MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' +$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME" + +if (Test-Path -Path "$MAVEN_HOME" -PathType Container) { + Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME" + Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" + exit $? +} + +if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) { + Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl" +} + +# prepare tmp dir +$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile +$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir" +$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null +trap { + if ($TMP_DOWNLOAD_DIR.Exists) { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } + } +} + +New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null + +# Download and Install Apache Maven +Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +Write-Verbose "Downloading from: $distributionUrl" +Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" + +$webclient = New-Object System.Net.WebClient +if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) { + $webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD) +} +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 +$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null + +# If specified, validate the SHA-256 sum of the Maven distribution zip file +$distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum +if ($distributionSha256Sum) { + if ($USE_MVND) { + Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." + } + Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash + if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) { + Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property." + } +} + +# unzip and move +Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null +Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null +try { + Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null +} catch { + if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) { + Write-Error "fail to move MAVEN_HOME" + } +} finally { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } +} + +Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" diff --git a/plexus-compilers/pom.xml b/plexus-compilers/pom.xml new file mode 100644 index 0000000..dfbfff9 --- /dev/null +++ b/plexus-compilers/pom.xml @@ -0,0 +1,113 @@ + + + 4.0.0 + + dev.elide + elide-plexus-compilers + 1.0.0 + jar + + Elide Java Plexus Compiler + A Maven-compatible Plexus compiler that uses Elide to compile Java sources. + https://elide.dev + + + + MIT License + https://www.opensource.org/licenses/mit-license.php + + + + + + Lauri Heino + datafox@datafox.me + Elide + https://elide.dev + + + Sam Gammon + sam@elide.dev + Elide + https://elide.dev + + + + + scm:git:git://github.com/elide-dev/maven.git + scm:git:ssh://github.com:elide-dev/maven.git + https://github.com/elide-dev/maven/tree/main + + + + UTF-8 + official + 1.8 + + 2.2.0 + 1 + 2.15.0 + 5.11.1 + 2.22.2 + + + + + mavenCentral + https://repo1.maven.org/maven2/ + + + + + src/main/kotlin + src/test/kotlin + + + org.jetbrains.kotlin + kotlin-maven-plugin + ${kotlinVersion} + true + + + maven-surefire-plugin + ${mavenTestPluginVersion} + + + maven-failsafe-plugin + ${mavenTestPluginVersion} + + + + + + + org.jetbrains.kotlin + kotlin-test-junit5 + ${kotlinVersion} + test + + + org.junit.jupiter + junit-jupiter + ${junitVersion} + test + + + org.jetbrains.kotlin + kotlin-stdlib + ${kotlinVersion} + + + javax.inject + javax.inject + ${injectVersion} + + + org.codehaus.plexus + plexus-compiler-api + ${plexusVersion} + + + \ No newline at end of file diff --git a/src/main/kotlin/dev/elide/maven/compiler/Constants.kt b/plexus-compilers/src/main/kotlin/dev/elide/maven/compiler/Constants.kt similarity index 100% rename from src/main/kotlin/dev/elide/maven/compiler/Constants.kt rename to plexus-compilers/src/main/kotlin/dev/elide/maven/compiler/Constants.kt diff --git a/src/main/kotlin/dev/elide/maven/compiler/ElideJavacCompiler.kt b/plexus-compilers/src/main/kotlin/dev/elide/maven/compiler/ElideJavacCompiler.kt similarity index 100% rename from src/main/kotlin/dev/elide/maven/compiler/ElideJavacCompiler.kt rename to plexus-compilers/src/main/kotlin/dev/elide/maven/compiler/ElideJavacCompiler.kt diff --git a/src/main/kotlin/dev/elide/maven/compiler/ElideLocator.kt b/plexus-compilers/src/main/kotlin/dev/elide/maven/compiler/ElideLocator.kt similarity index 100% rename from src/main/kotlin/dev/elide/maven/compiler/ElideLocator.kt rename to plexus-compilers/src/main/kotlin/dev/elide/maven/compiler/ElideLocator.kt diff --git a/src/main/resources/META-INF/sisu/javax.inject.Named b/plexus-compilers/src/main/resources/META-INF/sisu/javax.inject.Named similarity index 100% rename from src/main/resources/META-INF/sisu/javax.inject.Named rename to plexus-compilers/src/main/resources/META-INF/sisu/javax.inject.Named diff --git a/plexus-compilers/src/test/kotlin/.gitkeep b/plexus-compilers/src/test/kotlin/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..9d3629a --- /dev/null +++ b/pom.xml @@ -0,0 +1,19 @@ + + + 4.0.0 + + dev.elide + elide-maven + 1.0.0 + pom + + + plexus-compilers + kotlin-plugin + sample-java + sample-kotlin + sample-mixed + + \ No newline at end of file diff --git a/sample-java/README.md b/sample-java/README.md new file mode 100644 index 0000000..a82649e --- /dev/null +++ b/sample-java/README.md @@ -0,0 +1,26 @@ +## Elide Maven Java Compiler: Sample project + +This project demonstrates use of Elide as a replacement for `javac` within a Maven project. Explicitly add the +`maven-compiler-plugin`, add `elide-plexus-compilers` as a dependency, and configure `compilerId` to `elide`. + +**`pom.xml`** +```xml + + + + maven-compiler-plugin + 3.14.0 + + + dev.elide + elide-plexus-compilers + 1.0.0 + + + + elide + + + + +``` diff --git a/sample/pom.xml b/sample-java/pom.xml similarity index 62% rename from sample/pom.xml rename to sample-java/pom.xml index 47b660c..7e60f6d 100644 --- a/sample/pom.xml +++ b/sample-java/pom.xml @@ -1,24 +1,21 @@ - + + 4.0.0 com.sample - my-app + my-java-app 1 - - - 24 - 24 - UTF-8 - maven-compiler-plugin - 3.13.0 + 3.14.0 dev.elide elide-plexus-compilers - 1.0.0-SNAPSHOT + 1.0.0 diff --git a/sample/src/main/java/com/sample/Hello.java b/sample-java/src/main/java/com/sample/Hello.java similarity index 100% rename from sample/src/main/java/com/sample/Hello.java rename to sample-java/src/main/java/com/sample/Hello.java diff --git a/sample-kotlin/README.md b/sample-kotlin/README.md new file mode 100644 index 0000000..830df93 --- /dev/null +++ b/sample-kotlin/README.md @@ -0,0 +1,42 @@ +## Elide Maven Kotlin Plugin: Sample project + +This project demonstrates use of Elide as a Kotlin compiler within a Maven project. This is a drop-in replacement for +the Kotlin plugin, so configure your Kotlin project like normal, but use `dev.elide:elide-kotlin-maven-plugin` instead +of `org.jetbrains.kotlin:kotlin-maven-plugin`. Use of `` is not supported yet. + +**`pom.xml`** +```xml + + src/main/kotlin + src/test/kotlin + + + dev.elide + elide-kotlin-maven-plugin + 1.0.0 + + + compile + + compile + + + + test-compile + + test-compile + + + + + + + + + + org.jetbrains.kotlin + kotlin-stdlib + 2.2.0 + + +``` diff --git a/sample-kotlin/pom.xml b/sample-kotlin/pom.xml new file mode 100644 index 0000000..a2278ae --- /dev/null +++ b/sample-kotlin/pom.xml @@ -0,0 +1,52 @@ + + + 4.0.0 + com.sample + my-kotlin-app + 1 + + + + mavenCentral + https://repo1.maven.org/maven2/ + + + + + src/main/kotlin + src/test/kotlin + + + dev.elide + elide-kotlin-maven-plugin + 1.0.0 + + + compile + + compile + + + + + test-compile + + test-compile + + + + + + + + + + org.jetbrains.kotlin + kotlin-stdlib + 2.2.0 + + + + \ No newline at end of file diff --git a/sample-kotlin/src/main/kotlin/com.sample/Hello.kt b/sample-kotlin/src/main/kotlin/com.sample/Hello.kt new file mode 100644 index 0000000..639d6e7 --- /dev/null +++ b/sample-kotlin/src/main/kotlin/com.sample/Hello.kt @@ -0,0 +1,5 @@ +package com.sample + +fun main() { + println("Hello, World!") +} diff --git a/sample-kotlin/src/test/kotlin/.gitkeep b/sample-kotlin/src/test/kotlin/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/sample-mixed/README.md b/sample-mixed/README.md new file mode 100644 index 0000000..7f877b3 --- /dev/null +++ b/sample-mixed/README.md @@ -0,0 +1,85 @@ +## Elide Maven Kotlin Plugin: Mixed sources sample project + +This project demonstrates use of Elide as a Java and Kotlin compiler within a Maven project. This is a drop-in +replacement for the Kotlin plugin, so configure your Kotlin project like normal, but use +`dev.elide:elide-kotlin-maven-plugin` instead of `org.jetbrains.kotlin:kotlin-maven-plugin`, add +`elide-plexus-compilers` as a dependency to the `maven-compiler-plugin` and configure `compilerId` to `elide`. Use of +Kotlin plugin `` is not supported yet. + +**`pom.xml`** +```xml + + + + dev.elide + elide-kotlin-maven-plugin + 1.0.0 + + + compile + + compile + + + + ${project.basedir}/src/main/kotlin + ${project.basedir}/src/main/java + + + + + test-compile + + test-compile + + + + ${project.basedir}/src/test/kotlin + ${project.basedir}/src/test/java + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.14.0 + + + dev.elide + elide-plexus-compilers + 1.0.0 + + + + elide + + + + default-compile + none + + + default-testCompile + none + + + java-compile + compile + + compile + + + + java-test-compile + test-compile + + testCompile + + + + + + +``` diff --git a/sample-mixed/pom.xml b/sample-mixed/pom.xml new file mode 100644 index 0000000..4d45712 --- /dev/null +++ b/sample-mixed/pom.xml @@ -0,0 +1,107 @@ + + + 4.0.0 + com.sample + my-mixed-app + 1 + + + + UTF-8 + official + 11 + + + + + mavenCentral + https://repo1.maven.org/maven2/ + + + + + + + dev.elide + elide-kotlin-maven-plugin + 1.0.0 + + + compile + + compile + + + + ${project.basedir}/src/main/kotlin + ${project.basedir}/src/main/java + + + + + test-compile + + test-compile + + + + ${project.basedir}/src/test/kotlin + ${project.basedir}/src/test/java + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.14.0 + + + dev.elide + elide-plexus-compilers + 1.0.0 + + + + elide + + + + default-compile + none + + + default-testCompile + none + + + java-compile + compile + + compile + + + + java-test-compile + test-compile + + testCompile + + + + + + + + + + org.jetbrains.kotlin + kotlin-stdlib + 2.2.0 + + + + \ No newline at end of file diff --git a/sample-mixed/src/main/java/com/sample/Hello.java b/sample-mixed/src/main/java/com/sample/Hello.java new file mode 100644 index 0000000..6de6ad6 --- /dev/null +++ b/sample-mixed/src/main/java/com/sample/Hello.java @@ -0,0 +1,8 @@ +package com.sample; + +class Hello { + public static void main(String[] args) { + String hello = Library.INSTANCE.getHello(); + System.out.println(hello); + } +} diff --git a/sample-mixed/src/main/kotlin/com/sample/Library.kt b/sample-mixed/src/main/kotlin/com/sample/Library.kt new file mode 100644 index 0000000..bb18a3f --- /dev/null +++ b/sample-mixed/src/main/kotlin/com/sample/Library.kt @@ -0,0 +1,5 @@ +package com.sample + +object Library { + fun getHello(): String = "Hello, World!" +} \ No newline at end of file diff --git a/sample-mixed/src/test/java/.gitkeep b/sample-mixed/src/test/java/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/sample-mixed/src/test/kotlin/.gitkeep b/sample-mixed/src/test/kotlin/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/sample/.gitignore b/sample/.gitignore deleted file mode 100644 index 2f7896d..0000000 --- a/sample/.gitignore +++ /dev/null @@ -1 +0,0 @@ -target/ diff --git a/sample/README.md b/sample/README.md deleted file mode 100644 index 1225cfc..0000000 --- a/sample/README.md +++ /dev/null @@ -1,26 +0,0 @@ -## Elide Maven Plugin: Sample Project - -This project demonstrates use of Elide as a replacement for `javac` within a Maven project. There is some Java source -code to build, and the `pom.xml` is configured to use Elide. - -**`pom.xml`** -```xml - - - - maven-compiler-plugin - 3.13.0 - - - dev.elide - elide-plexus-compilers - 1.0.0-SNAPSHOT - - - - elide - - - - -``` diff --git a/settings.gradle.kts b/settings.gradle.kts deleted file mode 100644 index 728fac2..0000000 --- a/settings.gradle.kts +++ /dev/null @@ -1 +0,0 @@ -rootProject.name = "elide-plexus-compilers" \ No newline at end of file