Getting "Cannot resolve org.jenkins-ci.main" when trying to build plugin

I’m working on a plugin and I don’t know what could’ve possibly triggered this issue, but I was building a new hpi to hand off to a QA member. My process that I’ve always used, and performed multiple times today, is to do through Maven: clean; hpi:run; hpi:hpi.

Only things I’m finding even remotely relevant on the web is about missing jenkins-ci repository references, but I definitely have them in my pom, and I added to my .m2/settings.xml for good measure and still nothing

Java is far from my primary and I’m only familiar with IntelliJ, so I apologize for any lack of clarity

Here’s a screenshot in case it’s useful, and my pom.xml. Thanks

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.jenkins-ci.plugins</groupId>
        <artifactId>plugin</artifactId>
        <version>4.16</version>
        <relativePath />
    </parent>
    <artifactId>fortify-on-demand-uploader</artifactId>
    <version>7.0.0-SNAPSHOT</version>
    <packaging>hpi</packaging>

    <properties>
        <jenkins.version>2.263</jenkins.version>
        <java.level>8</java.level>
        <jenkins-test-harness.version>2.47</jenkins-test-harness.version>
        <disabledTestInjection>true</disabledTestInjection>
        <skipTests>false</skipTests>
    </properties>

    <name>Fortify on Demand</name>
    <description>Gathers build artifacts and uploads them to the Fortify on Demand service with user-specified options.</description>
    <url>https://github.com/jenkinsci/fortify-on-demand-uploader-plugin</url>

    <licenses>
        <license>
            <name>MIT License</name>
            <url>https://opensource.org/licenses/MIT</url>
        </license>
    </licenses>

    <scm>
        <connection>scm:git:git@github.com:jenkinsci/fortify-on-demand-uploader-plugin.git</connection>
        <developerConnection>scm:git:git@github.com:jenkinsci/fortify-on-demand-uploader-plugin.git</developerConnection>
        <url>https://github.com/jenkinsci/fortify-on-demand-uploader-plugin</url>
        <tag>HEAD</tag>
    </scm>

    <developers>
        <developer>
            <id>abec</id>
            <name>Alberto Bec</name>
            <email>alberto.bec@microfocus.com</email>
        </developer>
        <developer>
            <id>aishkotni</id>
            <name>Aishwarya Kotni</name>
            <email>aishwarya.kotni@microfocus.com</email>
        </developer>
    </developers>

    <repositories>
        <repository>
            <id>repo.jenkins-ci.org</id>
            <url>https://repo.jenkins-ci.org/public/</url>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>repo.jenkins-ci.org</id>
            <url>https://repo.jenkins-ci.org/public/</url>
        </pluginRepository>
    </pluginRepositories>
    <dependencies>

        <!-- for Jenkins Pipelines -->
        <dependency>
            <groupId>org.jenkins-ci.plugins.workflow</groupId>
            <artifactId>workflow-step-api</artifactId>
            <version>2.19</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp -->
        <dependency>
            <groupId>com.squareup.okhttp3</groupId>
            <artifactId>okhttp</artifactId>
            <version>3.9.0</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.squareup.okio/okio -->
        <dependency>
            <groupId>com.squareup.okio</groupId>
            <artifactId>okio</artifactId>
            <version>1.13.0</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.7</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/junit/junit -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.5.3</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/commons-logging/commons-logging -->
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>org.jenkins-ci.plugins</groupId>
            <artifactId>plain-credentials</artifactId>
            <version>1.5</version>
        </dependency>
        <dependency>
            <groupId>org.jenkins-ci.plugins</groupId>
            <artifactId>credentials</artifactId>
            <version>2.3.0</version>
        </dependency>
        <dependency>
            <groupId>org.jenkins-ci.plugins</groupId>
            <artifactId>structs</artifactId>
            <version>1.19</version>
        </dependency>
        <dependency>
            <groupId>com.googlecode.json-simple</groupId>
            <artifactId>json-simple</artifactId>
            <version>1.1</version>
        </dependency>
        <dependency>
            <groupId>io.jenkins.plugins</groupId>
            <artifactId>jquery3-api</artifactId>
            <version>3.6.0-1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-artifact</artifactId>
            <version>3.6.3</version>
        </dependency>
    </dependencies>

    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>**/application.properties</include>
                </includes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>false</filtering>
                <excludes>
                    <exclude>**/application.properties</exclude>
                </excludes>
            </resource>
        </resources>
    </build>
</project>

I should also add, the only changes I made from last successful build was 1 line in a JS file, and I’ve already restarted my IDE and computer multiple times

What’s the actual error message?

Can you try to use a different Jenkins baseline like 2.289 (or upgrade IntelliJ to latest version). I think that this has been fixed now.

Shouldn’t recommended baselines be LTS variants?

2.289 is one of our LTS baselines. Or do you ask why I did not use 2.289.1? This suffix is added automatically in my plugin pom files so I skipped it here analysis-pom-plugin/pom.xml at 5ee954254288a9194da159eefe415ec64f64301e · jenkinsci/analysis-pom-plugin · GitHub

@uhafner , interesting approach. I did not see same in posted pom.

From your response then, the x.xxx.1 should be the reference.

Cannot resolve org.jenkins-ci.main

I tried one more time before applying this, now I’m getting a connection refused error. Tried changing the baseline version and same. I’m starting to think something got corrupted in my Maven or IntelliJ install. I’m going to completely reinstall both and give that a shot.

Thanks

I just tried git cloning this, then mvn verify package and things worker properly (though you have a javadoc warning).

If reinstalling doesn’t help. I recommend looking at your local changes (git diff) or more details in the error message (like what URLs its trying and failing to download from)

This message 'Cannot resolve org.jenkins-ci.main" is a known IntelliJ-Maven integration problem (see https://groups.google.com/g/jenkinsci-dev/c/RGlvJSxq8gc/m/OU-Ts_zsEAAJ). However, it does not hurt, everything else works as it should.

BTW: I do not get those error messages anymore with IntelliJ 2021.3 and Jenkins 2.289.1.

Just getting back to this project after vacation and a fresh install of IntelliJ fixed it.

Thank you all for your help.