Skip to content

Commit

Permalink
Fix mkarneim#172 - Support Java 17 record type
Browse files Browse the repository at this point in the history
  • Loading branch information
mkarneim committed Jan 17, 2022
1 parent 27b762f commit e86a8ba
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
29 changes: 19 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ For older versions and a *change log* please see the [release history page].
PojoBuilder *binaries* are available for download at [Sonatype OSS Maven Repository] and [Maven Central].

If you don't use any build automation tool that supports maven repos,
you might want to download the [`pojobuilder-4.2.3-jar-with-dependencies.jar`] to get PojoBuilder complete with all dependent libraries included.
you might want to download the [`pojobuilder-4.3.0-jar-with-dependencies.jar`] to get PojoBuilder complete with all dependent libraries included.

How To Use
----------
Expand Down Expand Up @@ -206,6 +206,15 @@ public class FileFactory {
```
Have a look at [`FileBuilder.java`] to see the generated source code.

### Annotating a Record ###

Beginning with PojoBuilder 4.3 you can annotate a Java 17 record type:

```java
@GeneratePojoBuilder
public record MyRecord(int x, int y, String blah) {}
```

### Directives ###
The following elements of [@GeneratePojoBuilder] can be used to configure the output of the code generation process.

Expand Down Expand Up @@ -343,7 +352,7 @@ The `javac` compiler will auto-detect the presence of PojoBuilder if `pojobuilde

For example:

javac -cp pojobuilder-4.2.3-jar-with-dependencies.jar Contact.java
javac -cp pojobuilder-4.3.0-jar-with-dependencies.jar Contact.java

will generate a `ContactBuilder` if `Contact` is annotated with `@GeneratePojoBuilder`.

Expand All @@ -356,7 +365,7 @@ Add the following to your project's `pom.xml` to configure the PojoBuilder annot
<dependency>
<groupId>net.karneim</groupId>
<artifactId>pojobuilder</artifactId>
<version>4.2.3</version>
<version>4.3.0</version>
<!-- 'provided' scope because this is only needed during compilation -->
<scope>provided</scope>
</dependency>
Expand All @@ -378,7 +387,7 @@ repositories {
}
dependencies {
compile 'net.karneim:pojobuilder:4.2.3'
compile 'net.karneim:pojobuilder:4.3.0'
}
```
Please note that this not only adds the PojoBuilder and its dependencies to your compile-time class path but also to your run-time class path.
Expand All @@ -396,8 +405,8 @@ configurations {
}
dependencies {
codeGeneration 'net.karneim:pojobuilder:4.2.3'
compileOnly 'net.karneim:pojobuilder:4.2.3:annotations'
codeGeneration 'net.karneim:pojobuilder:4.3.0'
compileOnly 'net.karneim:pojobuilder:4.3.0:annotations'
}
compileJava.classpath += configurations.codeGeneration
compileTestJava.classpath += configurations.codeGeneration
Expand All @@ -421,7 +430,7 @@ To make pojobuilder work again, replace the used dependency scope with `annotati

```groovy
dependencies {
annotationProcessor 'net.karneim:pojobuilder:4.2.3'
annotationProcessor 'net.karneim:pojobuilder:4.3.0'
}
```

Expand Down Expand Up @@ -459,7 +468,7 @@ Do the following to enable PojoBuilder for your Eclipse project:
* Open your project's properties dialog
* Navigate to "Java Build Path" tree node
* Open the "Libraries" tab
* Add `pojobuilder-4.2.3-annotations.jar` to your project classpath
* Add `pojobuilder-4.3.0-annotations.jar` to your project classpath
* Navigate to "Java Compiler / Annotation Processing" tree node
* Check "Enable project specific settings"
* Check "Enable annotation processing"
Expand All @@ -468,7 +477,7 @@ Do the following to enable PojoBuilder for your Eclipse project:
* Navigate to "Java Compiler / Annotation Processing / Factory Path" tree node
* Check "Enable project specific settings"
* Click "Add JARs..."
* Add `pojobuiler-4.2.3-jar-with-dependencies.jar`
* Add `pojobuiler-4.3.0-jar-with-dependencies.jar`
* Click "OK"

How To Build
Expand All @@ -480,7 +489,7 @@ If you want to compile this project's sources yourself you can use Gradle (see [
[JavaWriter]: https://github.com/square/javawriter
[Sonatype OSS Maven Repository]: https://oss.sonatype.org/content/repositories/releases/net/karneim/pojobuilder
[Maven Central]: http://search.maven.org/#search|ga|1|a%3A%22pojobuilder%22
[`pojobuilder-4.2.3-jar-with-dependencies.jar`]: https://oss.sonatype.org/content/repositories/releases/net/karneim/pojobuilder/4.2.3/pojobuilder-4.2.3-jar-with-dependencies.jar
[`pojobuilder-4.3.0-jar-with-dependencies.jar`]: https://oss.sonatype.org/content/repositories/releases/net/karneim/pojobuilder/4.3.0/pojobuilder-4.3.0-jar-with-dependencies.jar
[javac documentation]: http://docs.oracle.com/javase/6/docs/technotes/tools/solaris/javac.html#processing
[@ConstructorProperties]: http://docs.oracle.com/javase/6/docs/api/java/beans/ConstructorProperties.html

Expand Down
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ task dependenciesJar(type: Jar, dependsOn:['compileJava']) {
archiveClassifier = "jar-with-dependencies"
from files(sourceSets.main.output.classesDirs)
from files(sourceSets.main.output.resourcesDir)
from {configurations.compile.collect {zipTree(it)}}
from {
configurations.runtimeClasspath.findAll { it.name.endsWith('jar') }.collect { zipTree(it) }
}
into('META-INF/license') { from 'license' }
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
distributionUrl=https\://services.gradle.org/distributions/gradle-5.3-rc-2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-bin.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
Expand Down

0 comments on commit e86a8ba

Please sign in to comment.