Maven site (Maven 3) generates empty site folder
Asked Answered
H

3

11

I'm attempting to create a basic maven site using the maven site plugin. So I added this to my pom:

<reporting>
    <plugins>
        <!--JavaDoc setup-->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>2.7</version>
            <configuration>
                <defaultAuthor>Leon Blakey</defaultAuthor>
                <defaultVersion>${project.version}</defaultVersion>
                <links>
                    <link>http://download.oracle.com/javase/6/docs/api</link>
                </links>
            </configuration>
        </plugin>
    </plugins>
</reporting>

And ran mvn site --errors

[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building pircbotx 1.3-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-site-plugin:2.0.1:site (default-site) @ pircbotx ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.688s
[INFO] Finished at: Wed Jan 12 18:08:00 EST 2011
[INFO] Final Memory: 5M/13M
[INFO] ------------------------------------------------------------------------
W:\programming\pircbot-hg>

Hmm, odd that there's no output. So when I check target/site, its empty. The only folders are images/ , css/ , and WEB-INF/ , filled with some generic pictures. No javadoc and no site.

This is reproducible with mvn site:site and mvn org.apache.maven.plugins:maven-site-plugin:2.2:site (apparently maven only wants to use 2.0.1 by default)

Whats strange is that I can go back to maven 2.2.1 and successfully generate a site. But when I use 3.0.1-RC1 (happens to come with Netbeans), it fails.

What am I doing wrong that would make the site plugin fail in 3.0.1 but not 2.2.1?

Holmun answered 12/1, 2011 at 23:21 Comment(3)
Not that this will help you, but I had the same problem with 3.0 and figured it was a maven bug. I never did get the site generated.Sixfold
Check cwiki.apache.org/MAVEN/maven-3x-and-site-plugin.html to see if that helps as wellJunk
@Junk these days I think the link you provided about Maven 3 and site plugin is detailed at this page instead: maven.apache.org/plugins/maven-site-plugin/maven-3.htmlFidgety
J
12

Perhaps you can try using Maven Site Plugin 3.x. You can do that by adding the following in your pom.xml

<build>
    ...
    <plugins>
        ...
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-site-plugin</artifactId>
            <version>3.0-beta-3</version>
        </plugin>
    </plugins>
</build>
Junk answered 13/1, 2011 at 8:46 Comment(6)
Yes, using 3.0-beta-3 plugin definitely causes maven to actually work, but it irks me to use a plugin version with -beta in it.Cathedral
Will this break if I use Maven 2? I migrate between 2.2.1 and 3.0.1Holmun
@TheLQ. Yes. This version of the plugin requires maven 3Junk
Well this works in Maven 3. Guess I just have to use that. Thanks for the helpHolmun
If you want this to work in both Maven 2 and 3 (this was a requirement for working with my CI server) you need to put it in a profile. I find that this activation section seems to give workable results: <activation><file><exists>${basedir}</exists></file></activation>Smelser
@Cathedral A demonstration of what was 'irking' you is trying to understand this page released further down the track. Seems things changed a little after betaFidgety
N
8

I was having the same problem. I found a blog post about the topic.

Quoting the blog (emphasis mine):

If you have been using the reporting section of the pom.xml file to generate code quality metrics, javadoc reports, and so forth, you may have a little work to do to migrate this feature into Maven 3. Indeed, the reporting and reportSets sections have been deprecated (it won't cause an error with Maven 3, it will just be ignored), and have been replaced by a reportPlugins section in the configuration block of the maven-site-plugin itself.

Ignoring the old <reporting> without any warning about it being deprecated seems a bit rude, but anyway...

So you are basically just moving your old reporting plugins into the configuration section of the new maven-site-plugin.

A section of the maven-plugin-site explains that they removed of all reporting logic from the core of Maven to "decouple the Maven core from Doxia and to allow arbitrary reporting systems to be developed." Makes sense.

Nanon answered 19/8, 2011 at 22:23 Comment(1)
Yea, that's why everything broke and why Site 3 is requiredHolmun
E
7

Use of the Site Plugin ( http://maven.apache.org/plugins/maven-site-plugin/ ) with Maven 3 finally seems to be resolved. The (non-beta) version has been released, and the ability to use the version 2 style <reporting> structure in the pom.xml declaration has been added back.

Although it is (as usual) hard to navigate the substantial but unorganized and overlapping documentation about Maven 3 and the site plugin, one page - http://maven.apache.org/plugins/maven-site-plugin/maven-3.html - states that the old style is now recommended over the new "plugin to site plugin" style:

Note: In Maven 3, the new format does not support report plugins configuration inheritance: see MSITE-484. This format was technically necessary to remove reporting logic from Maven 3, but a new inheritance mechanism still needs to be added to Maven 3 to make it as flexible as the old format. So the new format is not ready for direct use for now.

The example page http://maven.apache.org/plugins/maven-site-plugin/examples/configuring-reports.html for configuring reports doesn't even mention the "new" formatting method.

Not sure if this is in a "best practice" form, but an example pom reporting section that works for me with a couple of extra reports is as follows; select your own plugins as desired.

    ...
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-site-plugin</artifactId>
                <version>3.0</version>
          </plugin>
       </plugins>
    </build>

    <reporting>
        <plugins>

            <!-- Default Site Pages -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-project-info-reports-plugin</artifactId>
                <version>2.4</version>
            </plugin>

            <!-- Java Documentation -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>2.8</version>
            </plugin>

            <!-- Source Code Cross-Reference -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jxr-plugin</artifactId>
                <version>2.3</version>
            </plugin>
            ...
        </plugins>
    </reporting>

As an aside, If you use the m2e plugin in Eclipse to edit your POMs, then you can use code completion in the version section of a plugin to give you a list of its current versions. Very handy.

Epicanthus answered 22/1, 2012 at 21:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.