Skip to content

IntelliJ IDEA unable to resolve classes of project dependency shadow jar #264

Open
@Favorlock

Description

@Favorlock

Shadow: 1.2.4
Gradle: 2.5

From what I understand compile project(path: ':common', configuration: 'shadow') should result in the shaded artifact being selected as a dependency. This appears to work, however, IntelliJ IDEA will not resolve the contents of the shaded artifact.

Now here is the weird thing, if I change the configuration of the project dependencies to compile, the IDE is able to resolve the classes but the compiler cannot. If I change it back to shadow the compiler can resolve the classes and the IDE cannot... o.O

root build.gradle

buildscript {
    repositories {
        mavenCentral()
        maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
        maven { url 'https://plugins.gradle.org/m2/' }
    }
}

plugins {
    id 'nebula.provided-base' version '3.0.3'
    id 'com.github.johnrengelman.shadow' version '1.2.4'
}

subprojects {
    apply plugin: 'eclipse'
    apply plugin: 'idea'
    apply plugin: 'java'
    apply plugin: 'nebula.provided-base'
    apply plugin: 'maven'
    apply plugin: 'com.github.johnrengelman.shadow'

    idea {
        module {
            scopes.PROVIDED.plus += [configurations.shadow]
        }
    }

    tasks.withType(AbstractCompile) {
        classpath += configurations.shadow
    }

    ext {
        junit = '4.12'
        lombok = '1.16.8'
        guava = '19.0'
        gson = '2.3.1'
        log4j = '2.0-beta9'
        jsonrpc2 = '1.15'
        json_smart = '1.3.1'
        reflections = '0.9.10'
        javassist = '3.12.1.GA'
        zip4j = '1.3.2'
    }

    repositories {
        mavenLocal()
        mavenCentral()
        maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
        maven { url 'https://oss.sonatype.org/content/repositories/releases/' }
    }

    dependencies {
        testCompile group: 'junit', name: 'junit', version: junit
        provided group: 'net.minidev', name: 'json-smart', version: json_smart
        provided group: 'org.projectlombok', name: 'lombok', version: lombok
        provided group: 'com.google.guava', name: 'guava', version: guava
        provided group: 'org.apache.logging.log4j', name: 'log4j-core', version: log4j
        provided group: 'com.google.code.gson', name: 'gson', version: gson
        provided group: 'net.lingala.zip4j', name: 'zip4j', version: zip4j
    }

    shadowJar {
        relocate 'com.google.gson', 'com.enjin.shaded.gson'
        relocate 'net.minidev.json', 'com.enjin.shaded.json'
    }
}

subproject core build.gradle

sourceCompatibility = 1.7

dependencies {
    compile group: 'com.google.code.gson', name: 'gson', version: gson
}

shadowJar {
    dependencies {
        include(dependency('.*:json-smart'))
        include(dependency('.*:gson'))
    }
}

subproject rpcapi build.gradle

sourceCompatibility = 1.7

dependencies {
    compile project(path: ':core', configuration: 'shadow')
    compile group: 'com.thetransactioncompany', name: 'jsonrpc2-client', version: jsonrpc2
}

shadowJar {
    dependencies {
        include(project(':core'))
        include(dependency('com.thetransactioncompany:.*'))
    }
}

And so on...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions