
io.earcam.maven.plugin.sitemap.SitemapSubmissionMavenLifecycleParticipant Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of io.earcam.maven.plugin.sitemap Show documentation
Show all versions of io.earcam.maven.plugin.sitemap Show documentation
sitemaps.org integration; scalable, specification compliant
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:
*
* - BSD-3-Clause
* - EPL-1.0
* - Apache-2.0
* - MIT
*
* #L%
*/
package io.earcam.maven.plugin.sitemap;
import java.io.File;
import java.net.URI;
import java.util.List;
import org.apache.maven.AbstractMavenLifecycleParticipant;
import org.apache.maven.MavenExecutionException;
import org.apache.maven.execution.MavenSession;
import org.codehaus.plexus.component.annotations.Component;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.earcam.utilitarian.site.sitemap.Sitemaps;
@Component(role = AbstractMavenLifecycleParticipant.class, hint = SitemapSubmissionMavenLifecycleParticipant.NAME, instantiationStrategy = "singleton")
public class SitemapSubmissionMavenLifecycleParticipant extends AbstractMavenLifecycleParticipant {
private static final Logger LOG = LoggerFactory.getLogger(SitemapIndexMavenLifecycleParticipant.class);
static final String NAME = "sitemapsubmission";
private static final String CATEGORY = '[' + NAME + ']';
static volatile boolean run = false;
static URI baseUrl;
static File targetDir;
static List hosts;
@Override
public void afterSessionEnd(MavenSession session) throws MavenExecutionException
{
if(session.getResult().hasExceptions()) {
LOG.warn("{} extension: not running due to previous build errors", CATEGORY);
return;
}
LOG.debug("{} extension: configured to run: {}", CATEGORY, run);
if(run) {
String responses = Sitemaps.submit(targetDir.toPath(), baseUrl, hosts);
LOG.info("{} extension ran, responses: {}", CATEGORY, responses);
}
}
static void shouldRun(URI baseUrl, File targetDir, List hosts)
{
run = true;
SitemapSubmissionMavenLifecycleParticipant.baseUrl = baseUrl;
SitemapSubmissionMavenLifecycleParticipant.targetDir = targetDir;
SitemapSubmissionMavenLifecycleParticipant.hosts = hosts;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy