IntelliJ cannot resolve Kotlin stdlib members within bundle - intellij-idea

According to the Kotlin docs, there is an OSGi bundle for the Kotlin standard libraries. However, if I replace kotlin-stdlib with this bundle as recommended:
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-osgi-bundle</artifactId>
<version>${kotlin.version}</version>
<type>bundle</type>
</dependency>
IntelliJ is no longer able to find any classes or functions from the stdlib (i.e. println):
If I build and run the project (with maven-pax-plugin), everything works fine - it just seems to have broken IntelliJ's analysis capabilities.
How should I properly include Kotlin as an OSGi dependency?
I am using maven-bundle-plugin to build this bundle.

If you remove the type section, it should work:
<type>bundle</type>
The Kotlin OSGi bundle is not a Maven bundle artifact.
For Intellij IDEA 2018.2, works for me, using this way :
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-osgi-bundle</artifactId>
<version>${kotlin.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>${kotlin.version}</version>
</dependency>

Related

Missing artifact com.fasterxml.jackson.core:jackson-databind:bundle:2.9.8

Working with Jackson library, it came following error in Eclipse 4.9.0 version
Missing artifact com.fasterxml.jackson.core:jackson-databind:bundle:2.9.6 pom.xml /Jackson-Usage line 7 Maven Dependency Problem
The problem came when I added maven dependencies by GUI to add dependencies.
The solution was from generated dependencies
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.8</version>
<type>bundle</type>
</dependency>
to remove and save.
<type>bundle</type>
xml
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.9</version>
<type>bundle</type>
</dependency>
Remove bundle and that should resolve the error code in eclipse.

How to see Kotlin stdlib source code in Intellij?

Any idea how to obtain the source code for Kotlin's stdlib?
In the screencap below, I don't have any option to download the source code like other maven libraries.
I'm using the following Kotlin dependency:
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>1.2.30</version>
</dependency>
For me it helps to change maven dependency on Kotlin in pom.xml from
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>1.2.30</version>
</dependency>
to
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>1.3.31</version>
</dependency>
</dependencies>
more info on adding Kotlin to project as maven dependency can be found here:
https://kotlinlang.org/docs/reference/using-maven.html

IntelliJ doesn't autocomplete JUnit 5 Jupiter classes

I have Maven imports for JUnit 5 in an IntelliJ install, and I have invalidated the cache and restarted.
IntelliJ will refuse to autocomplete (CTRL-SPACE) any class nor any static method belonging to classes in the org.junit.jupiter.api. package, unless the class' fully qualified name is spelled out. Even when writing the package for which the class belongs, will not suggest the classes of that package.
IntelliJ version is 2017.2.1. Jupiter version is 5.0.0-RC2, platform is 1.0.0-RC2.
I am unsure how to move on from here. How come this package is the only one that seems to refuse basic completion?
<properties>
<junit.jupiter.version>5.0.0-RC2</junit.jupiter.version>
<junit.platform.version>1.0.0-RC2</junit.platform.version>
</properties>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<!-- Only required to run tests in an IDE that bundles an older version -->
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>${junit.platform.version}</version>
<scope>test</scope>
</dependency>
<!-- Only required to run tests in an IDE that bundles an older version -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.jupiter.version}</version>
</dependency>
Please check those classes are not in exclude list in File | Settings | Editor | General | Auto Import
You can try to downgrade JUnit 5 to M4 instead of RC2. IntelliJ 2017.2 is based on JUnit 5 M4, maybe that is causing the problem you are facing.

JUnit and WebDriver by IntelliJ IDEA

Im working in IntelliJ and need to add dependency's to Selenum WebDriver and Junit.
I already added the jars (as mentioned in all possible tutorial) to my Project lib.
I can also see them in the project view - Selenium-java-2.39.0.jar, Selenium-java-2.39.0.srcs.jar, Selenium-server-standalone-2.39.0.jar AND junit-4.11.jar
Nevertheless, my project can not recognized this items (for example
import org.openqa.selenium.;
import static org.junit.Assert.;
Any ideas?
I would recommend investing some time learning about some dependency management solutions. Here are my top two selections:
Maven
Ivy
If using maven, you'd have a pom.xml in your project and you'd have something like:
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>${selenium_version}</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-htmlunit-driver</artifactId>
<version>${selenium_version}</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>${selenium_version}</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-safari-driver</artifactId>
<version>${selenium_version}</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-ie-driver</artifactId>
<version>${selenium_version}</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-support</artifactId>
<version>${selenium_version}</version>
</dependency>
...
</dependencies>
Ivy is very similar, but i won't get into it. If you need a project to get you started, you can check out this project (download here) which is used by Major League Gaming for their selenium framework
I agree, you should invest in a dependency management solution, but if you are not forced to use maven, try gradle.
It is way lighter and flexible...
In that case, my dependencies are resume to 1 line:
compile "org.gebish:geb-spock:0.9.2", "org.seleniumhq.selenium:selenium-firefox-driver:2.39.0", "org.seleniumhq.selenium:selenium-support:2.39.0"
I agree, I could add a second line with a property for the selenium version.
Gradle is really well supported by intellij Idea.
enjoy

Using Cucumber with IntelliJ

Does anyone knows why 'Cucumber Java' does not appear in "Edit Configurations -> Defaults -> ???? even though my pom file as downloaded the dependency i.e. cucumber-java (1.1.5)
<dependencies>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-core</artifactId>
<version>1.1.5</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.1.5</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.1.5</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>2.38.0</version>
</dependency>
</dependencies>
Pom.xml file is used to install all the necessary plugins i.e. cucumber for java plugin
Make sure you have installed and enabled the Cucumber for Java plugin from the JetBrains plugin repository.
Look in the File -> Settings...
And you cannot install plugins into IDEA via Maven.
Just to add on top of the Answer by- Eugene.
While searching for Cucumber plugin, under File>Settings>plugins of Intellij you might not be able to see any Plugin available for cucumber and this is very weird issue for IntelliJ on windows.. troubled me for Hours..
But to solve it- we just have to click on 'Search in repositories' link as displayed on search panel. This will show all available stuff and you can select Cucumber for Java(or whatever).