# About

This project is used to reproduce an issue with `package-info.java` files and annotation processors.

The project is self-contained and uses only `javac` to reproduce the issue.

## The Issue
When the `package-info.java` file is included in build, the files `ColorEnum_MapperFull*` 
are created (which should **not** be created).

## Workaround
The problem is related to the `package-info.java` file in the `com.example` package.  
Ways to avoid the problem:
* delete `package-info.java`
* comment out it's contents
* don't include `package-info.java` in the build: see [Building](#Building) below

Then `com.example.ColorEnum_MapperFull.java` will not be generated twice.

### Details
* The project uses a library `libs/color-1.0-SNAPSHOT.jar`  
  * It contains only one java file
 [ColorEnum](https://gitlab.com/pck-info-issue/color-lib/blob/master/src/main/java/com/example/ColorEnum.java) 
  which uses the annotation processor [EnumMapper](https://github.com/tmtron/enum-mapper):
  * thus the generated `libs/color-1.0-SNAPSHOT.jar` file contains only some class files: 
  `ColorEnum*.class`, and the files generated by the annotation processor: `ColorEnum_MapperFull*.class`
  * Note: the full source-code of the color-library is available: https://gitlab.com/pck-info-issue/color-lib 
* Note: the other `jar` files in the `/libs` dir are only required to run the annotation processor
* The only java file of the project 
[BoolEnum](https://gitlab.com/pck-info-issue/java-only/blob/master/src/com/example/BoolEnum.java)
 uses the same annotation processor [EnumMapper](https://github.com/tmtron/enum-mapper) 
 and package `com.example` as the `color-lib`
* The project also has a 
[package-info](https://gitlab.com/pck-info-issue/java-only/blob/master/src/com/example/package-info.java)
 in the package `com.example` and it only includes the package declaration (no fancy stuff) 
* The source-code of the [EnumMapper](https://github.com/tmtron/enum-mapper) is available on 
[GitHub](https://github.com/tmtron/enum-mapper)
* The problem can also be reproduced with other annotation processors: 
  * e.g. https://immutables.github.io/
  * Android-Example project https://github.com/tmtron/ImmutablesPackageInfoIssue

## Building
The root of the project contains 2 minimal Windows batch files to start [javac](http://docs.oracle.com/javase/7/docs/technotes/tools/windows/javac.html):
* [build.bat](build.bat) builds the project, **including** the `com.example.package-info.java` to see the issue
* [build_NoPckInfo.bat](build_NoPckInfo.bat) builds the project, **without** `com.example.package-info.java` 

Notes: 
* both build scripts use [jopt.txt](jopt.txt) which includes the common build options:
  e.g. the `-classpath` and the `-processorpath` (but not the source files)
* the files will be generated in the `out` directory (which must exist)
* the contents of the `out` directory will be deleted by the `*.bat` files before the build 

### Build without package-info.java
When you start [build_NoPckInfo.bat](build_NoPckInfo.bat) `out\com\example` will contain following files:
* `BoolEnum_MapperFull*`
* `BoolEnum.*`
Those are expected.

### Build with package-info.java
When you start [build.bat](build.bat) `out\com\example` will contain following files:
* `BoolEnum_MapperFull*`
* `BoolEnum.*`
* `ColorEnum_MapperFull*`: **this is unexpected**

## Version-Info

* Operating System: Windows 10 64-bit
* IDE: IntelliJ IDEA 2017.2
* Java version:
```
>java -version
java version "1.8.0_141"
Java(TM) SE Runtime Environment (build 1.8.0_141-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.141-b15, mixed mode)
```

## References
* [Stackoverflow: "Why does the package-info.java file affect annotation-processing?"](https://stackoverflow.com/questions/45412736/why-does-the-package-info-java-file-affect-annotation-processing)
* [Stackoverflow: "Immutables-library generates the same immutable class twice"](https://stackoverflow.com/questions/45393034/immutables-library-generates-the-same-immutable-class-twice)
* Reported Bug to Oracle: internal review ID: #9050394 