简体   繁体   中英

Getting error duing maven org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile goal

While trying to build a gerrit plugin project, I seem to be seeing this error

[ERROR] error: Bad service configuration file, or exception thrown while constructing Processor object: javax.annotation.processing.Processor: com.ryanharter.auto.value.gson.factory.AutoValueGsonAdapterFactoryProcessor Unable to get public no-arg constructor
[ERROR]

There are not many details to what you're trying to do, but I've found this through a simple google search:

The default maven lifecycle runs javac with javax.annotation.processing.Processor file as a part of classpath. This cause compiler to expect a compiled instance of annotation processors listed in the files. But LogMeCustomAnnotationProcessor is not compiled at that moment so compiler raises "Bad service configuration file..." error. See bug report.

To solve this issue maven compilation phase can be separated to compile annotation processor at the first place and then compile whole project.

<build>
<plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.5.1</version>
        <configuration>
            <source>1.8</source>
            <target>1.8</target>
        </configuration>
        <executions>
            <execution>
                <id>default-compile</id>
                <configuration>
                    <compilerArgument>-proc:none</compilerArgument>
                    <includes>
                        <include>fun/n/learn/annotation/LogMeCustomAnnotationProcessor.java</include>
                        <!--include dependencies required for LogMeCustomAnnotationProcessor -->
                    </includes>
                </configuration>
            </execution>
            <execution>
                <id>compile-project</id>
                <phase>compile</phase>
                <goals>
                    <goal>compile</goal>
                </goals>
            </execution>
        </executions>
    </plugin>
</plugins>

default-compile execution compiles LogMeCustomAnnotationProcessor with disabled annotation processing in order to have successful compilation. compile-project compiles whole project with annotaton processing.

I managed to fix this by adding the dependency to my plugin's dependency list as a provided dependency. Hope this helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM