Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot compile the project in multi-module Maven setup #2808

Open
Fossan opened this issue Sep 5, 2024 · 1 comment
Open

Cannot compile the project in multi-module Maven setup #2808

Fossan opened this issue Sep 5, 2024 · 1 comment
Labels

Comments

@Fossan
Copy link

Fossan commented Sep 5, 2024

Describe the bug
I have a multi-module Maven project, in which one of the shared modules is called commons and is used by other modules (let's called them A and B).
All modules (A, B and commons) contain classes that are @Serializable.
All modules do have kotlinx-serialization-json-jvm dependency.
The kotlin-maven-plugin is configured for all modules as follows:

  <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>
      </executions>
      <configuration>
          <jvmTarget>21</jvmTarget>
          <compilerPlugins>
              <plugin>kotlinx-serialization</plugin>
          </compilerPlugins>
      </configuration>
      <dependencies>
          <dependency>
              <groupId>org.jetbrains.kotlin</groupId>
              <artifactId>kotlin-maven-serialization</artifactId>
              <version>${kotlin.version}</version>
          </dependency>
      </dependencies>
  </plugin>

When compiling the project, I'm getting an error on the first module that is using commons as dependency (e.g. A):

Your current kotlinx.serialization core version is 2.0.20, while current Kotlin compiler plugin unknown requires at least 1.0-M1-SNAPSHOT. Please update your kotlinx.serialization runtime dependency.

When I removed all @Serializable classes from commons and got rid of the plugin there, project was compiling again.
As a temporary workaround, I can suppress errors on all @Serializable classes which makes the compilation working:
@Suppress("PROVIDED_RUNTIME_TOO_LOW", "INLINE_CLASSES_NOT_SUPPORTED")
To Reproduce
In commons module:

@JvmInline
@Serializable
value class UserId(
    val id: String,
)

In A module:

import commons.UserId

@Serializable
data class Event(
    val userId: UserId,
)

Expected behavior
Multi-module Maven project can be compiled without any errors.

Environment

  • Kotlin version: 2.0.20
  • Library version: 1.7.2
  • Kotlin platforms: JVM
  • Maven version: 3.9.7
  • IDE version: IntelliJ IDEA 2024.2.1
  • Other relevant context: MacOS 14.5, JRE 21.0.4 Temurin
@sandwwraith
Copy link
Member

Is the error reproducible when running mvn package or only in IDE?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants