1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package io.earcam.maven.plugin.sitemap;
20
21 import static org.apache.maven.plugins.annotations.LifecyclePhase.SITE;
22
23 import java.nio.file.Files;
24 import java.nio.file.Path;
25
26 import org.apache.maven.plugin.MojoExecutionException;
27 import org.apache.maven.plugin.MojoFailureException;
28 import org.apache.maven.plugins.annotations.Mojo;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
31
32 import io.earcam.unexceptional.Exceptional;
33 import io.earcam.utilitarian.site.sitemap.Sitemaps;
34
35
36
37
38 @Mojo(name = SitemapMojo.NAME, requiresProject = true, threadSafe = true, inheritByDefault = true, defaultPhase = SITE, aggregator = false, requiresOnline = false)
39 public class SitemapMojo extends AbstractSitemapMojo {
40
41 private static final Logger LOG = LoggerFactory.getLogger(SitemapMojo.class);
42 static final String NAME = "sitemap";
43 private static final String CATEGORY = '[' + NAME + ']';
44
45
46 @Override
47 public void execute() throws MojoExecutionException, MojoFailureException
48 {
49 if(skip) {
50 LOG.debug("{} skip == true, skipping execution", CATEGORY);
51 return;
52 }
53
54 LOG.debug("{} start", CATEGORY);
55
56 Path file = Exceptional.apply(Sitemaps::create, parameters());
57
58 Exceptional.apply(Files::lines, file)
59 .forEach(f -> LOG.debug("{} Created {}", CATEGORY, f));
60
61 LOG.debug("{} end", CATEGORY);
62 }
63 }