Я пытаюсь преобразовать мой kotlin проект из pom. xml в build.gradle, но безуспешно. У меня есть рабочий pom. xml, и когда я компилирую с помощью "mvn compile", он отлично работает и запускает тесты. Попытка построить новый build.gradle для работы с gradle безуспешно. pom. xml:
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
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.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.release>11</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<avro.version>1.9.1</avro.version>
<kotlin.version>1.3.61</kotlin.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M3</version>
</plugin>
<plugin>
<groupId>org.apache.avro</groupId>
<artifactId>avro-maven-plugin</artifactId>
<version>${avro.version}</version>
<executions>
<execution>
<id>schemas</id>
<phase>generate-sources</phase>
<goals>
<goal>schema</goal>
<goal>protocol</goal>
<goal>idl-protocol</goal>
</goals>
<configuration>
<sourceDirectory>${project.basedir}/src/test/java/avro/</sourceDirectory>
<outputDirectory>${project.basedir}/src/test/java/</outputDirectory>
<stringType>String</stringType>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<configuration>
<jvmTarget>1.8</jvmTarget>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>testCompile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<filesets>
<fileset>
<directory>${basedir}/src/test/java/org/mashov/generated/</directory>
</fileset>
</filesets>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.0.0-M5</version>
</dependency>
<dependency>
<groupId>com.github.dozermapper</groupId>
<artifactId>dozer-core</artifactId>
<version>6.5.0</version>
</dependency>
<dependency>
<groupId>org.apache.avro</groupId>
<artifactId>avro</artifactId>
<version>${avro.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>
<version>1.3.61</version>
</dependency>
<dependency>
<groupId>io.github.microutils</groupId>
<artifactId>kotlin-logging</artifactId>
<version>1.7.7</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>1.7.25</version>
</dependency>
</dependencies>
</project>
new build.gradle:
import com.commercehub.gradle.plugin.avro.GenerateAvroJavaTask
group = 'com.mycompany.app'
version = '1.0-SNAPSHOT'
buildscript {
ext.kotlin_version = '1.3.61'
repositories {
jcenter()
}
dependencies {
classpath "com.commercehub.gradle.plugin:gradle-avro-plugin:0.17.0"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.junit.platform:junit-platform-gradle-plugin:1.2.0"
}
}
apply plugin: "org.junit.platform.gradle.plugin"
apply plugin: "kotlin"
apply plugin: "java"
apply plugin: "maven-publish"
apply plugin: "com.commercehub.gradle.plugin.avro"
task generateAvro(type: GenerateAvroJavaTask) {
source("src/test/java/avro/")
outputDir = file("src/test/java/")
}
compileJava.source(generateAvro.outputs)
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
repositories {
mavenCentral()
mavenLocal()
jcenter()
}
dependencies {
// JAX-B dependencies for JDK 9+
implementation "jakarta.xml.bind:jakarta.xml.bind-api:2.3.2"
implementation "org.glassfish.jaxb:jaxb-runtime:2.3.2"
// implementation 'org.junit.jupiter:junit-jupiter-api:5.0.0-M5'
implementation 'com.github.dozermapper:dozer-core:6.5.0'
implementation 'org.apache.avro:avro:1.9.1'
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.61'
//implementation 'org.jetbrains.kotlin:kotlin-test:1.3.61'
implementation 'org.jetbrains.kotlin:kotlin-reflect:1.3.61'
implementation 'io.github.microutils:kotlin-logging:1.7.7'
implementation 'org.slf4j:slf4j-jdk14:1.7.25'
testImplementation 'io.kotlintest:kotlintest-runner-junit5:3.0.2'
testImplementation 'org.jetbrains.kotlin:kotlin-test:1.3.61'
//testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.0'
//testImplementation ('org.junit.jupiter:junit-jupiter-params:5.6.0')
//testImplementation ('org.mockito:mockito-junit-jupiter:3.2.4')
testImplementation("org.junit.platform:junit-platform-launcher:1.6.0")
testRuntimeOnly ('org.junit.jupiter:junit-jupiter-engine:5.6.0')
test.useJUnitPlatform() // fix "test events not received" bug in IDEA
}
test {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
}
}
sourceCompatibility = '1.8'
publishing {
publications {
maven(MavenPublication) {
from(components.java)
}
}
}
что я делаю не так? Как я могу построить проект с запуском тестов Gradle?