All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.codehaus.mojo.rpm.HelpMojo Maven / Gradle / Ivy

The newest version!
package org.codehaus.mojo.rpm;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;

/**
 * Display help information on rpm-cbuild-maven-plugin.
Call
  mvn rpm-cbuild:help -Ddetail=true -Dgoal=<goal-name>
to display parameter details. * * @version generated on Sat May 30 14:50:39 CDT 2009 * @author org.apache.maven.tools.plugin.generator.PluginHelpGenerator (version 2.5) * @goal help * @requiresProject false */ public class HelpMojo extends AbstractMojo { /** * If true, display all settable properties for each goal. * * @parameter expression="${detail}" default-value="false" */ private boolean detail; /** * The name of the goal for which to show help. If unspecified, all goals will be displayed. * * @parameter expression="${goal}" */ private java.lang.String goal; /** * The maximum length of a display line, should be positive. * * @parameter expression="${lineLength}" default-value="80" */ private int lineLength; /** * The number of spaces per indentation level, should be positive. * * @parameter expression="${indentSize}" default-value="2" */ private int indentSize; /** {@inheritDoc} */ public void execute() throws MojoExecutionException { if ( lineLength <= 0 ) { getLog().warn( "The parameter 'lineLength' should be positive, using '80' as default." ); lineLength = 80; } if ( indentSize <= 0 ) { getLog().warn( "The parameter 'indentSize' should be positive, using '2' as default." ); indentSize = 2; } StringBuffer sb = new StringBuffer(); append( sb, "org.codehaus.mojo:rpm-cbuild-maven-plugin:1.0-beta-1", 0 ); append( sb, "", 0 ); append( sb, "RPM Plugin", 0 ); append( sb, "These plugins are designed to convert tarballs of typical non-java open source project and with patch/autoconf/configure/make/install prepare a directory for packaging with RPM. Stuffing a java project into an RPM is also supported.", 1 ); append( sb, "", 0 ); if ( goal == null || goal.length() <= 0 ) { append( sb, "This plugin has 8 goals:", 0 ); append( sb, "", 0 ); } if ( goal == null || goal.length() <= 0 || "build".equals( goal ) ) { append( sb, "rpm-cbuild:build", 0 ); append( sb, "Harvest a RPM from the project binaries and the generated spec file.", 1 ); append( sb, "", 0 ); if ( detail ) { append( sb, "Available parameters:", 1 ); append( sb, "", 0 ); append( sb, "destDir (Default: ${project.build.directory}/rpm-basedir)", 2 ); append( sb, "The Make DESTDIR, to let the RPM harvester know where the staged installation directory is located for packaging", 3 ); append( sb, "", 0 ); append( sb, "platformPostfix", 2 ); append( sb, "Override for platform postfix on RPM release number", 3 ); append( sb, "", 0 ); append( sb, "prefix", 2 ); append( sb, "The configure prefix, to let the RPM harvester know how to build the dir structure.", 3 ); append( sb, "", 0 ); append( sb, "release", 2 ); append( sb, "The RPM releaes level or build number", 3 ); append( sb, "", 0 ); append( sb, "rpmName", 2 ); append( sb, "Override parameter for the name of this RPM", 3 ); append( sb, "", 0 ); append( sb, "rpmrcIncludes", 2 ); append( sb, "This is a list of locations to include in the generated rpmrc file that contains the ref to the macro definitions that specify the topdir to be used here.", 3 ); append( sb, "", 0 ); append( sb, "rpmVersion", 2 ); append( sb, "The RPM version, typically set in a Dynamic Maven Property in the platform-detect goal during the validate phase.", 3 ); append( sb, "", 0 ); append( sb, "skipBuild (Default: false)", 2 ); append( sb, "(no description available)", 3 ); append( sb, "", 0 ); append( sb, "skipPlatformPostfix (Default: false)", 2 ); append( sb, "Whether to skip postfix on RPM release number rhoover - we can\'t use null on platformPostfix as an indication to skip the postfix until this bug is fixed (http://jira.codehaus.org/browse/MNG-1959) because currently specifying an empty string for a parameter in the POM yields null instead of an empty string.", 3 ); append( sb, "", 0 ); append( sb, "topDir (Default: ${project.build.directory}/rpm-topdir)", 2 ); append( sb, "Top directory of the RPM filesystem structure.", 3 ); append( sb, "", 0 ); } } if ( goal == null || goal.length() <= 0 || "generate-spec".equals( goal ) ) { append( sb, "rpm-cbuild:generate-spec", 0 ); append( sb, "Build a RPM spec file and save it to disk for subsequent harvesting.", 1 ); append( sb, "", 0 ); if ( detail ) { append( sb, "Available parameters:", 1 ); append( sb, "", 0 ); append( sb, "dependsExclusions", 2 ); append( sb, "List of dependencies in the form \'groupId:artifactId\' which should be excluded from the list of dependency functionality.", 3 ); append( sb, "", 0 ); append( sb, "destDir (Default: ${project.build.directory}/rpm-basedir)", 2 ); append( sb, "The Make DESTDIR, to let the RPM harvester know where the software staged installation directory is located for packaging", 3 ); append( sb, "", 0 ); append( sb, "platformPostfix", 2 ); append( sb, "Override for platform postfix on RPM release number.", 3 ); append( sb, "", 0 ); append( sb, "postInstallFile", 2 ); append( sb, "Create a simple RPM post install mechanism If defined, the RPM will insert the named file into the spec file that the pluggin is building (some claim this is weak, but make the script a .sh.in file and let autoconf do some expanding)", 3 ); append( sb, "", 0 ); append( sb, "postUninstallFile", 2 ); append( sb, "Create a simple RPM post un install mechanism If defined, the RPM will insert the named file into the spec file that the pluggin is building (this is weak in the sense that template expansion is not occuring)", 3 ); append( sb, "", 0 ); append( sb, "prefix", 2 ); append( sb, "The configure prefix, to let the RPM harvester know how to build the dir structure.", 3 ); append( sb, "", 0 ); append( sb, "preInstallFile", 2 ); append( sb, "Create a simple RPM pre install mechanism If defined, the RPM will insert the named file into the spec file that the pluggin is building (this is weak in the sense that template expansion is not occuring)", 3 ); append( sb, "", 0 ); append( sb, "preUninstallFile", 2 ); append( sb, "Create a simple RPM pre un install mechanism If defined, the RPM will insert the named file into the spec file that the pluggin is building (this is weak in the sense that template expansion is not occuring)", 3 ); append( sb, "", 0 ); append( sb, "providesExclusions", 2 ); append( sb, "List of dependencies in the form \'groupId:artifactId\' which should be excluded from the list of provided functionality.", 3 ); append( sb, "", 0 ); append( sb, "release", 2 ); append( sb, "The build number of the RPM, so you get versions like 1.2-4 which would be the fourth build of the 1.2 tarball. This is typically set during the platform-detect goal in the validate phase.", 3 ); append( sb, "", 0 ); append( sb, "rpmName", 2 ); append( sb, "Override parameter for the name of the RPM to be created.", 3 ); append( sb, "", 0 ); append( sb, "rpmNoStrip (Default: false)", 2 ); append( sb, "Turn off RPM compression and symbol stripping - this is very much manditory for binary sources like Sybase, Oracle, and the SunJDK. Usually you want this copression, so the default is false.", 3 ); append( sb, "", 0 ); append( sb, "rpmVersion", 2 ); append( sb, "The RPM version, typically set in a Dynamic Maven Property in the platform-detect goal during the validate phase.", 3 ); append( sb, "", 0 ); append( sb, "skip (Default: false)", 2 ); append( sb, "Whether to skip RPM spec file generation.", 3 ); append( sb, "", 0 ); append( sb, "skipPlatformPostfix (Default: false)", 2 ); append( sb, "Whether to skip postfix on RPM release number. When this is set, the RPM BuildArch: will be set to noarch and the RPM Release: will only have the release number established by the platform-detect goal. When set to true, no BuildArch: will be set in the RPM and the release will have a release number and a platform postfix in it so you can tell what operating system distro was used when the RPM was created.", 3 ); append( sb, "", 0 ); append( sb, "topDir (Default: ${project.build.directory}/rpm-topdir)", 2 ); append( sb, "The top directory of the RPM harvesting structure.", 3 ); append( sb, "", 0 ); } } if ( goal == null || goal.length() <= 0 || "help".equals( goal ) ) { append( sb, "rpm-cbuild:help", 0 ); append( sb, "Display help information on rpm-cbuild-maven-plugin.\nCall\n\u00a0\u00a0mvn\u00a0rpm-cbuild:help\u00a0-Ddetail=true\u00a0-Dgoal=\nto display parameter details.", 1 ); append( sb, "", 0 ); if ( detail ) { append( sb, "Available parameters:", 1 ); append( sb, "", 0 ); append( sb, "detail (Default: false)", 2 ); append( sb, "If true, display all settable properties for each goal.", 3 ); append( sb, "", 0 ); append( sb, "goal", 2 ); append( sb, "The name of the goal for which to show help. If unspecified, all goals will be displayed.", 3 ); append( sb, "", 0 ); append( sb, "indentSize (Default: 2)", 2 ); append( sb, "The number of spaces per indentation level, should be positive.", 3 ); append( sb, "", 0 ); append( sb, "lineLength (Default: 80)", 2 ); append( sb, "The maximum length of a display line, should be positive.", 3 ); append( sb, "", 0 ); } } if ( goal == null || goal.length() <= 0 || "install".equals( goal ) ) { append( sb, "rpm-cbuild:install", 0 ); append( sb, "Used to install the RPM onto the OS. This is critical for multimodule builds, since dependent compiles need RPMs installed.", 1 ); append( sb, "", 0 ); if ( detail ) { append( sb, "Available parameters:", 1 ); append( sb, "", 0 ); append( sb, "forceAllInstalls (Default: false)", 2 ); append( sb, "(no description available)", 3 ); append( sb, "", 0 ); append( sb, "forceInstall (Default: false)", 2 ); append( sb, "This will attempt to override an error which will usually abort an RPM install", 3 ); append( sb, "", 0 ); append( sb, "noParentDirs (Default: false)", 2 ); append( sb, "RPM 4.4.6 introduced a feature that the parent directories of a package must be provided by another package as a dependency. This usually isn\'t what you want so set this to false if you are getting installation failures on a directory dependency. You can check your system for orphanced dependencies with rpm -Va --orphandirs.", 3 ); append( sb, "", 0 ); append( sb, "release", 2 ); append( sb, "The build number of the RPM, so you get versions like 1.2-4 which would be the fourth build of the 1.2 tarball.", 3 ); append( sb, "", 0 ); append( sb, "rpmDbPath", 2 ); append( sb, "Use this if your RPM database is not installed in the typical location, usually /var/lib/rpm", 3 ); append( sb, "", 0 ); append( sb, "rpmVersion", 2 ); append( sb, "The RPM version, typically set in a Dynamic Maven Property in the platform-detect goal during the validate phase.", 3 ); append( sb, "", 0 ); append( sb, "skipInstall (Default: false)", 2 ); append( sb, "Use this flag to skip the install phase of an RPM. Useful if you want to create an RPM but not install it on your build machine.", 3 ); append( sb, "", 0 ); append( sb, "useSudo (Default: true)", 2 ); append( sb, "Flag to determine when to use sudo to execute the rpm command.", 3 ); append( sb, "", 0 ); } } if ( goal == null || goal.length() <= 0 || "install-dependencies".equals( goal ) ) { append( sb, "rpm-cbuild:install-dependencies", 0 ); append( sb, "Used to install the RPM onto the OS. This is critical for multimodule builds, since dependent compiles need RPMs installed.", 1 ); append( sb, "", 0 ); if ( detail ) { append( sb, "Available parameters:", 1 ); append( sb, "", 0 ); append( sb, "forceAllInstalls (Default: false)", 2 ); append( sb, "(no description available)", 3 ); append( sb, "", 0 ); append( sb, "forceDependencyInstalls (Default: false)", 2 ); append( sb, "(no description available)", 3 ); append( sb, "", 0 ); append( sb, "noParentDirs (Default: false)", 2 ); append( sb, "RPM 4.4.6 introduced a feature that the parent directories of a package must be provided by another package as a dependency. This usually isn\'t what you want so set this to false if you are getting installation failures on a directory dependency. You can check your system for orphanced dependencies with rpm -Va --orphandirs.", 3 ); append( sb, "", 0 ); append( sb, "rpmDbPath", 2 ); append( sb, "Use this if your RPM database is not installed in the typical location, usually /var/lib/rpm", 3 ); append( sb, "", 0 ); append( sb, "skipDependencies (Default: false)", 2 ); append( sb, "(no description available)", 3 ); append( sb, "", 0 ); append( sb, "useSudo (Default: true)", 2 ); append( sb, "Flag to determine when to use sudo to execute the rpm command.", 3 ); append( sb, "", 0 ); } } if ( goal == null || goal.length() <= 0 || "platform-detect".equals( goal ) ) { append( sb, "rpm-cbuild:platform-detect", 0 ); append( sb, "This goal will do basic validation of the project for use with the rpm-cbuild-maven-plugin and set Maven dynamic properties which will be needed in later rpm-cbuild goals", 1 ); append( sb, "", 0 ); if ( detail ) { append( sb, "Available parameters:", 1 ); append( sb, "", 0 ); append( sb, "archProperty (Default: DYNAMIC.CBUILDPROP.ARCH)", 2 ); append( sb, "platform-detect will set a Maven property during runtime which the project\'s POM may utilize after this plugin runs. The system architecture (i386, x86_64, etc) will be the value and the value of archProperty will be the name of the dynamic Maven property.", 3 ); append( sb, "", 0 ); append( sb, "osProperty (Default: DYNAMIC.CBUILDPROP.OS)", 2 ); append( sb, "platform-detect will set a Maven property during runtime which the project\'s POM may utilize after this plugin runs. The system os name (rhel3, fc10, osx5, etc) will be the value and the value of osProperty will be the name of the dynamic Maven property.", 3 ); append( sb, "", 0 ); append( sb, "rpmReleaseProperty (Default: DYNAMIC.CBUILDPROP.RPM.RELEASE)", 2 ); append( sb, "platform-detect will set a Maven property during runtime which the project\'s POM may utilize after this plugin runs. The declared maven project\'s version will be parsed to derive an RPM release number. This will be concatenated in the rpm-cbuild-maven-plugin with the platform distro (rhel3, osx5, centos5, etc) to get you a full rpm release named something like 4.rhel3. The release will be the string to the right of the last dash and must be SNAPSHOT or a numeric value, otherwise an error will be generated.", 3 ); append( sb, "", 0 ); append( sb, "rpmVersionProperty (Default: DYNAMIC.CBUILDPROP.RPM.VERSION)", 2 ); append( sb, "platform-detect will set a Maven property during runtime which the project\'s POM may utilize after this plugin runs. The declared maven project\'s version will be parsed to derive an RPM version. Many legal maven version will generate an error as they introduce compatibility problems with RPM version numbers. Legal maven versions are similar to 1.2.3-SNAPSHOT and 1.2.3-4. The version will be the string to the left of the last dash. Maven keywords like ALPHA, BETA, RC, and the like will generate an error. Don\'t use maven milestone versioning either such as 2.1.0-M1-1 as this will not do what you expect when put into RPM packaging. If you run into one of these Maven projects that you want to put in an RPM, best to version it as either 2.1.0-SNAPSHOT or 2.0.999-1.", 3 ); append( sb, "", 0 ); append( sb, "skip (Default: false)", 2 ); append( sb, "Whether to skip RPM platform-detect file generation.", 3 ); append( sb, "", 0 ); append( sb, "skipPlatformPostfix (Default: false)", 2 ); append( sb, "Whether to skip postfix on RPM release number. When this is set, the RPM BuildArch: will be set to noarch and the RPM Release: will only have the release number established by this platform-detect goal. When set to true, no BuildArch: will be set in the RPM and the release will have a release number and a platform postfix in it so you can tell what operating system distro was used when the RPM was created.", 3 ); append( sb, "", 0 ); } } if ( goal == null || goal.length() <= 0 || "remove".equals( goal ) ) { append( sb, "rpm-cbuild:remove", 0 ); append( sb, "Used to install the RPM onto the OS. This is critical for multimodule builds, since dependent compiles need RPMs installed.", 1 ); append( sb, "", 0 ); if ( detail ) { append( sb, "Available parameters:", 1 ); append( sb, "", 0 ); append( sb, "rpmDbPath", 2 ); append( sb, "(no description available)", 3 ); append( sb, "", 0 ); append( sb, "skipRemove (Default: false)", 2 ); append( sb, "(no description available)", 3 ); append( sb, "", 0 ); append( sb, "useSudo (Default: true)", 2 ); append( sb, "Flag to determine when to use sudo to execute the rpm command.", 3 ); append( sb, "", 0 ); } } if ( goal == null || goal.length() <= 0 || "remove-project-references".equals( goal ) ) { append( sb, "rpm-cbuild:remove-project-references", 0 ); append( sb, "(no description available)", 1 ); append( sb, "", 0 ); if ( detail ) { append( sb, "Available parameters:", 1 ); append( sb, "", 0 ); } } if ( getLog().isInfoEnabled() ) { getLog().info( sb.toString() ); } } /** *

Repeat a String n times to form a new string.

* * @param str String to repeat * @param repeat number of times to repeat str * @return String with repeated String * @throws NegativeArraySizeException if repeat < 0 * @throws NullPointerException if str is null */ private static String repeat( String str, int repeat ) { StringBuffer buffer = new StringBuffer( repeat * str.length() ); for ( int i = 0; i < repeat; i++ ) { buffer.append( str ); } return buffer.toString(); } /** * Append a description to the buffer by respecting the indentSize and lineLength parameters. * Note: The last character is always a new line. * * @param sb The buffer to append the description, not null. * @param description The description, not null. * @param indent The base indentation level of each line, must not be negative. */ private void append( StringBuffer sb, String description, int indent ) { for ( Iterator it = toLines( description, indent, indentSize, lineLength ).iterator(); it.hasNext(); ) { sb.append( it.next().toString() ).append( '\n' ); } } /** * Splits the specified text into lines of convenient display length. * * @param text The text to split into lines, must not be null. * @param indent The base indentation level of each line, must not be negative. * @param indentSize The size of each indentation, must not be negative. * @param lineLength The length of the line, must not be negative. * @return The sequence of display lines, never null. * @throws NegativeArraySizeException if indent < 0 */ private static List toLines( String text, int indent, int indentSize, int lineLength ) { List lines = new ArrayList(); String ind = repeat( "\t", indent ); String[] plainLines = text.split( "(\r\n)|(\r)|(\n)" ); for ( int i = 0; i < plainLines.length; i++ ) { toLines( lines, ind + plainLines[i], indentSize, lineLength ); } return lines; } /** * Adds the specified line to the output sequence, performing line wrapping if necessary. * * @param lines The sequence of display lines, must not be null. * @param line The line to add, must not be null. * @param indentSize The size of each indentation, must not be negative. * @param lineLength The length of the line, must not be negative. */ private static void toLines( List lines, String line, int indentSize, int lineLength ) { int lineIndent = getIndentLevel( line ); StringBuffer buf = new StringBuffer( 256 ); String[] tokens = line.split( " +" ); for ( int i = 0; i < tokens.length; i++ ) { String token = tokens[i]; if ( i > 0 ) { if ( buf.length() + token.length() >= lineLength ) { lines.add( buf.toString() ); buf.setLength( 0 ); buf.append( repeat( " ", lineIndent * indentSize ) ); } else { buf.append( ' ' ); } } for ( int j = 0; j < token.length(); j++ ) { char c = token.charAt( j ); if ( c == '\t' ) { buf.append( repeat( " ", indentSize - buf.length() % indentSize ) ); } else if ( c == '\u00A0' ) { buf.append( ' ' ); } else { buf.append( c ); } } } lines.add( buf.toString() ); } /** * Gets the indentation level of the specified line. * * @param line The line whose indentation level should be retrieved, must not be null. * @return The indentation level of the line. */ private static int getIndentLevel( String line ) { int level = 0; for ( int i = 0; i < line.length() && line.charAt( i ) == '\t'; i++ ) { level++; } for ( int i = level + 1; i <= level + 4 && i < line.length(); i++ ) { if ( line.charAt( i ) == '\t' ) { level++; break; } } return level; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy