Skip to content
This repository has been archived by the owner on Aug 26, 2021. It is now read-only.

No methods listed for "You have these unused @Provider methods" #429

Open
fbiville opened this issue Aug 7, 2014 · 8 comments
Open

No methods listed for "You have these unused @Provider methods" #429

fbiville opened this issue Aug 7, 2014 · 8 comments

Comments

@fbiville
Copy link

fbiville commented Aug 7, 2014

Hi, I have this module:

package com.vidal.rest.sdk;

import com.vidal.rest.sdk.converters.AtomConverter;
import com.vidal.rest.sdk.converters.AtomDeserializerFactory;
import dagger.Module;
import dagger.ObjectGraph;
import dagger.Provides;
import retrofit.RestAdapter;
import retrofit.converter.Converter;

@Module
public class VidalAPI {

    private final String uri;

    private VidalAPI(String uri) {
        this.uri = uri;
    }

    public static Resources at(String uri) {
        ObjectGraph graph = ObjectGraph.create(new VidalAPI(uri));
        return graph.get(ResourceFactory.class);
    }

    @Provides
    ResourceFactory resourceFactory(RestAdapter restAdapter) {
        return new ResourceFactory(restAdapter);
    }

    @Provides
    RestAdapter restAdapter(Converter converter) {
        return new RestAdapter.Builder()
                .setConverter(converter)
                .setEndpoint(uri)
                .build();
    }

    @Provides
    Converter converter(AtomDeserializerFactory deserializers) {
        return new AtomConverter(deserializers);
    }

    @Provides
    AtomDeserializerFactory deserializers() {
        return new AtomDeserializerFactory();
    }

}

Whenever I try building the project, I get this:

[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /home/fbiville/Projects/vidal-rest-sdk/src/main/java/com/vidal/rest/sdk/VidalAPI.java:[11,7] error: Graph validation failed: You have these unused @Provider methods:
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------

Without any faulty methods listed >:(.
I guess that's a bug, or?

@cgruber
Copy link
Collaborator

cgruber commented Aug 7, 2014

I believe that is must maven hiding your error message detail. Please use
"mvn -e" (or mvn -X) to get more detail on the error messages.

On 7 August 2014 04:41, @fbiville [email protected] wrote:

Hi, I have this module:

@module
public class VidalAPI {

private final String uri;

private VidalAPI(String uri) {
    this.uri = uri;
}

public static Resources at(String uri) {
    ObjectGraph graph = ObjectGraph.create(new VidalAPI(uri));
    return new ResourceFactory(graph.get(RestAdapter.class));
}

@Provides
RestAdapter restAdapter(AtomConverter converter) {
    return new RestAdapter.Builder()
            .setConverter(converter)
            .setEndpoint(uri)
            .build();
}

@Provides
AtomConverter converter(AtomDeserializerFactory deserializers) {
    return new AtomConverter(deserializers);
}

@Provides
AtomDeserializerFactory deserializers() {
    return new AtomDeserializerFactory();
}

Whenever I try building the project, I get this:

[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /home/fbiville/Projects/vidal-rest-sdk/src/main/java/com/vidal/rest/sdk/VidalAPI.java:[11,7] error: Graph validation failed: You have these unused @Provider methods:
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------

Without any faulty methods listed >:(.


Reply to this email directly or view it on GitHub
#429.

@fbiville
Copy link
Author

fbiville commented Aug 7, 2014

Hmmm, it does not seem to provide more information:

➜  vidal-rest-sdk git:(issue_1_dagger) mvn -e clean install
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] 
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder with a thread count of 4
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building vidal-rest-sdk 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ vidal-rest-sdk ---
[INFO] Deleting /home/flo/Projects/_VIDAL/vidal-rest-sdk/target
[INFO] 
[INFO] --- maven-enforcer-plugin:1.3.1:enforce (enforce-versions) @ vidal-rest-sdk ---
[INFO] 
[INFO] --- jacoco-maven-plugin:0.7.1.201405082137:prepare-agent (prepare-agent) @ vidal-rest-sdk ---
[INFO] argLine set to -javaagent:/home/flo/.m2/repository/org/jacoco/org.jacoco.agent/0.7.1.201405082137/org.jacoco.agent-0.7.1.201405082137-runtime.jar=destfile=/home/flo/Projects/_VIDAL/vidal-rest-sdk/target/jacoco.exec
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ vidal-rest-sdk ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/flo/Projects/_VIDAL/vidal-rest-sdk/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ vidal-rest-sdk ---
[INFO] Compiling 10 source files to /home/flo/Projects/_VIDAL/vidal-rest-sdk/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /home/flo/Projects/_VIDAL/vidal-rest-sdk/src/main/java/com/vidal/rest/sdk/VidalAPI.java:[12,7] error: Graph validation failed: You have these unused @Provider methods:
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.399 s (Wall Clock)
[INFO] Finished at: 2014-08-07T21:26:02+01:00
[INFO] Final Memory: 15M/87M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project vidal-rest-sdk: Compilation failure
[ERROR] /home/flo/Projects/_VIDAL/vidal-rest-sdk/src/main/java/com/vidal/rest/sdk/VidalAPI.java:[12,7] error: Graph validation failed: You have these unused @Provider methods:
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project vidal-rest-sdk: Compilation failure
/home/flo/Projects/_VIDAL/vidal-rest-sdk/src/main/java/com/vidal/rest/sdk/VidalAPI.java:[12,7] error: Graph validation failed: You have these unused @Provider methods:

    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:108)
    at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call(MultiThreadedBuilder.java:188)
    at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call(MultiThreadedBuilder.java:184)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:744)
Caused by: org.apache.maven.plugin.CompilationFailureException: Compilation failure
/home/flo/Projects/_VIDAL/vidal-rest-sdk/src/main/java/com/vidal/rest/sdk/VidalAPI.java:[12,7] error: Graph validation failed: You have these unused @Provider methods:

    at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:729)
    at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:128)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:133)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    ... 11 more
[ERROR] 
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

@JakeWharton
Copy link
Collaborator

The error should be on resourceFactory as in Dagger's eyes it's unused.

You can change your @Module declaration to fix:

@Module(injects = ResourceFactory.class)

@fbiville
Copy link
Author

fbiville commented Aug 7, 2014

Hurray! That's it!
I should have RTFM on Module.class.

How come the faulty method was not displayed, though? Should I keep the issue open for that?

@JakeWharton
Copy link
Collaborator

Yeah keep it open. We'll try and figure it out. Can you paste the output from mvn -v?

@fbiville
Copy link
Author

fbiville commented Aug 7, 2014

Sure thing

➜  vidal-rest-sdk git:(issue_1_dagger) mvn -v
Apache Maven 3.2.1 (ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9; 2014-02-14T18:37:52+01:00)
Maven home: /home/flo/Tools/maven
Java version: 1.8.0, vendor: Oracle Corporation
Java home: /home/flo/Tools/jdk1.8.0/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.11.0-26-generic", arch: "amd64", family: "unix"

@heenenee
Copy link

I also had this problem with maven-compiler-plugin:2.5.1, but I changed to maven-compiler-plugin:3.3 and then the unused @Provider methods were successfully displayed upon compilation failure. So it's probably some old bug in the maven-compiler-plugin failing to show multi-line error messages.

@heenenee
Copy link

Additionally, the unused @Provider methods are once again suppressed if <fork>true</fork> is set on the maven-compiler-plugin configuration, even on version 3.3. So there is still probably a bug regarding multi-line error messages in the maven-compiler-plugin.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants