Hey, so I’ve got two projects (A and B) both depending on google’s Inject and SLF4J. Project A is a maven project and project B is a Gradle project. Both projects had to have these libs added to the classpath of the project. So both projects are basically identical up until this point other than the build tool being used. I can not build project B (gradle project) without getting the error:
Executing external task ‘build’…
C:\some-hidden-path\SpearMod.java:3: error: package com.google.inject does not exist
import com.google.inject.Inject;
^
C:\some-hidden-path\SpearMod.java:8: error: package org.slf4j does not exist
import org.slf4j.Logger;
^
C:\some-hidden-path\SpearMod.java:19: error: cannot find symbol
private Logger logger;
^
symbol: class Logger
location: class SpearMod
C:\some-hidden-path\SpearMod.java:58: error: cannot find symbol
public Logger getLogger() {
^
symbol: class Logger
location: class SpearMod
C:\some-hidden-path\SpearMod.java:18: error: cannot find symbol @Inject
^
symbol: class Inject
location: class SpearMod
C:\some-hidden-path\SpearMod.java:21: error: cannot find symbol @Inject
^
symbol: class Inject
location: class SpearMod
C:\some-hidden-path\SpearMod.java:24: error: cannot find symbol @Inject
^
symbol: class Inject
location: class SpearMod
7 errors
:compileJava FAILED
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ‘:compileJava’.
Compilation failed; see the compiler error output for details.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 0.512 secs
Compilation failed; see the compiler error output for details.
External task execution finished ‘build’.
I’ve compared the classpaths in IntelliJ 14 but I have been unable to deduce why I can build one and not the other. I am sure there’s a perfectly understandable solution but at this point in time I’m pretty stumped. Any advice/suggestions would be more than appreciated. I would prefer to use Gradle over Maven.
They both have the required libs as far as I know.
EDIT: I’ve now made project B have the EXACT same dependencies as project A but it still says that slf4j and inject do not exist. They’re marked as provided, why does it “need” them?
Okay, so I’ve attempted to invalidate my caches with IntelliJ. It resulted in SLF4J and Google Inject no longer being libs in my module. I only hit this issue with Gradle (not with Maven).
I’m at my wits end at this point. I’ve tried rearranging the dependencies, manually adding them etc. Is there something I’m missing in my build.gradle?
(it’s properly formatted in my actual file, the forums don’t want it to be on one line- at least in preview mode)
I know that the SpongeAPI does not uber-jar/shade/fatjar its dependencies, so perhaps I should somehow be marking my dependency of the API in a way so that it also depends on its dependencies?
Still no luck. I’ve been trying everything I can. Instead of using my own remote repo I even used sponge’s and I still get this: http://prntscr.com/799q9l. I’ve tried all possible imports/adding etc and I can’t seem to get my Gradle project to build without it telling me Inject/SLF4J packages do not exist…
So I removed all my modules, closed my IDE, then I ran gradle clean build --refresh-dependencies on the module (or “project”) but I still get the same result from that command as shown in the OP.
Okay, so I resolved the issue for now. I had another dependency in the module that seems to prevent it from compiling giving off the error in OP. When I remove it I get no issues compiling. Although it’s an API and the plugin is the implementation so it needs to be able to be fatJar’d together, but then ALL the dependencies get fatJar’d.