Add support for custom script compilation and execution to maven plugin, add simple test, relevant refactorings on the compiler side
This commit is contained in:
@@ -23,6 +23,16 @@
|
||||
<artifactId>kotlin-reflect</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-script-util</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-js-library</artifactId>
|
||||
@@ -75,6 +85,7 @@
|
||||
<!--This could speed up test by providing local repo as remote repo for test but might be tricky on different OS-->
|
||||
<!--<settingsFile>src/it/settings.xml</settingsFile>-->
|
||||
<localRepositoryPath>local-repo</localRepositoryPath>
|
||||
<showErrors>true</showErrors>
|
||||
<postBuildHookScript>verify</postBuildHookScript>
|
||||
<streamLogs>false</streamLogs>
|
||||
<invokerPropertiesFile>invoker.properties</invokerPropertiesFile>
|
||||
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
<?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/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>test-executeKotlinScriptFile</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib</artifactId>
|
||||
<version>${kotlin.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-script-util</artifactId>
|
||||
<version>${kotlin.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<kotlin.compiler.scriptTemplates>org.jetbrains.kotlin.script.util.StandardScript</kotlin.compiler.scriptTemplates>
|
||||
<kotlin.compiler.scriptClasspath>${org.jetbrains.kotlin:kotlin-script-util:jar}</kotlin.compiler.scriptClasspath>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<version>2.3</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>properties</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<version>${kotlin.version}</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib</artifactId>
|
||||
<version>${kotlin.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-script-util</artifactId>
|
||||
<version>${kotlin.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>execute-kotlin-script</id>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>script</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<scriptFile>script.kts</scriptFile>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
|
||||
if (!args.isEmpty())
|
||||
println("some args passed")
|
||||
|
||||
println("Hello from Kotlin script file!")
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
source(new File(basedir, "../../../verify-common.bsh").getAbsolutePath());
|
||||
|
||||
assertBuildLogHasLine("Hello from Kotlin script file!")
|
||||
Reference in New Issue
Block a user