Solution for cofoja/lombok conflict with maven

92 views
Skip to first unread message

José María

unread,
Apr 20, 2014, 7:21:15 AM4/20/14
to cof...@googlegroups.com
Hello!

I've been investigating how to automate the compilation with maven when using both annotation processors, lombok & cofoja. I've found finally how to compile and run test without conflicts. Here I write the relevant pom fragment:


...

        <dependency>
            <groupId>com.google.java.contract</groupId>
            <artifactId>cofoja</artifactId>
            <version>1.1-r150</version>
        </dependency>
        
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.12.6</version>
        </dependency>
...

<build>
        <plugins>
            <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-agents</id>
                        <phase>initialize</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>com.google.java.contract</groupId>
                                    <artifactId>cofoja</artifactId>
                                    <version>1.1-r150</version>
                                    <outputDirectory>${project.build.directory}/agents</outputDirectory>
                                    <destFileName>cofoja-1.1-r150.jar</destFileName>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>org.projectlombok</groupId>
                                    <artifactId>lombok</artifactId>
                                    <version>1.12.6</version>
                                    <outputDirectory>${project.build.directory}/agents</outputDirectory>
                                    <destFileName>lombok-1.12.6.jar</destFileName>
                                </artifactItem>
                            </artifactItems>
                        </configuration> 
                    </execution>
                </executions>
            </plugin>
            
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
                <executions>
                    <execution>
                        <id>default-compile></id>
                        <configuration>
                            <includes>
                                <include>${project.build.directory}/agents/lombok-1.12.6.jar</include>
                            </includes>
                        </configuration>
                    </execution>
                    <execution>
                        <id>compile-everything-else</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                        <configuration>
                            <compilerArgument>-proc:only</compilerArgument>
                            <includes>
                                <include>${project.build.directory}/agents/cofoja-1.1-r150.jar</include>
                            </includes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.17</version>
                <executions>
                    <execution>
                        <phase>test</phase>
                    </execution>
                </executions>
                <configuration>
                    <argLine>-javaagent:${project.build.directory}/agents/cofoja-1.1-r150.jar</argLine>
                </configuration>
            </plugin>
...

José María

unread,
Apr 22, 2014, 12:47:36 PM4/22/14
to cof...@googlegroups.com
Sorry, I thought it worked but it doesn't :-(
Reply all
Reply to author
Forward
0 new messages