Skip to content

Commit 4c2fefa

Browse files
authored
Merge pull request #12 from aloubyansky/7.x
7.x
2 parents 2d19266 + 821081e commit 4c2fefa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+964
-192
lines changed

README.md

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,20 @@ In the following sections, substitute `patch-gen` for `java -jar patch-gen-*-sha
88

99
alias patch-gen='java -jar patch-gen-*-shaded.jar'
1010

11-
### Patch Generation
12-
patch-gen --applies-to-dist=~/wildfly/wildfly-8.0.0.Final --updated-dist=~/wildfly/wildfly-8.1.0.CR2 --patch-config=patch-config-wildfly-CR2-patch.xml --output-file=wildfly-8.1.0.CR2.patch.zip
11+
## Patch Generation
12+
patch-gen --applies-to-dist=~/wildfly/wildfly-8.0.0.Final --updated-dist=~/wildfly/wildfly-8.0.1.Final --patch-config=wildfly-8.0.1.Final-patch.xml --output-file=wildfly-8.0.1.Final.patch.zip
1313

1414
`--applies-to-dist` and `--updated-dist` must point exactly at the root of the distributions (the directory containing bin, modules, domain, etc.), otherwise the tool will crash.
1515

16+
### Generation of patches containing multiple CPs
17+
18+
patch-gen --applies-to-dist=~/wildfly/wildfly-8.0.1.Final --updated-dist=~/wildfly/wildfly-8.0.2.Final --patch-config=wildfly-8.0.2.Final-patch.xml --output-file=wildfly-8.0.2.Final.patch.zip --combine-with=wildfly-8.0.1.Final.patch.zip
19+
20+
where wildfly-8.0.1.Final.patch.zip is the last produced CP (in this example generated in the section above) for wildfly-8.0.0.Final.
21+
The generated patch wildfly-8.0.2.Final.patch.zip can be applied to wildfly-8.0.1.Final as well as to wildfly-8.0.0.Final.
22+
No matter to which version it is applied, the resulting patched version will be wildfly-8.0.2.Final.
23+
There is no restriction on the number of CPs included into a single patch file.
24+
1625
### Configuration Templating
1726

1827
#### One off
@@ -32,7 +41,7 @@ You probably want to use the shaded jar, which is executable and contains all of
3241
The jars will be located in the `target/` subdirectory.
3342

3443
#### Download from Github
35-
curl -LO 'https://github.com/jbossas/patch-gen/releases/download/1.0/patch-gen-1.0-shaded.jar'
44+
curl -LO 'https://github.com/jbossas/patch-gen/releases/download/2.0.0.Final/patch-gen-2.0.0.Final-shaded.jar'
3645

3746
## Patch Workflow
3847

@@ -44,10 +53,10 @@ $EDITOR patch-config-wildfly-CR2-patch.xml
4453
```xml
4554
<?xml version='1.0' encoding='UTF-8'?>
4655
<patch-config xmlns="urn:jboss:patch-config:1.0">
47-
<name>wildfly-CR2</name>
48-
<description>WildFly 8.1.0.CR2 patch</description>
56+
<name>wildfly-8.0.2.Final.patch</name>
57+
<description>WildFly 8.0.2.Final patch</description>
4958
<cumulative />
50-
<element patch-id="base-wildfly-CR2-patch">
59+
<element patch-id="base-wildfly-8.0.2.Final-patch">
5160
<cumulative name="base" />
5261
<description>No description available</description>
5362
</element>
@@ -60,4 +69,4 @@ $EDITOR patch-config-wildfly-CR2-patch.xml
6069
unzip -qo patch.zip README.txt
6170
$EDITOR README.txt
6271
zip -qu patch.zip README.txt
63-
```
72+
```

patch-gen-maven-plugin/pom.xml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
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.Alpha2-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+
<scope>provided</scope>
29+
</dependency>
30+
<dependency>
31+
<groupId>org.apache.maven.plugin-tools</groupId>
32+
<artifactId>maven-plugin-annotations</artifactId>
33+
<version>3.2</version>
34+
<scope>provided</scope>
35+
</dependency>
36+
</dependencies>
37+
38+
<build>
39+
<plugins>
40+
<plugin>
41+
<groupId>org.apache.maven.plugins</groupId>
42+
<artifactId>maven-plugin-plugin</artifactId>
43+
<configuration>
44+
<goalPrefix>patch-gen-maven-plugin</goalPrefix>
45+
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
46+
</configuration>
47+
<executions>
48+
<execution>
49+
<id>mojo-descriptor</id>
50+
<goals>
51+
<goal>descriptor</goal>
52+
</goals>
53+
</execution>
54+
<execution>
55+
<id>help-goal</id>
56+
<goals>
57+
<goal>helpmojo</goal>
58+
</goals>
59+
</execution>
60+
</executions>
61+
</plugin>
62+
</plugins>
63+
</build>
64+
<profiles>
65+
<profile>
66+
<id>run-its</id>
67+
<build>
68+
69+
<plugins>
70+
<plugin>
71+
<groupId>org.apache.maven.plugins</groupId>
72+
<artifactId>maven-invoker-plugin</artifactId>
73+
<version>1.7</version>
74+
<configuration>
75+
<debug>true</debug>
76+
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
77+
<pomIncludes>
78+
<pomInclude>*/pom.xml</pomInclude>
79+
</pomIncludes>
80+
<postBuildHookScript>verify</postBuildHookScript>
81+
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
82+
<settingsFile>src/it/settings.xml</settingsFile>
83+
<goals>
84+
<goal>clean</goal>
85+
<goal>test-compile</goal>
86+
</goals>
87+
</configuration>
88+
<executions>
89+
<execution>
90+
<id>integration-test</id>
91+
<goals>
92+
<goal>install</goal>
93+
<goal>integration-test</goal>
94+
<goal>verify</goal>
95+
</goals>
96+
</execution>
97+
</executions>
98+
</plugin>
99+
</plugins>
100+
101+
</build>
102+
</profile>
103+
</profiles>
104+
</project>
Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
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.io.IOException;
26+
import java.util.ArrayList;
27+
import java.util.List;
28+
29+
import org.apache.maven.artifact.Artifact;
30+
import org.apache.maven.plugin.AbstractMojo;
31+
import org.apache.maven.plugin.MojoExecutionException;
32+
import org.apache.maven.plugins.annotations.LifecyclePhase;
33+
import org.apache.maven.plugins.annotations.Mojo;
34+
import org.apache.maven.plugins.annotations.Parameter;
35+
import org.jboss.as.patching.generator.PatchGenerator;
36+
37+
/**
38+
* Maven plug-in for creating patches for WildFly / JBoss EAP, using the patch-gen tool.
39+
* <p>
40+
* All options from {@link PatchGenerator} are supported. The configuration option names are the same as for the CLI
41+
* options, but without hyphens and camel-cased. E.g. use {@code appliesToDist} as counterpart to
42+
* {@code --applies-to-dist}.
43+
* <p>
44+
* Example usage:
45+
* <pre>
46+
* {@code
47+
* <plugin>
48+
* <groupId>org.jboss.as</groupId>
49+
* <artifactId>patch-gen-maven-plugin</artifactId>
50+
* <version>2.0.1.Alpha2-SNAPSHOT</version>
51+
* <executions>
52+
* <execution>
53+
* <id>create-patch-file</id>
54+
* <phase>prepare-package</phase>
55+
* <goals>
56+
* <goal>GenPatch</goal>
57+
* </goals>
58+
* <configuration>
59+
* <appliesToDist>path/to/source/dist</appliesToDist>
60+
* <updatedDist>path/to/updated/dist</updatedDist>
61+
* <patchConfig>path/to/patch.xml</patchConfig>
62+
* <outputFile>path/to/my-patch.zip</outputFile>
63+
* <includeVersion>true</includeVersion>
64+
* </configuration>
65+
* </execution>
66+
* </executions>
67+
* </plugin>
68+
* }
69+
* </pre>
70+
*
71+
* @author Gunnar Morling
72+
*/
73+
@Mojo( name = "generate-patch", defaultPhase = LifecyclePhase.GENERATE_RESOURCES )
74+
public class PatchGenMojo extends AbstractMojo {
75+
76+
private static final String LOG_FILE = "patchgen.log";
77+
78+
@Parameter( property = "patchConfig", required = true )
79+
private File patchConfig;
80+
81+
@Parameter( property = "appliesToDist", required = true )
82+
private File appliesToDist;
83+
84+
@Parameter( property = "updatedDist", required = true )
85+
private File updatedDist;
86+
87+
@Parameter( property = "outputFile", required = true )
88+
private File outputFile;
89+
90+
@Parameter( property = "assemblePatchBundle" )
91+
private Boolean assemblePatchBundle;
92+
93+
@Parameter( property = "createTemplate" )
94+
private Boolean createTemplate;
95+
96+
@Parameter( property = "detailedInspection" )
97+
private Boolean detailedInspection;
98+
99+
@Parameter( property = "includeVersion" )
100+
private Boolean includeVersion;
101+
102+
@Parameter( property = "combineWith" )
103+
private File combineWith;
104+
105+
@Parameter( property = "project.build.directory" )
106+
private File buildDirectory;
107+
108+
@Parameter( property = "plugin.artifacts" )
109+
protected List<Artifact> pluginArtifacts;
110+
111+
@Override
112+
public void execute() throws MojoExecutionException {
113+
List<String> args = new ArrayList<>();
114+
115+
args.add( "java" );
116+
args.add( "-cp" );
117+
args.add( getClasspath() );
118+
args.add( PatchGenerator.class.getName() );
119+
120+
args.add( PatchGenerator.APPLIES_TO_DIST + "=" + appliesToDist.getPath() );
121+
args.add( PatchGenerator.OUTPUT_FILE + "=" + outputFile.getPath() );
122+
args.add( PatchGenerator.PATCH_CONFIG + "=" + patchConfig.getPath() );
123+
args.add( PatchGenerator.UPDATED_DIST + "=" + updatedDist.getPath() );
124+
125+
if ( assemblePatchBundle != null ) {
126+
args.add( PatchGenerator.ASSEMBLE_PATCH_BUNDLE );
127+
}
128+
129+
if ( createTemplate != null ) {
130+
args.add( PatchGenerator.CREATE_TEMPLATE );
131+
}
132+
133+
if ( detailedInspection != null ) {
134+
args.add( PatchGenerator.DETAILED_INSPECTION );
135+
}
136+
137+
if ( includeVersion != null ) {
138+
args.add( PatchGenerator.INCLUDE_VERSION );
139+
}
140+
141+
if ( combineWith != null ) {
142+
args.add( PatchGenerator.COMBINE_WITH + "=" + combineWith.getPath() );
143+
}
144+
145+
// Ideally, we'd just invoke PatchGenerator directly; currently we cannot do so due to https://issues.jboss.org/browse/MODULES-136:
146+
// JBoss Modules, when used as a library, will set some system properties to values causing trouble for other plug-ins later in the
147+
// build; e.g. SAXParserFactory is redirected to a JBoss Modules specific variant which then cannot be found by other users such as
148+
// the Checkstyle plug-in (which naturally doesn't have JBoss Modules on the plug-in dependency path). Hence we start patch-gen in
149+
// a separate process
150+
//
151+
// PatchGenerator.main( args.toArray( new String[0] ) );
152+
try {
153+
Process p = new ProcessBuilder( args )
154+
.redirectOutput( new File( buildDirectory, LOG_FILE ) )
155+
.redirectError( new File( buildDirectory, LOG_FILE ) )
156+
.start();
157+
p.waitFor();
158+
}
159+
catch (IOException | InterruptedException e) {
160+
throw new MojoExecutionException( "Execution of PatchGenerator failed. See " + LOG_FILE + " for details.", e );
161+
}
162+
163+
if ( !outputFile.exists() ) {
164+
throw new MojoExecutionException( "Execution of PatchGenerator failed. See " + LOG_FILE + " for details." );
165+
}
166+
}
167+
168+
private String getClasspath() {
169+
StringBuilder sb = new StringBuilder();
170+
boolean first = true;
171+
172+
for ( Artifact artifact : pluginArtifacts ) {
173+
if ( first ) {
174+
first = false;
175+
}
176+
else {
177+
sb.append( File.pathSeparator );
178+
}
179+
sb.append( artifact.getFile().getPath() );
180+
}
181+
182+
return sb.toString();
183+
}
184+
}

0 commit comments

Comments
 (0)