|
| 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 | +} |
0 commit comments