Adding custom classes required by maven-antrun-plugin - maven

I have an Ant task which is executed in maven by using maven-antrun-plugin. This tas uses an XmlTask to read some values from an XML file. The task fails with a class load error as the definition for this tas is in a separate jar. How can I add this jar to the classpath? I have tried adding this jar to the lib directory of both Maven and Ant, but still, I get this error.
Below is a section of my pom.xml where the error is:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>versionConsistency</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask"/>
<xmltask source="Upgrade.xml">
<copy path="component/versions/version/#number" property="fVer" />
</xmltask>
<property name="pVer" value = "${project.version}" />
<script language="javascript">
<![CDATA[
fVer = project.getProperty('fVer');
pVer = project.getProperty('pVer');
if( fVer == pVer){
project.setProperty('isVerConsistent','true');
}else if (pVer.substring(0, pVer.search("-")) == fVer){
project.setProperty('isVerConsistent','true');
}else{
project.setProperty('isVerConsistent','false');
var fail = project.createTask("fail");
fail.setMessage("Project version and version in Upgrade.xml do not match");
fail.perform();
}
]]>
</script>
</target>
</configuration>
</execution>
</executions>

Related

How to exclude META-INF WARNING after running mvn clean install?

the warnings look like this. Then under are my plugins How should I configure plugins to remove all META-INF warnings? the warnings look like this. Then under are my plugins How should I configure plugins to remove all META-INF warnings? Hier is one explanation that I have found. Maven Shade plugin: how resolve the warning message "define 1 overlapping resource: [WARNING] - META-INF/MANIFEST.MF"
[WARNING] Discovered module-info.class. Shading will break its strong encapsulation.
[WARNING] Discovered module-info.class. Shading will break its strong encapsulation.
[WARNING] FastInfoset-1.2.15.jar, HikariCP-java7-2.4.13.jar, MigLayout-3.7.2.jar, SparseBitSet-1.2.jar, TeoClientTest.jar, activemq-client-5.17.0.jar, animal-sniffer-annotations-1.17.jar, ant-1.10.12.jar, ant-antlr-1.10.12.jar, ant-junit-1.10.12.jar, ant-launcher-1.10.12.jar, asm-7.1.jar, bapi-skif-11.5.0-SNAPSHOT.jar, bcprov-jdk15on-1.68.jar, byte-buddy-1.8.12.jar, c3p0-0.9.5.4.jar, cglib-3.3.0.jar, checker-qual-2.5.2.jar, classmate-1.4.0.jar, cloning-1.9.12.jar, commons-beanutils-1.9.4.jar, commons-cli-1.4.jar, commons-codec-1.15.jar, commons-collections-3.2.2.jar, commons-collections4-4.4.jar, commons-compiler-3.1.6.jar, commons-compress-1.19.jar, commons-digester-2.1.jar, commons-email-1.5.jar, commons-io-2.11.0.jar, commons-lang-2.6.jar, commons-lang3-3.4.jar, commons-math3-3.6.1.jar, curvesapi-1.06.jar, ecj-3.21.0.jar, error_prone_annotations-2.2.0.jar, failureaccess-1.0.1.jar, geronimo-j2ee-management_1.1_spec-1.0.1.jar, groovy-3.0.10.jar, groovy-ant-3.0.10.jar, groovy-astbuilder-3.0.10.jar, groovy-cli-picocli-3.0.10.jar, groovy-console-3.0.10.jar, groovy-datetime-3.0.10.jar, groovy-docgenerator-3.0.10.jar, groovy-groovydoc-3.0.10.jar, groovy-groovysh-3.0.10.jar, groovy-jmx-3.0.10.jar, groovy-json-3.0.10.jar, groovy-jsr223-3.0.10.jar, groovy-macro-3.0.10.jar, groovy-nio-3.0.10.jar, groovy-servlet-3.0.10.jar, groovy-sql-3.0.10.jar, groovy-swing-3.0.10.jar, groovy-templates-3.0.10.jar, groovy-test-3.0.10.jar, groovy-test-junit5-3.0.10.jar, groovy-testng-3.0.10.jar, groovy-xml-3.0.10.jar, gson-2.9.0.jar, guava-27.0.1-jre.jar, hawtbuf-1.11.jar, httpclient-4.5.13.jar, httpcore-4.4.13.jar, httpmime-4.5.13.jar, itext-2.1.7.js9.jar, itextpdf-5.5.6.jar, j2objc-annotations-1.1.jar, jackson-annotations-2.11.3.jar, jackson-core-2.11.3.jar, jackson-databind-2.11.3.jar, jackson-dataformat-xml-2.11.3.jar, jackson-module-jaxb-annotations-2.11.3.jar, jakarta.activation-2.0.1.jar, janino-3.1.6.jar, jasperreports-6.19.0.jar, javaparser-core-3.24.0.jar, javassist-3.28.0-GA.jar, javax.activation-api-1.2.0.jar, javax.annotation-api-1.3.2.jar, javax.jms-api-2.0.1.jar, javax.mail-1.5.6.jar, jaxb-api-2.3.1.jar, jaxb-core-3.0.2.jar, jaxb-impl-3.0.2.jar, jaxb-runtime-2.4.0-b180830.0438.jar, jcl-over-slf4j-1.7.35.jar, jcommander-1.78.jar, jcommon-1.0.24.jar, jdom2-2.0.6.1.jar, jfreechart-1.5.3.jar, jide-action-3.7.10.jar, jide-charts-3.7.10.jar, jide-common-3.7.10.jar, jide-components-3.7.10.jar, jide-dashboard-3.7.10.jar, jide-dock-3.7.10.jar, jide-editor-3.7.10.jar, jide-gantt-3.7.10.jar, jide-grids-3.7.10.jar, jide-pivot-3.7.10.jar, jide-plaf-3.7.10.jar, jide-shortcut-3.7.10.jar, jline-2.14.6.jar, jna-5.11.0.jar, jna-platform-5.11.0.jar, joda-time-2.10.14.jar, jollyday-0.5.10.jar, jquery-3.5.1.jar, jsr305-3.0.2.jar, jul-to-slf4j-1.7.35.jar, junit-jupiter-api-5.8.2.jar, junit-jupiter-engine-5.8.2.jar, junit-platform-commons-1.8.2.jar, junit-platform-engine-1.8.2.jar, junit-platform-launcher-1.8.2.jar, listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar, log4j-over-slf4j-1.7.35.jar, logback-classic-1.2.10.jar, logback-core-1.2.10.jar, mapstruct-1.2.0.Final.jar, mchange-commons-java-0.2.15.jar, mybatis-3.5.7.jar, objenesis-3.0.1.jar, ojdbc11-21.5.0.0.jar, opencsv-2.3.jar, opentest4j-1.2.0.jar, picocli-4.6.1.jar, plac-exif-21.2.0.0.jar, poi-4.1.2.jar, poi-ooxml-4.1.2.jar, poi-ooxml-schemas-4.1.2.jar, qdox-1.12.1.jar, quartz-2.3.2.jar, reflections-0.10.2.jar, slf4j-api-1.7.35.jar, spring-aop-5.2.20.RELEASE.jar, spring-beans-5.2.20.RELEASE.jar, spring-context-5.2.20.RELEASE.jar, spring-context-support-5.2.20.RELEASE.jar, spring-core-5.2.20.RELEASE.jar, spring-expression-5.2.20.RELEASE.jar, spring-jdbc-5.2.20.RELEASE.jar, spring-jms-5.2.20.RELEASE.jar, spring-messaging-5.2.20.RELEASE.jar, spring-orm-5.2.20.RELEASE.jar, spring-oxm-5.2.20.RELEASE.jar, spring-plugin-core-1.2.0.RELEASE.jar, spring-plugin-metadata-1.2.0.RELEASE.jar, spring-security-core-5.4.10.jar, spring-tx-5.2.20.RELEASE.jar, spring-web-5.2.20.RELEASE.jar, spring-webmvc-5.2.20.RELEASE.jar, springfox-core-2.9.2.jar, springfox-schema-2.9.2.jar, springfox-spi-2.9.2.jar, springfox-spring-web-2.9.2.jar, springfox-swagger-common-2.9.2.jar, springfox-swagger-ui-2.9.2.jar, springfox-swagger2-2.9.2.jar, stax-ex-1.8.jar, stax2-api-4.2.1.jar, swagger-annotations-1.5.20.jar, swagger-models-1.5.20.jar, teo-common-report-10.3.0-SNAPSHOT.jar, teo-common-ui-10.3.0-SNAPSHOT.jar, teo-common-ui-report-10.3.0-SNAPSHOT.jar, teo-common-util-10.3.0-SNAPSHOT.jar, teo-skif-12.7.0-SNAPSHOT.jar, testng-7.5.jar, threeten-extra-1.5.0.jar, ucp-21.5.0.0.jar, woodstox-core-6.2.1.jar, xbean-spring-4.20.jar, xmlbeans-3.1.0.jar define 1 overlapping resource:
[WARNING] - META-INF/MANIFEST.MF
[WARNING] activemq-client-5.17.0.jar, cglib-3.3.0.jar, classmate-1.4.0.jar, geronimo-j2ee-management_1.1_spec-1.0.1.jar, groovy-3.0.10.jar, groovy-ant-3.0.10.jar, groovy-astbuilder-3.0.10.jar, groovy-cli-picocli-3.0.10.jar, groovy-console-3.0.10.jar, groovy-datetime-3.0.10.jar, groovy-docgenerator-3.0.10.jar, groovy-groovydoc-3.0.10.jar, groovy-groovysh-3.0.10.jar, groovy-jmx-3.0.10.jar, groovy-json-3.0.10.jar, groovy-jsr223-3.0.10.jar, groovy-macro-3.0.10.jar, groovy-nio-3.0.10.jar, groovy-servlet-3.0.10.jar, groovy-sql-3.0.10.jar, groovy-swing-3.0.10.jar, groovy-templates-3.0.10.jar, groovy-test-3.0.10.jar, groovy-test-junit5-3.0.10.jar, groovy-testng-3.0.10.jar, groovy-xml-3.0.10.jar, httpclient-4.5.13.jar, httpcore-4.4.13.jar, httpmime-4.5.13.jar, jackson-annotations-2.11.3.jar, jackson-core-2.11.3.jar, jackson-databind-2.11.3.jar, jackson-dataformat-xml-2.11.3.jar, jackson-module-jaxb-annotations-2.11.3.jar, jna-5.11.0.jar, jna-platform-5.11.0.jar, mybatis-3.5.7.jar, objenesis-3.0.1.jar, poi-4.1.2.jar, poi-ooxml-4.1.2.jar, poi-ooxml-schemas-4.1.2.jar, stax2-api-4.2.1.jar, woodstox-core-6.2.1.jar, xbean-spring-4.20.jar define 1 overlapping resource:
[WARNING] - META-INF/LICENSE
[WARNING] activemq-client-5.17.0.jar, cglib-3.3.0.jar, classmate-1.4.0.jar, geronimo-j2ee-management_1.1_spec-1.0.1.jar, groovy-3.0.10.jar, groovy-ant-3.0.10.jar, groovy-astbuilder-3.0.10.jar, groovy-cli-picocli-3.0.10.jar, groovy-console-3.0.10.jar, groovy-datetime-3.0.10.jar, groovy-docgenerator-3.0.10.jar, groovy-groovydoc-3.0.10.jar, groovy-groovysh-3.0.10.jar, groovy-jmx-3.0.10.jar, groovy-json-3.0.10.jar, groovy-jsr223-3.0.10.jar, groovy-macro-3.0.10.jar, groovy-nio-3.0.10.jar, groovy-servlet-3.0.10.jar, groovy-sql-3.0.10.jar, groovy-swing-3.0.10.jar, groovy-templates-3.0.10.jar, groovy-test-3.0.10.jar, groovy-test-junit5-3.0.10.jar, groovy-testng-3.0.10.jar, groovy-xml-3.0.10.jar, httpclient-4.5.13.jar, httpcore-4.4.13.jar, httpmime-4.5.13.jar, jackson-core-2.11.3.jar, jackson-databind-2.11.3.jar, jackson-dataformat-xml-2.11.3.jar, jackson-module-jaxb-annotations-2.11.3.jar, mybatis-3.5.7.jar, objenesis-3.0.1.jar, poi-4.1.2.jar, poi-ooxml-4.1.2.jar, poi-ooxml-schemas-4.1.2.jar, xbean-spring-4.20.jar define 1 //
[WARNING] maven-shade-plugin has detected that some class files are
[WARNING] present in two or more JARs. When this happens, only one
[WARNING] single version of the class is copied to the uber jar.
[WARNING] Usually this is not harmful and you can skip these warnings,
[WARNING] otherwise try to manually exclude artifacts based on
[WARNING] mvn dependency:tree -Ddetail=true and the above output.
[WARNING] See http://maven.apache.org/plugins/maven-shade-plugin/
How can I remove these WARNINGS?
My plugins looks like this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<configuration>
<minimizeJar>true</minimizeJar>
<inLibsFilter>!META-INF/**,!META-INF/versions/9/**.class</inLibsFilter>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.basepom.maven</groupId>
<artifactId>duplicate-finder-maven-plugin</artifactId>
<version>1.5.1</version>
<executions>
<execution>
<id>default</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<configuration>
<printEqualFiles>false</printEqualFiles>
<failBuildInCaseOfDifferentContentConflict>false</failBuildInCaseOfDifferentContentConflict>
<failBuildInCaseOfEqualContentConflict>false</failBuildInCaseOfEqualContentConflict>
<failBuildInCaseOfConflict>false</failBuildInCaseOfConflict>
<checkCompileClasspath>true</checkCompileClasspath>
<checkRuntimeClasspath>true</checkRuntimeClasspath>
<checkTestClasspath>false</checkTestClasspath>
<skip>false</skip>
<quiet>false</quiet>
<preferLocal>true</preferLocal>
<useResultFile>true</useResultFile>
<resultFileMinClasspathCount>2</resultFileMinClasspathCount>
<resultFile>${project.build.directory}/duplicate-finder-result.xml</resultFile>
<includeBootClasspath>false</includeBootClasspath>
<bootClasspathProperty>sun.boot.class.path</bootClasspathProperty>
<useDefaultResourceIgnoreList>true</useDefaultResourceIgnoreList>
<includePomProjects>false</includePomProjects>
<useDefaultResourceIgnoreList>true</useDefaultResourceIgnoreList>
<ignoredResourcePatterns>
<ignoredResourcePattern>jasperreports_extension\.properties</ignoredResourcePattern>
<ignoredResourcePattern>\.project</ignoredResourcePattern>
<ignoredResourcePattern>.*\.png$</ignoredResourcePattern>
<ignoredResourcePattern>.*\.txt$</ignoredResourcePattern>
<ignoredResourcePattern>.*\.json$</ignoredResourcePattern>
<ignoredResourcePattern>.*\.xml$</ignoredResourcePattern>
<ignoredResourcePattern>.*\.properties$</ignoredResourcePattern>
<ignoredResourcePattern>.*\.md$</ignoredResourcePattern>
</ignoredResourcePatterns>
<ignoredClassPatterns>
<ignoredClassPattern>(META-INF)</ignoredClassPattern>
</ignoredClassPatterns>
<!-- Beispiele <ignoredResourcePatterns> jasperreports_extension.properties
<ignoredResourcePattern>.*index\.html$</ignoredResourcePattern> </ignoredResourcePatterns>
<ignoredClassPatterns> <ignoredClassPattern>javax.*$</ignoredClassPattern>
</ignoredClassPatterns> -->
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<!-- We need to exclude the signatures for any signed jars otherwise
we get an exception. -->
<excludes>
<exclude>META-INF/*</exclude>
<exclude>META-INF/*.*</exclude>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</configuration>
</plugin>
This example works for me:
...
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.example.pikachu.Pikachu</mainClass>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer">
<resource>MANIFEST.MF</resource>
</transformer>
</transformers>
<filters>
<filter>
<artifact>com.example.pikachu:*</artifact>
<excludes>
<exclude>META-INF/*.MF</exclude>
</excludes>
</filter>
</filters>
</configuration>
...

cxf-codegen adding superfluous underscore in enum member name

I have the following generated enumeration type. The issue I have is that for some reason (presumably capitalisation) that an underscore is inserted in the NCBonus value.
I would like to know how I can prevent that from happening when generating the enumeration.
*
* <p>The following schema fragment specifies the expected content contained within this class.
* <p>
* <pre>
* <simpleType name="PromoType">
* <restriction base="{http://www.w3.org/2001/XMLSchema}string">
* <enumeration value="MEM"/>
* <enumeration value="COU"/>
* <enumeration value="CHA"/>
* <enumeration value="SAD"/>
* <enumeration value="NCBonus"/>
* </restriction>
* </simpleType>
* </pre>
*
*/
#XmlType(name = "PromoType")
#XmlEnum
public enum PromoType {
MEM("MEM"),
COU("COU"),
CHA("CHA"),
SAD("SAD"),
#XmlEnumValue("NCBonus")
NC_BONUS("NCBonus");
I have tried using the global bindings option
<jxb:globalBindings underscoreBinding="asCharInWord" xmlns:xs="http://www.w3.org/2001/XMLSchema">
which has undesired consequences on other objects but makes no different to the enum type.
In addition I have tried using
<jaxb:bindings schemaLocation="../schemas/insurance_service_model.xsd" node="//xs:schema">
<jaxb:bindings node="xs:simpleType[#name='PromoType']">
<jaxb:typesafeEnumMember name="NCBonus" value="NCBonus"/>
all to no avail.
Could someone please advise how I can achieve this goal please.
The answer that worked for me was to move the jaxb bindings out of the jaxws bindings file.
jaxb_bindings.xml
<jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
jaxb:version="2.0">
<jaxb:bindings schemaLocation="../schemas/insurance_service_model.xsd">
<jaxb:bindings node="//xsd:simpleType[#name='PromoType']">
<jaxb:typesafeEnumClass name="PromoType">
<jaxb:typesafeEnumMember name="NCBonus" value="NCBonus"/>
</jaxb:typesafeEnumClass>
</jaxb:bindings>
</jaxb:bindings>
</jaxb:bindings>
wsdl_bindings.xml
<?xml version="1.0" encoding="UTF-8"?>
<jaxws:bindings
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
wsdlLocation="../wsdl/insurance_service.wsdl"
xmlns="http://java.sun.com/xml/ns/jaxws"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws">
<jaxws:enableWrapperStyle>false</jaxws:enableWrapperStyle>
</jaxws:bindings>
pom.xml
<build>
<plugins>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.codegen.version}</version>
<executions>
<execution>
<id>csg</id>
<phase>generate-sources</phase>
<configuration>
<wsdlOptions>
<wsdlOption>
<wsdl>${project.basedir}/src/main/resources/v2_3/wsdl/insurance_service.wsdl</wsdl>
<extraargs>
<extraarg>-xjc-verbose</extraarg>
<extraarg>-verbose</extraarg>
</extraargs>
<bindingFiles>
<bindingFile>${project.basedir}/src/main/resources/common_binding.xml</bindingFile>
<bindingFile>${project.basedir}/src/main/resources/v2_3/bindings/wsdl_binding.xml</bindingFile>
<bindingFile>${project.basedir}/src/main/resources/v2_3/bindings/jaxb_bindings.xml</bindingFile>
</bindingFiles>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>

maven-jaxb2-plugin (maven) generated date and time

I'm trying to remove the generated date and time from files generated with plugin maven-jaxb2-plugin. Is-it possible?
Part of pom.xml :
<build>
<plugins>
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.8.3</version>
<executions>
<execution>
<id>commun-generate</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<generatePackage>my.package.dest</generatePackage>
<generateDirectory>${basedir}/src/main/java/</generateDirectory>
<schemaDirectory>${basedir}/src/main/resources/schemas/wsrest</schemaDirectory>
<bindingDirectory>${basedir}/src/main/resources/schemas/wsrest</bindingDirectory>
<bindingIncludes>
<include>bindings.xml</include>
</bindingIncludes>
<strict>false</strict>
<extension>true</extension>
<verbose>true</verbose>
</configuration>
</execution>
Begin of a generated file :
//
// Ce fichier a été généré par l'implémentation de référence JavaTM Architecture for XML Binding (JAXB), v2.2.6
// Voir http://java.sun.com/xml/jaxb
// Toute modification apportée à ce fichier sera perdue lors de la recompilation du schéma source.
// Généré le : 2014.03.17 à 09:42:08 AM CET
//
package my.package.dest;
...
I would like to remove this part :
Généré le : 2014.03.17 à 09:42:08 AM CET
thanks in advance
Clément
FYI noFileHeader configuration parameter is supported from 0.9.0. So you can just do
<configuration>
<noFileHeader>true</noFileHeader>
</configuration>
now.
See controlling the output section in the docs.
#lexicore's answer still works in 0.14.0 version. Simply add <noFileHeader>true</noFileHeader> in the configuration section.
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.14.0</version>
<configuration>
<noFileHeader>true</noFileHeader>
<schemaLanguage>wsdl</schemaLanguage>
<generatePackage>[...]</generatePackage>
<generateDirectory>${project.basedir}/src/main/java</generateDirectory>
<schemas>
<schema>
<url>[...]</url>
</schema>
</schemas>
</configuration>
I found a workaround describe here :
Skip the Generated on... in Java files using jaxb2 maven plugin
Solution? add in pom.xml, in , theses arguments : <args><arg>-no-header</arg></args>
result : no header is generated

Getting Menu Inheritance to Work in a Multi-Module Maven Site

I have a question about constructing a Maven site with a parent POM file and sub-modules. I am having trouble getting relative links in inherited module sites to work when the menu is inherited from a parent POM.
I have a project structure as follows:
modules/pom.xml
parent/
module1/
module2/
etc.
So with this configuration I end up with a site that looks like:
base-site/
module1/
module2/
The reactor build from modules/pom.xml generates the top-level website, and each of the modules also has a site generated.
Each of the modules inherits this site.xml file from the parent (for example):
<project>
<body>
<menu name="Module" inherit="top">
<item name="Summary" href="./project-summary.html"/>
</menu>
<menu name="Module" ref="reports" inherit="bottom" />
</body>
</project>
The menu referencing the standard Maven generated "reports" works fine.
But the href to project-summary.html ends up pointing back at the top site and not the child.
I have seen some similar issues on Stackoverflow having to do with constructing an inherited menu, but I did not find exact information on how to get these links to point to content in the child site and not the parent. It may be possible that I am misunderstanding what the menu inheritance is supposed to accomplish here.
Basically, I want the menu links to generated content in the child sites to look like:
<item name="Summary" href="./module1/project-summary.html"/>
Okay, so I thought, let me try to use filtering to accomplish this like from my parent POM using something like:
<item name="Summary" href="./${project.artifactId}/project-summary.html"/>
But that does not work because the parent POM's name gets substituted here instead of the child project's name.
In this case, perhaps I need site a custom site.xml for each module, but I would like to avoid this as there are something like 15 of them, and they will mostly be identical in terms of sharing about 8 or 9 different (relative) menu links. Most projects would not need their own site.xml file. So ideally I'd like the parent to define all the defaults with the child POMs adding a few additional menus.
In order to do this, am I stuck with using the "reports" ref and its default layout? Or can I list these explicitly as menu items in the parent's site.xml file and get those references to work somehow?
I hope that's clear. Thanks.
I've the same need as you.
I'll use the gmaven-plugin with a script (during the generate resource phase) that iterates in parent and copy src/site/site.xml in the current project if any.
Here's my script (Here's I'm just copying a parent site.xml file if a 'readme.md' file is present on the module):
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>execute</goal>
</goals>
<phase>pre-site</phase>
</execution>
</executions>
<configuration>
<scripts>
<script> <![CDATA[
import java.io.BufferedWriter
import java.io.File
import java.nio.charset.Charset
import java.nio.file.StandardCopyOption
import java.nio.file.Files
import java.nio.file.StandardOpenOption
String siteXmlPath = "src/site/site.xml"
String readme_file = "readme.md"
String currentPath = "${project.basedir}"
if (new File(currentPath + "/" + readme_file).exists() && !(new File(currentPath + "/" + siteXmlPath).exists())) {
while (!(new File(currentPath + "/" + siteXmlPath).exists())) {
currentPath = currentPath + "/.."
if (new File(currentPath + "/" + siteXmlPath).exists()) {
Files.copy(new File(currentPath + "/" + siteXmlPath).toPath(), new File("${project.basedir}/" + siteXmlPath).toPath(), StandardCopyOption.REPLACE_EXISTING)
File newlyCreatedFile = new File("${project.basedir}/" + siteXmlPath)
BufferedWriter newFileWriter = Files.newBufferedWriter(newlyCreatedFile.toPath(), Charset.defaultCharset(), StandardOpenOption.APPEND)
newFileWriter.append("<!-- #generated -->")
newFileWriter.close()
} else if (!(new File(currentPath + "/pom.xml").exists())) { break; }
}
} ]]>
</script>
</scripts>
</configuration>
</plugin>
Regards

Removing the About link from maven site

I'm using mvn site to generate my site's documentation. For the most part, I'm satisfied with the default site, but I'd like to remove the "About" link from the left hand menu bar and just have the default page be the "Project Information" page. Is there an easy way to do this?
Here only the 'About' report is still included. All other standard reports are removed.
<reporting>
<plugins>
<!-- Add the Maven project information reports -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.1.2</version>
<reportSets>
<reportSet>
<reports>
<report>index</report>
<!--
<report>dependencies</report>
<report>project-team</report>
<report>mailing-list</report>
<report>cim</report>
<report>issue-tracking</report>
<report>license</report>
<report>scm</report>
-->
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
You can either modify the source and comment it out or add a css selector for it, or you can include a JS library like jQuery and remove it when the page loads via something like:
$(function () {
// untested
$('#navcolumn h5:contains("Maven")').hide(); // hide the header
$('#navcolumn h5:contains("Maven") + ul ').hide(); // hide the ul
})();
I ended up not using that plugin at all and just used the maven-site-plugin. Maven 3 has a reportPlugins configuration section of the maven pom that lets you specified which reports you want to show up http://maven.apache.org/plugins/maven-site-plugin/maven-3.html
org.apache.maven.plugins
maven-site-plugin
3.0
org.codehaus.mojo
cobertura-maven-plugin
I also provided my own index.apt (in src/site/apt) file to customize the index page text.
I know this is an old question, but I've always found it quite annoying. The 'About' section is redundant, and more important, cause the 'Project Information' menu is expanded by default when you visit the site. Since I didn't found any solution on the web, I had to figure it out myself.
With the following workaround, the 'About' item under the 'Project Information' menu will completely disappear from the site. Just add this to the site.xml file:
...
<body>
<head>
<![CDATA[
<script type="text/javascript">
$(document).ready(function () {
var linkAbout = $('a').filter(function(index) { return $(this).text() === "About"; });
var projectInformationMenu = $('a').filter(function(index) { return $(this).text() === "Project Information"; });
linkAbout.hide();
if (!projectInformationMenu.parent().hasClass('active')) {
projectInformationMenu.parent().children('ul').hide();
projectInformationMenu.children('span').removeClass('icon-chevron-down').addClass('icon-chevron-right');
}
});
</script>
]]>
</head>
...
</body>

Resources