Kotlin: Unresolved reference: jetbrains

已完成

Hi,

I installed IntelliJ IDE Community to create a TeamCity build configuration using Kotlin. However, when I build the .teamcity folder, IntelliJ keeps throwing multiple errors one of which is "Kotlin: Unresolved reference: jetbrains". How do I get IntelliJ to resolve all the jetbrains references used in the import statements above? I'm guessing once it pulls those packages, it should resolve all other errors, too.

Thanks!

1

Hi! 

Could you please open the side Maven panel in IDEA (by default on the right), then click the Reload All Maven Projects action in the panel. If that doesn't help, go to File > Invalidate caches... > tick the checkboxes to clear all caches > Invalidate and Restart.

If the issue is still there, try to run the following commands in the .teamcity folder. Please note, Maven has to be installed on your machine, and the path to mvn executable's dir added to your account's PATH variable.

mvn dependency:purge-local-repository
mvn clean compile

If that still doesn't help, try purging the <user_home>/.m2 folder and running the commands above. If that doesn't resolve the issue either, would you be able to provide the content of the pom.xml file the output of mvn clean compile -X?

KR,
-Anatoly 

1

Thanks, Anatoly. Reload all maven projects helped. 

0

Hello, I am dealing with the same problem actually.

0

Hi Anatoly Cherenkov ! In my case, there was an internal corporate Artifactory with a custom root CA. After keytool -import <…> in command line mvn clean compile works, but still have an Unresolved reference 'jetbrains'. errors in IDEA. And it seems that the problem appears in the .teamcity/patches directory only.

0
<?xml version="1.0"?>
<project>
    <modelVersion>4.0.0</modelVersion>
    <name>_Root Config DSL Script</name>
    <groupId>_Root</groupId>
    <artifactId>_Root_dsl</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <serialization.version>1.0.0-RC</serialization.version>
    </properties>

    <parent>
        <groupId>org.jetbrains.teamcity</groupId>
        <artifactId>configs-dsl-kotlin-parent</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>

    <repositories>
        <repository>
            <id>bucket-jetbrains-teamcity</id>
            <url>https://artifactory.internal/artifactory/jetbrains-teamcity</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>teamcity-server</id>
            <url>https://teamcity.internal/app/dsl-plugins-repository</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>bucket-central</id>
            <url>https://artifactory.internal/artifactory/central/</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>

    <pluginRepositories>
        <pluginRepository>
            <id>bucket-jetbrains-teamcity</id>
            <url>https://artifactory.internal/artifactory/jetbrains-teamcity</url>
        </pluginRepository>
        <pluginRepository>
            <id>bucket-central</id>
            <url>https://artifactory.internal/artifactory/central/</url>
        </pluginRepository>
    </pluginRepositories>

    <build>
        <sourceDirectory>${basedir}</sourceDirectory>
        <testSourceDirectory>${basedir}/tests</testSourceDirectory>
        <plugins>
            <plugin>
                <artifactId>kotlin-maven-plugin</artifactId>
                <groupId>org.jetbrains.kotlin</groupId>
                <version>${kotlin.version}</version>

                <configuration />
                <executions>
                    <execution>
                        <id>compile</id>
                        <phase>process-sources</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>test-compile</id>
                        <phase>process-test-sources</phase>
                        <goals>
                            <goal>test-compile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.jetbrains.teamcity</groupId>
                <artifactId>teamcity-configs-maven-plugin</artifactId>
                <version>${teamcity.dsl.version}</version>
                <configuration>
                    <format>kotlin</format>
                    <dstDir>target/generated-configs</dstDir>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>org.jetbrains.teamcity</groupId>
            <artifactId>configs-dsl-kotlin-latest</artifactId>
            <version>${teamcity.dsl.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.jetbrains.teamcity</groupId>
            <artifactId>configs-dsl-kotlin-plugins-latest</artifactId>
            <version>1.0-SNAPSHOT</version>
            <type>pom</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-stdlib</artifactId>
            <version>${kotlin.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-stdlib-jdk8</artifactId>
            <version>${kotlin.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-stdlib-common</artifactId>
            <version>${kotlin.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-script-runtime</artifactId>
            <version>${kotlin.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-reflect</artifactId>
            <version>${kotlin.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.module</groupId>
            <artifactId>jackson-module-kotlin</artifactId>
            <version>2.19.0</version>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>5.9.2</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.jetbrains.teamcity</groupId>
            <artifactId>server-api</artifactId>
            <version>${teamcity.dsl.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>
0

Maybe that's because there are .kts files..

0
I'd recommend checking it with `mvn teamcity-configs:generate` and ensuring it works. If it doesn't, please troubleshoot accordingly. If `mvn teamcity-configs:generate` works, but you still see unresolved references in IDEA, most likely it means that IDEA cannot resolve the necessary dependencies. That could happen if IDEA uses a different JDK or Maven runtime from what is used in the command line.
0

Anatoly Cherenkov , mvn teamcity-configs:generate works, even if it was run from the IDEA Maven panel. Imported classes are present under Project > External Libraries, and are OK in .kt files. But in .kts files they are not available.

0
Can you share a minimal project that reproduces the issue? Preferably, without dependencies on artifacts from a private repository. You can upload it via https://uploads.jetbrains.com/ and specify the specify the upload ID.
Also, which version of IDEA do you use?
0

请先登录再写评论。