|
28 | 28 |
|
29 | 29 | <artifactId>log4j-api-kotlin-benchmark</artifactId>
|
30 | 30 |
|
| 31 | + <name>Apache Log4j Kotlin API benchmarks</name> |
| 32 | + |
31 | 33 | <properties>
|
32 | 34 | <bnd.baseline.skip>true</bnd.baseline.skip>
|
33 | 35 | <maven.test.skip>true</maven.test.skip>
|
34 | 36 | <maven.deploy.skip>true</maven.deploy.skip>
|
35 | 37 | <maven.install.skip>true</maven.install.skip>
|
36 | 38 | <spotbugs.skip>true</spotbugs.skip>
|
37 |
| - <jmh.generator>default</jmh.generator> |
38 | 39 | <uberjar.name>benchmarks</uberjar.name>
|
39 | 40 | </properties>
|
40 | 41 |
|
|
77 | 78 | </dependencies>
|
78 | 79 |
|
79 | 80 | <build>
|
| 81 | + |
80 | 82 | <plugins>
|
81 | 83 |
|
82 |
| - <!-- Compile Kotlin sources first --> |
| 84 | + <!-- What follows is an unconventional plugin sequence to make JMH work with Kotlin. |
| 85 | + The follow logic can be summarized as follows: |
| 86 | +
|
| 87 | + 1. Compile JMH-annotated Kotlin sources |
| 88 | + 2. Using compiled (and JMH-annotated!) classes, generate JMH Java sources |
| 89 | + 3. Add JMH Java sources |
| 90 | + 4. Compile JMH Java sources --> |
| 91 | + |
| 92 | + <!-- 1. Compile Kotlin sources --> |
83 | 93 | <plugin>
|
84 | 94 | <groupId>org.jetbrains.kotlin</groupId>
|
85 | 95 | <artifactId>kotlin-maven-plugin</artifactId>
|
86 | 96 | <executions>
|
87 | 97 | <execution>
|
88 |
| - <id>process-sources</id> |
| 98 | + <id>compile</id> |
89 | 99 | <goals>
|
90 | 100 | <goal>compile</goal>
|
91 | 101 | </goals>
|
92 |
| - <phase>generate-sources</phase> |
| 102 | + <phase>process-sources</phase> |
93 | 103 | <configuration>
|
94 | 104 | <sourceDirs>
|
95 | 105 | <sourceDir>${project.basedir}/src/main/kotlin</sourceDir>
|
|
99 | 109 | </executions>
|
100 | 110 | </plugin>
|
101 | 111 |
|
102 |
| - <!-- Invoke JMH generators to produce benchmark code --> |
| 112 | + <!-- 2. Generate JMH sources --> |
103 | 113 | <plugin>
|
104 | 114 | <groupId>org.codehaus.mojo</groupId>
|
105 | 115 | <artifactId>exec-maven-plugin</artifactId>
|
|
112 | 122 | </dependencies>
|
113 | 123 | <executions>
|
114 | 124 | <execution>
|
| 125 | + <id>generate-JMH-sources</id> |
115 | 126 | <goals>
|
116 | 127 | <goal>java</goal>
|
117 | 128 | </goals>
|
118 |
| - <phase>generate-resources</phase> |
| 129 | + <phase>process-resources</phase> |
119 | 130 | <configuration>
|
120 | 131 | <includePluginDependencies>true</includePluginDependencies>
|
121 | 132 | <mainClass>org.openjdk.jmh.generators.bytecode.JmhBytecodeGenerator</mainClass>
|
122 | 133 | <arguments>
|
123 |
| - <argument>${project.basedir}/target/classes/</argument> |
124 |
| - <argument>${project.basedir}/target/generated-sources/jmh/</argument> |
125 |
| - <argument>${project.basedir}/target/classes/</argument> |
126 |
| - <argument>${jmh.generator}</argument> |
| 134 | + <!-- `compiled-bytecode-dir`: --> |
| 135 | + <argument>${project.build.directory}/classes</argument> |
| 136 | + <!-- `output-source-dir`: --> |
| 137 | + <argument>${project.build.directory}/generated-sources/jmh</argument> |
| 138 | + <!-- `output-resource-dir`: --> |
| 139 | + <argument>${project.build.directory}/classes</argument> |
127 | 140 | </arguments>
|
128 | 141 | </configuration>
|
129 | 142 | </execution>
|
130 | 143 | </executions>
|
131 | 144 | </plugin>
|
132 | 145 |
|
133 |
| - <!-- Add JMH generated code to the compile session --> |
| 146 | + <!-- 3. Add generated JMH sources to the compile session --> |
134 | 147 | <plugin>
|
135 | 148 | <groupId>org.codehaus.mojo</groupId>
|
136 | 149 | <artifactId>build-helper-maven-plugin</artifactId>
|
137 | 150 | <executions>
|
138 | 151 | <execution>
|
139 |
| - <id>add-source</id> |
| 152 | + <id>add-JMH-sources</id> |
140 | 153 | <goals>
|
141 | 154 | <goal>add-source</goal>
|
142 | 155 | </goals>
|
143 | 156 | <phase>process-resources</phase>
|
144 | 157 | <configuration>
|
145 | 158 | <sources>
|
146 |
| - <source>${project.basedir}/target/generated-sources/jmh</source> |
| 159 | + <source>${project.build.directory}/generated-sources/jmh</source> |
147 | 160 | </sources>
|
148 | 161 | </configuration>
|
149 | 162 | </execution>
|
150 | 163 | </executions>
|
151 | 164 | </plugin>
|
152 | 165 |
|
153 |
| - <!-- Compile JMH generated code --> |
| 166 | + <!-- 4. Compile sources (incl. JMH-generated ones) --> |
154 | 167 | <plugin>
|
155 | 168 | <groupId>org.apache.maven.plugins</groupId>
|
156 | 169 | <artifactId>maven-compiler-plugin</artifactId>
|
|
0 commit comments