-
-
Notifications
You must be signed in to change notification settings - Fork 390
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Annotation Processors with Lombok example, reorganize github acti…
…ons test matrix (#3331) `examples/` was becoming slow, split it into 3 jobs, `integrations/` was split into 2 jobs. Generally trimmed the number of jobs to try and speed up CI
- Loading branch information
Showing
89 changed files
with
217 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
example/javamodule/13-annotation-processors-lombok/bar/src/bar/GetterSetterExample.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package bar; | ||
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); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
example/javamodule/13-annotation-processors-lombok/bar/test/src/bar/HelloWorldTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package bar; | ||
import static org.junit.Assert.assertEquals; | ||
import org.junit.Test; | ||
|
||
public class HelloWorldTest { | ||
@Test | ||
public void testSimple() { | ||
GetterSetterExample exampleValue = new GetterSetterExample(); | ||
assertEquals(exampleValue.getAge(), 10); | ||
exampleValue.setAge(20); | ||
assertEquals(exampleValue.getAge(), 20); | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
example/javamodule/13-annotation-processors-lombok/build.sc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import mill._, javalib._ | ||
|
||
|
||
object foo extends JavaModule { | ||
def compileIvyDeps = Agg(ivy"org.projectlombok:lombok:1.18.34") | ||
|
||
object test extends JavaTests with TestModule.Junit4 | ||
} | ||
|
||
// This is an example of how to use Mill to build Java projects using Java annotations and | ||
// annotation processors. In this case, we use the annotations provided by | ||
// https://projectlombok.org[Project Lombok] to automatically generate getters and setters | ||
// from class private fields | ||
|
||
/** Usage | ||
> ./mill foo.test | ||
Test foo.HelloWorldTest.testSimple started | ||
Test foo.HelloWorldTest.testSimple finished... | ||
... | ||
*/ | ||
|
||
// The Java compiler automatically discovers annotation processors based on the | ||
// classes available during compilation, e.g. on `compileIvyDeps` or `ivyDeps`, | ||
// which is what takes place in the example above. | ||
// | ||
// In some cases, you may need | ||
// to pass in the annotation processors manually, e.g. if you need annotation | ||
// processors that are not on the compilation classpath, or you need finer control | ||
// over exactly which annotation processors are active. To do this, you can define | ||
// a module to contain the exact annotation processors you want, and pass | ||
// in `-processorpath` to `javacOptions` explicitly: | ||
|
||
object processors extends JavaModule{ | ||
def ivyDeps = Agg(ivy"org.projectlombok:lombok:1.18.34") | ||
} | ||
|
||
object bar extends JavaModule { | ||
def compileIvyDeps = Agg(ivy"org.projectlombok:lombok:1.18.34") | ||
|
||
def javacOptions = Seq( | ||
"-processorpath", | ||
processors.runClasspath().map(_.path).mkString(":"), | ||
) | ||
|
||
object test extends JavaTests with TestModule.Junit4 | ||
} | ||
|
||
/** Usage | ||
> ./mill bar.test | ||
Test bar.HelloWorldTest.testSimple started | ||
Test bar.HelloWorldTest.testSimple finished... | ||
... | ||
*/ |
27 changes: 27 additions & 0 deletions
27
example/javamodule/13-annotation-processors-lombok/foo/src/foo/GetterSetterExample.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package foo; | ||
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); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
example/javamodule/13-annotation-processors-lombok/foo/test/src/foo/HelloWorldTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package foo; | ||
import static org.junit.Assert.assertEquals; | ||
import org.junit.Test; | ||
|
||
public class HelloWorldTest { | ||
@Test | ||
public void testSimple() { | ||
GetterSetterExample exampleValue = new GetterSetterExample(); | ||
assertEquals(exampleValue.getAge(), 10); | ||
exampleValue.setAge(20); | ||
assertEquals(exampleValue.getAge(), 20); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.