Skip to content

Commit 5f14a5e

Browse files
committed
Merge pull request #15 from davidmoten/maven-plugin
Retrolambda Maven plugin
2 parents 7bc1cba + c32db1a commit 5f14a5e

File tree

14 files changed

+537
-9
lines changed

14 files changed

+537
-9
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
/target/
22
/*/target/
3+
.classpath
4+
.settings
5+
.project

README.md

+23-6
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,33 @@ Optional system properties:
6666
Output directory into where the generated class files are written.
6767
Defaults to same as retrolambda.inputDir
6868
```
69+
### Maven plugin
70+
To run Retrolambda using Maven add the following to your pom.xml:
71+
```xml
72+
<build>
73+
<plugins>
74+
...
75+
<plugin>
76+
<groupId>net.orfjackal.retrolambda</groupId>
77+
<artifactId>retrolambda-maven-plugin</artifactId>
78+
<version>0.1.15-SNAPSHOT</version>
79+
<executions>
80+
<execution>
81+
<goals>
82+
<goal>process-main</goal>
83+
<goal>process-test</goal>
84+
</goals>
85+
</execution>
86+
</executions>
87+
</plugin>
88+
...
89+
```
90+
See [end-to-end-tests/pom.xml](https://github.com/orfjackal/retrolambda/blob/master/end-to-end-tests/pom.xml) for an example.
6991

92+
Plugin documentation is [here](). (TODO decide where to put the site report)
7093

7194
### Tips
7295

73-
For an example of how to run Retrolambda using Maven, see how
74-
maven-dependency-plugin and maven-antrun-plugin are used in
75-
[end-to-end-tests/pom.xml](https://github.com/orfjackal/retrolambda/blob/master/end-to-end-tests/pom.xml)
76-
There isn't yet a Maven plugin for doing that with less boilerplate, but maybe
77-
later.
78-
7996
During development, inside an IDE, it's the easiest to use Java 8, without
8097
Retrolamba, to compile and run tests. But in your continuous integration build
8198
you should run tests using the target Java version. For example, you can

end-to-end-tests/pom.xml

+18-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,24 @@
4747
</plugin>
4848

4949
<!-- Process our byte codes to make them run on Java 7 -->
50+
<plugin>
51+
<groupId>net.orfjackal.retrolambda</groupId>
52+
<artifactId>retrolambda-maven-plugin</artifactId>
53+
<version>${project.parent.version}</version>
54+
<executions>
55+
<execution>
56+
<goals>
57+
<goal>process-main</goal>
58+
<goal>process-test</goal>
59+
</goals>
60+
</execution>
61+
</executions>
62+
</plugin>
5063

64+
<!-- alternatively, can use a call to the dependency plugin and antrun plugins for fine control of retrolambda parameters -->
65+
<!-- although optimally all such use should be through the maven plugin above. Request changes if you need them! -->
66+
<!-- if people are happy we could delete this block now -->
67+
<!--
5168
<plugin>
5269
<artifactId>maven-dependency-plugin</artifactId>
5370
<executions>
@@ -118,7 +135,7 @@
118135
</execution>
119136
</executions>
120137
</plugin>
121-
138+
-->
122139
</plugins>
123140
</build>
124141

parent/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -283,12 +283,12 @@
283283

284284
<plugin>
285285
<artifactId>maven-plugin-plugin</artifactId>
286-
<version>3.1</version>
286+
<version>3.2</version>
287287
</plugin>
288288

289289
<plugin>
290290
<artifactId>maven-site-plugin</artifactId>
291-
<version>3.1</version>
291+
<version>3.3</version>
292292
</plugin>
293293

294294
<plugin>

pom.xml

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<modules>
1919
<module>parent</module>
2020
<module>retrolambda</module>
21+
<module>retrolambda-maven-plugin</module>
2122
<module>end-to-end-tests</module>
2223
</modules>
2324

retrolambda-maven-plugin/pom.xml

+153
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<parent>
5+
<groupId>net.orfjackal.retrolambda</groupId>
6+
<artifactId>parent</artifactId>
7+
<version>1.1.5-SNAPSHOT</version>
8+
<relativePath>../parent/pom.xml</relativePath>
9+
</parent>
10+
<artifactId>retrolambda-maven-plugin</artifactId>
11+
<packaging>maven-plugin</packaging>
12+
13+
<name>${project.artifactId}</name>
14+
15+
<url>https://github.com/orfjackal/retrolambda</url>
16+
17+
<properties>
18+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
19+
</properties>
20+
21+
<prerequisites>
22+
<maven>${minimumMavenVersion}</maven>
23+
</prerequisites>
24+
25+
<dependencies>
26+
<dependency>
27+
<groupId>org.apache.maven</groupId>
28+
<artifactId>maven-plugin-api</artifactId>
29+
<version>2.0</version>
30+
</dependency>
31+
<dependency>
32+
<groupId>org.apache.maven.plugin-tools</groupId>
33+
<artifactId>maven-plugin-annotations</artifactId>
34+
<version>3.2</version>
35+
<scope>provided</scope>
36+
</dependency>
37+
<dependency>
38+
<groupId>org.codehaus.plexus</groupId>
39+
<artifactId>plexus-utils</artifactId>
40+
<version>3.0.8</version>
41+
</dependency>
42+
<dependency>
43+
<groupId>org.twdata.maven</groupId>
44+
<artifactId>mojo-executor</artifactId>
45+
<version>2.2.0</version>
46+
</dependency>
47+
48+
</dependencies>
49+
50+
<build>
51+
<resources>
52+
<resource>
53+
<directory>src/main/resources</directory>
54+
<filtering>true</filtering>
55+
</resource>
56+
</resources>
57+
<plugins>
58+
<plugin>
59+
<groupId>org.apache.maven.plugins</groupId>
60+
<artifactId>maven-compiler-plugin</artifactId>
61+
<configuration>
62+
<verbose>true</verbose>
63+
<fork>true</fork>
64+
<source>1.6</source>
65+
<target>1.6</target>
66+
</configuration>
67+
</plugin>
68+
<plugin>
69+
<groupId>org.apache.maven.plugins</groupId>
70+
<artifactId>maven-plugin-plugin</artifactId>
71+
<configuration>
72+
<goalPrefix>retrolambda</goalPrefix>
73+
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
74+
</configuration>
75+
<executions>
76+
<execution>
77+
<id>mojo-descriptor</id>
78+
<goals>
79+
<goal>descriptor</goal>
80+
</goals>
81+
<phase>process-classes</phase>
82+
</execution>
83+
<execution>
84+
<id>help-goal</id>
85+
<goals>
86+
<goal>helpmojo</goal>
87+
</goals>
88+
<phase>process-classes</phase>
89+
</execution>
90+
</executions>
91+
</plugin>
92+
<plugin>
93+
<groupId>org.apache.maven.plugins</groupId>
94+
<artifactId>maven-site-plugin</artifactId>
95+
<executions>
96+
<execution>
97+
<id>attach-descriptor</id>
98+
<goals>
99+
<goal>attach-descriptor</goal>
100+
</goals>
101+
</execution>
102+
</executions>
103+
<configuration>
104+
<reportPlugins>
105+
<plugin>
106+
<groupId>org.apache.maven.plugins</groupId>
107+
<artifactId>maven-plugin-plugin</artifactId>
108+
<version>3.2</version>
109+
</plugin>
110+
</reportPlugins>
111+
</configuration>
112+
</plugin>
113+
</plugins>
114+
</build>
115+
<profiles>
116+
<profile>
117+
<id>run-its</id>
118+
<build>
119+
<plugins>
120+
<plugin>
121+
<groupId>org.apache.maven.plugins</groupId>
122+
<artifactId>maven-invoker-plugin</artifactId>
123+
<version>1.7</version>
124+
<configuration>
125+
<debug>true</debug>
126+
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
127+
<pomIncludes>
128+
<pomInclude>*/pom.xml</pomInclude>
129+
</pomIncludes>
130+
<postBuildHookScript>verify</postBuildHookScript>
131+
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
132+
<settingsFile>src/it/settings.xml</settingsFile>
133+
<goals>
134+
<goal>clean</goal>
135+
<goal>test-compile</goal>
136+
</goals>
137+
</configuration>
138+
<executions>
139+
<execution>
140+
<id>integration-test</id>
141+
<goals>
142+
<goal>install</goal>
143+
<goal>integration-test</goal>
144+
<goal>verify</goal>
145+
</goals>
146+
</execution>
147+
</executions>
148+
</plugin>
149+
</plugins>
150+
</build>
151+
</profile>
152+
</profiles>
153+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!--
4+
Licensed to the Apache Software Foundation (ASF) under one
5+
or more contributor license agreements. See the NOTICE file
6+
distributed with this work for additional information
7+
regarding copyright ownership. The ASF licenses this file
8+
to you under the Apache License, Version 2.0 (the
9+
"License"); you may not use this file except in compliance
10+
with the License. You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing,
15+
software distributed under the License is distributed on an
16+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
KIND, either express or implied. See the License for the
18+
specific language governing permissions and limitations
19+
under the License.
20+
-->
21+
22+
<settings>
23+
<profiles>
24+
<profile>
25+
<id>it-repo</id>
26+
<activation>
27+
<activeByDefault>true</activeByDefault>
28+
</activation>
29+
<repositories>
30+
<repository>
31+
<id>local.central</id>
32+
<url>@localRepositoryUrl@</url>
33+
<releases>
34+
<enabled>true</enabled>
35+
</releases>
36+
<snapshots>
37+
<enabled>true</enabled>
38+
</snapshots>
39+
</repository>
40+
</repositories>
41+
<pluginRepositories>
42+
<pluginRepository>
43+
<id>local.central</id>
44+
<url>@localRepositoryUrl@</url>
45+
<releases>
46+
<enabled>true</enabled>
47+
</releases>
48+
<snapshots>
49+
<enabled>true</enabled>
50+
</snapshots>
51+
</pluginRepository>
52+
</pluginRepositories>
53+
</profile>
54+
</profiles>
55+
</settings>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<groupId>net.orfjackal.retrolambda.it</groupId>
7+
<artifactId>simple-it</artifactId>
8+
<version>1.0-SNAPSHOT</version>
9+
10+
<description>A simple IT verifying the basic use case.</description>
11+
12+
<properties>
13+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
14+
</properties>
15+
16+
<build>
17+
<plugins>
18+
<plugin>
19+
<groupId>@project.groupId@</groupId>
20+
<artifactId>@project.artifactId@</artifactId>
21+
<version>@project.version@</version>
22+
<executions>
23+
<execution>
24+
<id>touch</id>
25+
<phase>validate</phase>
26+
<goals>
27+
<goal>touch</goal>
28+
</goals>
29+
</execution>
30+
</executions>
31+
</plugin>
32+
</plugins>
33+
</build>
34+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
File touchFile = new File( basedir, "target/touch.txt" );
2+
3+
assert touchFile.isFile()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package net.orfjackal.retrolambda.maven;
2+
3+
enum ClassesType {
4+
MAIN, TEST;
5+
}

0 commit comments

Comments
 (0)