https://github.com/rzwitserloot/lombok/issues/942#issuecomment-154281184
Can't bag on the Lombok guys too much. Java 9 is not due to be released until next September.
--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/64c58060-e828-4a57-b2e2-f89eff04f51f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
That's what I figured. It can't hurt to ask, and my shipwreck will hopefully serve as a warning to others navigating these waters.
Yes, the Lombok guys have said their approach is a filthy hack. They're compile-time annotations, though, and this is the first time I've had any trouble at all in the 4-5 years I've been using them. Still, Bazel is a bigger win. I'll have to do without Lombok for now. It makes me sad, though.
> (there are better ways to avoid boilerplate)
I'm all ears.
The ones I use most are @Slf4j, @Getter/@Setter, and @Cleanup.
Hundreds of lines of machine-generated code are not a reasonable alternative to @Getter/@Setter, IMHO.
@Cleanup is nicer than try-with-resource, and I suspect the same applies to the Guava version.
Thanks for taking the time to reply, though.
Lombok has created an edge release that works with Bazel:
BazelJavaBuilder threw exception: java compilation returned status ERROR
...
external/local-jdk/bin/java -Xbootclasspath/p:external/bazel_tools/third_party/java/jdk/langtools/javac.jar -client -jar external/bazel_tools/tools/jdk/JavaBuilder_deploy.jar @bazel-out/local_linux-fastbuild/bin/my-project/libdefault.jar-2.params): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1: java failed: error executing command
(cd /home/tdgreenw/.cache/bazel/_bazel_tdgreenw/e44ccbe30899b3513451116133ca5b8d/my-project && \
exec env - \
Target //my-project:default failed to build
INFO: Elapsed time: 1.735s, Critical Path: 1.64s
$ grep lombok bazel-out/local_linux-fastbuild/bin/my-project/libdefault.jar-2.params
bazel-out/local_linux-fastbuild/genfiles/external/org/projectlombok/lombok/jar/_ijar/jar/external/org/projectlombok/lombok/jar/lombok-1.16.7-ijar.jar
--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/f60be4c3-916f-4778-acbb-c64b5bf0883f%40googlegroups.com.
We build with --verbose_failures, but there's not much additional information. Here's the full trace modulus the first 99 errors:
my-project/src/file.java:59: error: invalid method reference
.thenComparing(MyClass::getFoo)
^
cannot find symbol
symbol: method getFoo()
location: class MyClass
100 errors
BazelJavaBuilder threw exception: java compilation returned status ERROR
ERROR: /home/tdgreenw/temp/my-workspace/my-project/BUILD:9:1: Java compilation in rule '//my-project:default' failed: java failed: error executing command
(cd /home/tdgreenw/.cache/bazel/_bazel_tdgreenw/e44ccbe30899b3513451116133ca5b8d/my-workspace && \
exec env - \
external/local-jdk/bin/java -Xbootclasspath/p:external/bazel_tools/third_party/java/jdk/langtools/javac.jar -client -jar external/bazel_tools/tools/jdk/JavaBuilder_deploy.jar @bazel-out/local_linux-fastbuild/bin/my-project/libdefault.jar-2.params): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1: java failed: error executing command
(cd /home/tdgreenw/.cache/bazel/_bazel_tdgreenw/e44ccbe30899b3513451116133ca5b8d/my-workspace && \
exec env - \
external/local-jdk/bin/java -Xbootclasspath/p:external/bazel_tools/third_party/java/jdk/langtools/javac.jar -client -jar external/bazel_tools/tools/jdk/JavaBuilder_deploy.jar @bazel-out/local_linux-fastbuild/bin/my-project/libdefault.jar-2.params): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1.
Target //my-project:default failed to build
INFO: Elapsed time: 1.735s, Critical Path: 1.64s
Our version of Bazel is 0.1.1 - which arguably is a bit old (October).
Project:
$ find my-app/ | egrep -v .git
my-app/
my-app/BUILD
my-app/DEPS
my-app/README.md
my-app/pom.xml
my-app/src
my-app/src/test
my-app/src/test/java
my-app/src/test/java/com
my-app/src/test/java/com/mycompany
my-app/src/test/java/com/mycompany/app
my-app/src/test/java/com/mycompany/app/AppTest.java
my-app/src/main
my-app/src/main/java
my-app/src/main/java/com
my-app/src/main/java/com/mycompany
my-app/src/main/java/com/mycompany/app
my-app/src/main/java/com/mycompany/app/GetterSetterExample.java
my-app/src/main/java/com/mycompany/app/App.java
#pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>my-app</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.7</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
$ cat my-app/BUILD
## ----------------------------------------------------------------------------
## BUILD
## ----------------------------------------------------------------------------
# The following dependencies were calculated from:
# /home/tdgreenw/temp/maven-quickstart-ws/my-app/pom.xml
java_library(
name = "default",
srcs = glob(["src/**/*"]),
deps = [
"@junit/junit//jar",
"@org/projectlombok/lombok//jar",
],
visibility = ["//visibility:public"],
)
$ cat my-app/DEPS
## ----------------------------------------------------------------------------
## DEPS
## ----------------------------------------------------------------------------
# The following dependencies were calculated from:
# /home/tdgreenw/temp/maven-quickstart-ws/my-app/pom.xml
maven_jar(
artifact = "junit:junit:3.8.1",
name = "junit/junit",
server = None,
)
maven_jar(
artifact = "org.projectlombok:lombok:1.16.7",
name = "org/projectlombok/lombok",
server = None,
)
$ cat my-app/src/test/java/com/mycompany/app/AppTest.java
package com.mycompany.app;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}
/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}
/**
* Rigourous Test :-)
*/
public void testApp()
{
App app = new App();
assertNotNull(app);
}
public void testApp1()
{
GetterSetterExample gse = new GetterSetterExample();
assertNotNull(gse);
int age = 99;
String name = "Todd";
gse.setAge(age);
gse.setName(name);
assertEquals(age, gse.getAge());
}
}
$ cat my-app/src/main/java/com/mycompany/app/GetterSetterExample.java
package com.mycompany.app;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
public class GetterSetterExample {
/**
* Age of the person. Water is wet.
*
* @param age New value for this person's age. Sky is blue.
* @return The current value of this person's age. Circles are round.
*/
@Getter @Setter private int age = 10;
/**
* Name of the person.
* -- SETTER --
* Changes the name of this person.
*
* @param name The new value.
*/
@Setter(AccessLevel.PROTECTED) private String name;
@Override public String toString() {
return String.format("%s (age: %d)", name, age);
}
}
$ cat my-app/src/main/java/com/mycompany/app/App.java
package com.mycompany.app;
/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
GetterSetterExample gse = new GetterSetterExample();
gse.setAge(99);
gse.setName("Todd");
System.out.println( String.format("GSE: %s", gse) );
}
}
$ cat WORKSPACE
## ----------------------------------------------------------------------------
## Maven Jars
## ----------------------------------------------------------------------------
maven_jar(artifact='junit:junit:3.8.1', name='junit/junit', server=None)
maven_jar(artifact='org.projectlombok:lombok:1.16.7', name='org/projectlombok/lombok', server=None)
$ bazel build //my-app:default --verbose_failures
INFO: Found 1 target...
INFO: From Building my-app/libdefault.jar (3 files):
my-app/src/main/java/com/mycompany/app/App.java:14: error: cannot find symbol
gse.setAge(99);
^
symbol: method setAge(int)
location: variable gse of type GetterSetterExample
my-app/src/main/java/com/mycompany/app/App.java:15: error: cannot find symbol
gse.setName("Todd");
^
symbol: method setName(String)
location: variable gse of type GetterSetterExample
my-app/src/test/java/com/mycompany/app/AppTest.java:47: error: cannot find symbol
gse.setAge(age);
^
symbol: method setAge(int)
location: variable gse of type GetterSetterExample
my-app/src/test/java/com/mycompany/app/AppTest.java:48: error: cannot find symbol
gse.setName(name);
^
symbol: method setName(String)
location: variable gse of type GetterSetterExample
my-app/src/test/java/com/mycompany/app/AppTest.java:50: error: cannot find symbol
assertEquals(age, gse.getAge());
^
symbol: method getAge()
location: variable gse of type GetterSetterExample
5 errors
BazelJavaBuilder threw exception: java compilation returned status ERROR
ERROR: /home/tdgreenw/temp/maven-quickstart-ws/my-app/BUILD:8:1: Java compilation in rule '//my-app:default' failed: java failed: error executing command
(cd /home/tdgreenw/.cache/bazel/_bazel_tdgreenw/57073b756147bd0f753c5ed2228c23dd/maven-quickstart-ws && \
exec env - \
external/local-jdk/bin/java -Xbootclasspath/p:external/bazel_tools/third_party/java/jdk/langtools/javac.jar -client -jar external/bazel_tools/tools/jdk/JavaBuilder_deploy.jar @bazel-out/local_linux-fastbuild/bin/my-app/libdefault.jar-2.params): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1: java failed: error executing command
(cd /home/tdgreenw/.cache/bazel/_bazel_tdgreenw/57073b756147bd0f753c5ed2228c23dd/maven-quickstart-ws && \
exec env - \
external/local-jdk/bin/java -Xbootclasspath/p:external/bazel_tools/third_party/java/jdk/langtools/javac.jar -client -jar external/bazel_tools/tools/jdk/JavaBuilder_deploy.jar @bazel-out/local_linux-fastbuild/bin/my-app/libdefault.jar-2.params): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1.
Target //my-app:default failed to build
$ cat /home/tdgreenw/.cache/bazel/_bazel_tdgreenw/57073b756147bd0f753c5ed2228c23dd/maven-quickstart-ws/bazel-out/local_linux-fastbuild/bin/my-app/libdefault.jar-2.params
--classdir
bazel-out/local_linux-fastbuild/bin/my-app/_javac/default/libdefault_classes
--tempdir
bazel-out/local_linux-fastbuild/bin/my-app/_javac/default/libdefault_temp
--output
bazel-out/local_linux-fastbuild/bin/my-app/libdefault.jar
--sourcegendir
bazel-out/local_linux-fastbuild/bin/my-app/_javac/default/libdefault_sourcegenfiles
--output_manifest_proto
bazel-out/local_linux-fastbuild/bin/my-app/libdefault.jar_manifest_proto
--compress_jar
--output_deps_proto
bazel-out/local_linux-fastbuild/bin/my-app/libdefault.jdeps
--classpath
bazel-out/local_linux-fastbuild/genfiles/external/junit/junit/jar/_ijar/jar/external/junit/junit/jar/junit-3.8.1-ijar.jar:bazel-out/local_linux-fastbuild/genfiles/external/org/projectlombok/lombok/jar/_ijar/jar/external/org/projectlombok/lombok/jar/lombok-1.16.7-ijar.jar:bazel-out/local_linux-fastbuild/bin/my-app/_javac/default/libdefault_classes
--extdir
external/local-jdk/jre/lib/ext
--sources
my-app/src/main/java/com/mycompany/app/App.java
my-app/src/main/java/com/mycompany/app/GetterSetterExample.java
my-app/src/test/java/com/mycompany/app/AppTest.java
--javacopts
-source
8
-target
8
-encoding
UTF-8
-bootclasspath
external/local-jdk/jre/lib/rt.jar:external/local-jdk/jre/lib/resources.jar:external/local-jdk/jre/lib/jsse.jar:external/local-jdk/jre/lib/jce.jar:external/local-jdk/jre/lib/charsets.jar
--strict_java_deps
ERROR
--direct_dependency
bazel-out/local_linux-fastbuild/genfiles/external/junit/junit/jar/_ijar/jar/external/junit/junit/jar/junit-3.8.1-ijar.jar
@@junit/junit//jar:jar
--direct_dependency
bazel-out/local_linux-fastbuild/genfiles/external/org/projectlombok/lombok/jar/_ijar/jar/external/org/projectlombok/lombok/jar/lombok-1.16.7-ijar.jar
@@org/projectlombok/lombok//jar:jar
--reduce_classpath
--rule_kind
java_library
--target_label
//my-app:default
$ mvn clean compile package test
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building my-app 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ my-app ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ my-app ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/tdgreenw/temp/maven-quickstart-ws/my-app/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ my-app ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 2 source files to /home/tdgreenw/temp/maven-quickstart-ws/my-app/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ my-app ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/tdgreenw/temp/maven-quickstart-ws/my-app/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ my-app ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ my-app ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/tdgreenw/temp/maven-quickstart-ws/my-app/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ my-app ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 1 source file to /home/tdgreenw/temp/maven-quickstart-ws/my-app/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ my-app ---
[INFO] Surefire report directory: /home/tdgreenw/temp/maven-quickstart-ws/my-app/target/surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.mycompany.app.AppTest
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.006 sec
Results :
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ my-app ---
[INFO] Building jar: /home/tdgreenw/temp/maven-quickstart-ws/my-app/target/my-app-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ my-app ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/tdgreenw/temp/maven-quickstart-ws/my-app/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ my-app ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ my-app ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/tdgreenw/temp/maven-quickstart-ws/my-app/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ my-app ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ my-app ---
[INFO] Skipping execution of surefire because it has already been run for this configuration
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.539 s
[INFO] Finished at: 2016-02-18T14:07:08-08:00
[INFO] Final Memory: 20M/308M
[INFO] ------------------------------------------------------------------------