michaelbull / kotlin-result

A multiplatform Result monad for modelling success or failure operations.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problem with using kotlin-result via maven

filipamb opened this issue · comments

Hello

I am trying to add kotlin-result to my maven project, however strange things starts to happen then. After adding

<dependency>
  <groupId>com.michael-bull.kotlin-result</groupId>
  <artifactId>kotlin-result</artifactId>
  <version>1.1.11</version>
</dependency>

Dependency is added, jar is downloaded , however I cannot import any class - maven just doesn't see classes from com.github.michaelbull package.

My properties for kotlin and java are:

<java.version>11</java.version>
<kotlin.version>1.4.31</kotlin.version>

Do you know what can cause such problems? I have never had such problem with any other library.

Can you provide a log of the maven command you're running in which it fails to resolve anything from that package? Failing that a reproducible test case would also help.

@michaelbull thx for quick response! I have just created repo from spring initializer using maven and kotlin. It's just plain repo with additional kotlin-result dependency
https://github.com/filipamb/kotlin-result-maven/blob/master/pom.xml

Here is class where I am trying to import Result
https://github.com/filipamb/kotlin-result-maven/blob/master/src/main/kotlin/com/example/demo/TestClass.kt

Error log:

[ERROR] Failed to execute goal org.jetbrains.kotlin:kotlin-maven-plugin:1.4.31:compile (compile) on project demo: Compilation failure
[ERROR] /home/filip/IdeaProjects/demo/src/main/kotlin/com/example/demo/TestClass.kt:[3,38] Unresolved reference: Result
[ERROR]
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

It seems the problem is that Maven doesn't know what environment you're trying to build for the same way Gradle does, so you'll have to explicitly depend on whichever platform version you want. For it to resolve the JVM artifacts properly I used this:

		<dependency>
			<groupId>com.michael-bull.kotlin-result</groupId>
			<artifactId>kotlin-result-jvm</artifactId>
			<version>1.1.11</version>
		</dependency>

@filipamb did the above comment resolve your issue?

Ye, helped. Thanks!

Hello,

May be the README sould be updated with a Maven Installation section containing the dependency above. I have run into the same issue.