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

io.earcam.maven.plugin.sitemap.SitemapSubmissionMojo Maven / Gradle / Ivy

The newest version!
/*-
 * #%L
 * io.earcam.maven.plugin.sitemap
 * %%
 * Copyright (C) 2017 earcam
 * %%
 * SPDX-License-Identifier: (BSD-3-Clause OR EPL-1.0 OR Apache-2.0 OR MIT)
 *
 * You must choose to accept, in full - any individual or combination of
 * the following licenses:
 * 
 * #L%
 */
package io.earcam.maven.plugin.sitemap;

import static org.apache.maven.plugins.annotations.LifecyclePhase.SITE_DEPLOY;

import java.io.File;
import java.net.URI;
import java.util.List;

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Mojo for submitting sitemaps
 */
@Mojo(name = SitemapSubmissionMojo.NAME, requiresProject = true, threadSafe = true, inheritByDefault = false, defaultPhase = SITE_DEPLOY)
public class SitemapSubmissionMojo extends AbstractMojo {

	private static final Logger LOG = LoggerFactory.getLogger(SitemapIndexMavenLifecycleParticipant.class);
	static final String NAME = "submit";
	private static final String CATEGORY = '[' + NAME + ']';

	/**
	 * The site's base URL, defaults to ${project.distributionManagement.site.url}
	 */
	@Parameter(property = "sitemap.url.base", defaultValue = "${project.distributionManagement.site.url}")
	protected URI baseUrl;

	/**
	 * Location of where the sitemap/index should be written, defaults to ${project.reporting.outputDirectory}
	 */
	@Parameter(property = "sitemap.dir.target", defaultValue = "${project.reporting.outputDirectory}")
	protected File targetDir;

	/**
	 * Sitemap submission hosts. The host URI must include the protocol but no path, e.g. https://google.com
	 */
	@Parameter(property = "sitemap.submit.hosts", defaultValue = "https://google.com,https://bing.com,https://yahoo.com", readonly = true, required = true)
	protected List hosts;

	/**
	 * Skip execution of this plugin
	 */
	@Parameter(property = "sitemap.skip", defaultValue = "false")
	protected boolean skip;


	@Override
	public void execute() throws MojoExecutionException, MojoFailureException
	{
		if(skip) {
			LOG.debug("{} skip == true, skipping execution", CATEGORY);
			return;
		}

		LOG.debug("{} extending lifecycle, will run at end", CATEGORY);
		SitemapSubmissionMavenLifecycleParticipant.shouldRun(baseUrl, targetDir, hosts);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy