s4u / sitemapxml-maven-plugin

Maven sitemap.xml generator plugin
https://www.simplify4u.org/sitemapxml-maven-plugin/
Apache License 2.0
4 stars 0 forks source link

Problem when run mvn site com.github.s4u.plugins:sitemapxml-maven-plugin:gen #38

Closed BigGitWorld closed 3 years ago

BigGitWorld commented 3 years ago

Sorry For the question here. Can I use this plugin for a maven project that is in the development phase locally?I mean do I have to publish my site project and use real links or it can be used in localhost development phase with introducing folder of HTML files (I'm using spring boot with thymeleaf template engine)?

slawekjaranowski commented 3 years ago

Thanks for question. First you mentioned old groupId of plugin, newer versions use org.simplify4u.plugins:sitemapxml-maven-plugin - please update.

You can use plugin for locally development. After execute plugin generate file sitemap.xml in maven site target directory, default targe/site

When you have configured plugin in project you don't need call this separately. It will be run with maven site

BigGitWorld commented 3 years ago

thank you for your nice plugin. I modified the groupId of the plugin to the new one. I don't know why when I run mvn site, very maven dependencies that are not included in my own maven project at all, are getting downloaded! for example kafka, jboss, third party libraries and etc. And I have to wait very long time. Example:

mvn site

Downloading: https://repo.maven.apache.org/maven2/org/springframework/cloud/spring-cloud-gcp-starters/1.1.3.RELEASE/spring-cloud-gcp-starters-1.1.3.RELEASE.pom
Downloaded: https://repo.maven.apache.org/maven2/org/springframework/cloud/spring-cloud-gcp-starters/1.1.3.RELEASE/spring-cloud-gcp-starters-1.1.3.RELEASE.pom (2 KB at 3.7 KB/sec)
Downloading: https://repo.spring.io/libs-milestone-local/org/springframework/cloud/spring-cloud-gcp-starter-config/1.1.3.RELEASE/spring-cloud-gcp-starter-config-1.1.3.RELEASE.pom
Downloading: https://repo.spring.io/release/org/springframework/cloud/spring-cloud-gcp-starter-config/1.1.3.RELEASE/spring-cloud-gcp-starter-config-1.1.3.RELEASE.pom
Downloading: https://maven-central.storage-download.googleapis.com/repos/central/data/org/springframework/cloud/spring-cloud-gcp-starter-config/1.1.3.RELEASE/spring-cloud-gcp-starter-config-1.1.3.RELEASE.pom
...
other maven libs...

what is the problem?

slawekjaranowski commented 3 years ago

What do you have in reporting section in your pom.xml? Try with one report, like: index

https://maven.apache.org/plugins/maven-site-plugin/examples/configuring-reports.html

look at the log of your build for something as:

[INFO] --- maven-site-plugin:3.9.1:site (default-site)  ---
[INFO] configuring report plugin org.apache.maven.plugins:maven-project-info-reports-plugin:3.1.1
[INFO] 8 reports configured for maven-project-info-reports-plugin:3.1.1: ci-management, dependencies, issue-management, licenses, plugins, team, scm, summary

probably you have configured dependency* report and report try to analyze all dependency tree of your project ... so many artifacts is downloaded

https://maven.apache.org/plugins/maven-project-info-reports-plugin/

BigGitWorld commented 3 years ago

I added the below reporting section to the pom.xml and the above problem was solved.

 <reporting>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-project-info-reports-plugin</artifactId>
                <version>2.6</version>
                <reportSets>
                    <reportSet>
                        <reports><!-- select reports -->
                            <report>index</report>
                        </reports>
                    </reportSet>
                </reportSets>
            </plugin>
        </plugins>
    </reporting>

But the sitemap.xml file generated in the target/site did not recognize my HTML files. I'm using spring + Thymeleaf and my html files are inside of resources/templates folder. How do I have to solve it?

mvn site

[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for com.example:project-site:jar:0.0.1-SNAPSHOT
[WARNING] 'dependencies.dependency.version' for org.json:json:jar is either LATEST or RELEASE (both of them are being deprecated) @ com.example:parent-services:1.0-SNAPSHOT, /home/user/.m2/repository/com/example/parent-services/1.0-SNAPSHOT/parent-services-1.0-SNAPSHOT.pom, line 102, column 22
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 
[INFO] 
[INFO] ----------------------< com.example:project-site >----------------------
[INFO] Building project-site 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-site-plugin:3.7.1:site (default-site) @ project-site ---
[INFO] configuring report plugin org.apache.maven.plugins:maven-project-info-reports-plugin:2.6
[INFO] 1 report configured for maven-project-info-reports-plugin:2.6: index
[INFO] Rendering site with default locale English (en)
[WARNING] Unable to find a URL to the parent project. The parent menu will NOT be added.
[INFO] Relativizing decoration links with respect to localized project URL: https://projects.spring.io/spring-boot/#/spring-boot-starter-parent/parent-services/project-site
[INFO] Rendering content with org.apache.maven.skins:maven-default-skin:jar:1.2 skin.
[INFO] Generating "About" report         --- maven-project-info-reports-plugin:2.6:index
[INFO] 
[INFO] --- sitemapxml-maven-plugin:2.1.0:gen (default) @ project-site ---
[INFO] Generate sitemap.xml - Start
[INFO] Generate sitemap.xml - OK
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  6.601 s
[INFO] Finished at: 2020-11-14T11:13:31+03:30
[INFO] ------------------------------------------------------------------------
slawekjaranowski commented 3 years ago

In your case you don't need to use maven site engine, try

    <build>
        <plugins>
            <plugin>
                <groupId>org.simplify4u.plugins</groupId>
                <artifactId>sitemapxml-maven-plugin</artifactId>
                <version>2.1.0</version>
                <executions>
                    <execution>
                        <id>sitemapxml-templates</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>gen</goal>
                        </goals>
                        <configuration>
                            <siteOutputDirectory>${project.build.outputDirectory}/templates</siteOutputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

sitemap.xml will be generated in target/templates directory

now you must discover how to configure thymeleaf resolver to suport sitemapxml https://www.thymeleaf.org/doc/tutorials/3.0/thymeleafspring.html#views-and-view-resolvers-in-thymeleaf

slawekjaranowski commented 3 years ago

more configuration options you can found at https://www.simplify4u.org/sitemapxml-maven-plugin/gen-mojo.html

slawekjaranowski commented 3 years ago

I hope, then I help you. So I close this issue.