Skip to content

Commit 053f217

Browse files
authored
Merge pull request #8 from gunnarmorling/7
#7 Adding a Maven plug-in
2 parents a6bc8b5 + 1642023 commit 053f217

40 files changed

+400
-117
lines changed

patch-gen-maven-plugin/pom.xml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
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+
>
5+
<modelVersion>4.0.0</modelVersion>
6+
<parent>
7+
<artifactId>patch-gen-parent</artifactId>
8+
<groupId>org.jboss.as</groupId>
9+
<version>2.0.1.Alpha1-SNAPSHOT</version>
10+
</parent>
11+
12+
<artifactId>patch-gen-maven-plugin</artifactId>
13+
<packaging>maven-plugin</packaging>
14+
15+
<name>JBoss patch-gen Maven Plugin</name>
16+
17+
<dependencies>
18+
<dependency>
19+
<groupId>${project.groupId}</groupId>
20+
<artifactId>patch-gen</artifactId>
21+
<version>${project.version}</version>
22+
</dependency>
23+
24+
<dependency>
25+
<groupId>org.apache.maven</groupId>
26+
<artifactId>maven-plugin-api</artifactId>
27+
<version>2.0</version>
28+
</dependency>
29+
<dependency>
30+
<groupId>org.apache.maven.plugin-tools</groupId>
31+
<artifactId>maven-plugin-annotations</artifactId>
32+
<version>3.2</version>
33+
<scope>provided</scope>
34+
</dependency>
35+
</dependencies>
36+
37+
<build>
38+
<plugins>
39+
<plugin>
40+
<groupId>org.apache.maven.plugins</groupId>
41+
<artifactId>maven-plugin-plugin</artifactId>
42+
<configuration>
43+
<goalPrefix>patch-gen-maven-plugin</goalPrefix>
44+
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
45+
</configuration>
46+
<executions>
47+
<execution>
48+
<id>mojo-descriptor</id>
49+
<goals>
50+
<goal>descriptor</goal>
51+
</goals>
52+
</execution>
53+
<execution>
54+
<id>help-goal</id>
55+
<goals>
56+
<goal>helpmojo</goal>
57+
</goals>
58+
</execution>
59+
</executions>
60+
</plugin>
61+
</plugins>
62+
</build>
63+
<profiles>
64+
<profile>
65+
<id>run-its</id>
66+
<build>
67+
68+
<plugins>
69+
<plugin>
70+
<groupId>org.apache.maven.plugins</groupId>
71+
<artifactId>maven-invoker-plugin</artifactId>
72+
<version>1.7</version>
73+
<configuration>
74+
<debug>true</debug>
75+
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
76+
<pomIncludes>
77+
<pomInclude>*/pom.xml</pomInclude>
78+
</pomIncludes>
79+
<postBuildHookScript>verify</postBuildHookScript>
80+
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
81+
<settingsFile>src/it/settings.xml</settingsFile>
82+
<goals>
83+
<goal>clean</goal>
84+
<goal>test-compile</goal>
85+
</goals>
86+
</configuration>
87+
<executions>
88+
<execution>
89+
<id>integration-test</id>
90+
<goals>
91+
<goal>install</goal>
92+
<goal>integration-test</goal>
93+
<goal>verify</goal>
94+
</goals>
95+
</execution>
96+
</executions>
97+
</plugin>
98+
</plugins>
99+
100+
</build>
101+
</profile>
102+
</profiles>
103+
</project>
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
/*
2+
* JBoss, Home of Professional Open Source.
3+
* Copyright 2016, Red Hat, Inc., and individual contributors
4+
* as indicated by the @author tags. See the copyright.txt file in the
5+
* distribution for a full listing of individual contributors.
6+
*
7+
* This is free software; you can redistribute it and/or modify it
8+
* under the terms of the GNU Lesser General Public License as
9+
* published by the Free Software Foundation; either version 2.1 of
10+
* the License, or (at your option) any later version.
11+
*
12+
* This software is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
* Lesser General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Lesser General Public
18+
* License along with this software; if not, write to the Free
19+
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20+
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21+
*/
22+
package org.jboss.as.patch.generator.maven.plugin;
23+
24+
import java.io.File;
25+
import java.util.ArrayList;
26+
import java.util.List;
27+
28+
import org.apache.maven.plugin.AbstractMojo;
29+
import org.apache.maven.plugin.MojoExecutionException;
30+
import org.apache.maven.plugins.annotations.LifecyclePhase;
31+
import org.apache.maven.plugins.annotations.Mojo;
32+
import org.apache.maven.plugins.annotations.Parameter;
33+
import org.jboss.as.patching.generator.PatchGenerator;
34+
35+
/**
36+
* Maven plug-in for creating patches for WildFly / JBoss EAP, using the patch-gen tool.
37+
* <p>
38+
* All options from {@link PatchGenerator} are supported. The configuration option names are the same as for the CLI
39+
* options, but without hyphens and camel-cased. E.g. use {@code appliesToDist} as counterpart to
40+
* {@code --applies-to-dist}.
41+
* <p>
42+
* Example usage:
43+
* <pre>
44+
* {@code
45+
* <plugin>
46+
* <groupId>org.jboss.as</groupId>
47+
* <artifactId>patch-gen-maven-plugin</artifactId>
48+
* <version>2.0.1.Alpha1-SNAPSHOT</version>
49+
* <executions>
50+
* <execution>
51+
* <id>create-patch-file</id>
52+
* <phase>prepare-package</phase>
53+
* <goals>
54+
* <goal>GenPatch</goal>
55+
* </goals>
56+
* <configuration>
57+
* <appliesToDist>path/to/source/dist</appliesToDist>
58+
* <updatedDist>path/to/updated/dist</updatedDist>
59+
* <patchConfig>path/to/patch.xml</patchConfig>
60+
* <outputFile>path/to/my-patch.zip</outputFile>
61+
* <includeVersion>true</includeVersion>
62+
* </configuration>
63+
* </execution>
64+
* </executions>
65+
* </plugin>
66+
* }
67+
* </pre>
68+
*
69+
* @author Gunnar Morling
70+
*/
71+
@Mojo( name = "GenPatch", defaultPhase = LifecyclePhase.GENERATE_RESOURCES )
72+
public class PatchGenMojo extends AbstractMojo {
73+
74+
@Parameter( property = "patchConfig", required = true )
75+
private File patchConfig;
76+
77+
@Parameter( property = "appliesToDist", required = true )
78+
private File appliesToDist;
79+
80+
@Parameter( property = "updatedDist", required = true )
81+
private File updatedDist;
82+
83+
@Parameter( property = "outputFile", required = true )
84+
private File outputFile;
85+
86+
@Parameter( property = "assemblePatchBundle" )
87+
private Boolean assemblePatchBundle;
88+
89+
@Parameter( property = "createTemplate" )
90+
private Boolean createTemplate;
91+
92+
@Parameter( property = "detailedInspection" )
93+
private Boolean detailedInspection;
94+
95+
@Parameter( property = "includeVersion" )
96+
private Boolean includeVersion;
97+
98+
@Parameter( property = "combineWith" )
99+
private File combineWith;
100+
101+
@Override
102+
public void execute() throws MojoExecutionException {
103+
List<String> args = new ArrayList<>();
104+
args.add( PatchGenerator.APPLIES_TO_DIST + "=" + appliesToDist.getPath() );
105+
args.add( PatchGenerator.OUTPUT_FILE + "=" + outputFile.getPath() );
106+
args.add( PatchGenerator.PATCH_CONFIG + "=" + patchConfig.getPath() );
107+
args.add( PatchGenerator.UPDATED_DIST + "=" + updatedDist.getPath() );
108+
109+
if ( assemblePatchBundle != null ) {
110+
args.add( PatchGenerator.ASSEMBLE_PATCH_BUNDLE );
111+
}
112+
113+
if ( createTemplate != null ) {
114+
args.add( PatchGenerator.CREATE_TEMPLATE );
115+
}
116+
117+
if ( detailedInspection != null ) {
118+
args.add( PatchGenerator.DETAILED_INSPECTION );
119+
}
120+
121+
if ( includeVersion != null ) {
122+
args.add( PatchGenerator.INCLUDE_VERSION );
123+
}
124+
125+
if ( combineWith != null ) {
126+
args.add( PatchGenerator.COMBINE_WITH + "=" + combineWith.getPath() );
127+
}
128+
129+
PatchGenerator.main( args.toArray( new String[0] ) );
130+
}
131+
}

patch-gen/pom.xml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<parent>
8+
<groupId>org.jboss.as</groupId>
9+
<artifactId>patch-gen-parent</artifactId>
10+
<version>2.0.1.Alpha1-SNAPSHOT</version>
11+
<relativePath>../pom.xml</relativePath>
12+
</parent>
13+
14+
<artifactId>patch-gen</artifactId>
15+
16+
<name>JBoss patch-gen tool</name>
17+
<description>The patch-gen Tool</description>
18+
19+
<properties>
20+
</properties>
21+
22+
<build>
23+
<plugins>
24+
<plugin>
25+
<groupId>org.apache.maven.plugins</groupId>
26+
<artifactId>maven-checkstyle-plugin</artifactId>
27+
</plugin>
28+
<plugin>
29+
<groupId>org.apache.maven.plugins</groupId>
30+
<artifactId>maven-shade-plugin</artifactId>
31+
<configuration>
32+
<transformers>
33+
<transformer
34+
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
35+
<mainClass>org.jboss.as.patching.generator.PatchGenerator</mainClass>
36+
</transformer>
37+
</transformers>
38+
</configuration>
39+
<executions>
40+
<execution>
41+
<phase>package</phase>
42+
<goals>
43+
<goal>shade</goal>
44+
</goals>
45+
<configuration>
46+
<shadedArtifactAttached>true</shadedArtifactAttached>
47+
<shadedClassifierName>shaded</shadedClassifierName>
48+
</configuration>
49+
</execution>
50+
</executions>
51+
</plugin>
52+
<plugin>
53+
<groupId>org.apache.maven.plugins</groupId>
54+
<artifactId>maven-assembly-plugin</artifactId>
55+
<configuration>
56+
<descriptors>
57+
<descriptor>src/main/assembly/assembly.xml</descriptor>
58+
</descriptors>
59+
<appendAssemblyId>false</appendAssemblyId>
60+
</configuration>
61+
<executions>
62+
<execution>
63+
<id>make-assembly</id>
64+
<phase>package</phase>
65+
<goals>
66+
<goal>single</goal>
67+
</goals>
68+
</execution>
69+
</executions>
70+
</plugin>
71+
</plugins>
72+
</build>
73+
74+
<dependencies>
75+
<dependency>
76+
<groupId>org.wildfly.core</groupId>
77+
<artifactId>wildfly-patching</artifactId>
78+
<version>${version.org.wildfly-core}</version>
79+
</dependency>
80+
<dependency>
81+
<groupId>junit</groupId>
82+
<artifactId>junit</artifactId>
83+
<version>${version.junit}</version>
84+
<scope>test</scope>
85+
</dependency>
86+
</dependencies>
87+
</project>

0 commit comments

Comments
 (0)