Skip to content

Commit

Permalink
enable to run minisite-core with java 8
Browse files Browse the repository at this point in the history
  • Loading branch information
rmannibucau committed Sep 15, 2022
1 parent 14137c4 commit e68c1d8
Show file tree
Hide file tree
Showing 13 changed files with 152 additions and 124 deletions.
4 changes: 3 additions & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,11 @@ Here is a sample report:

=== Minisite

Minisite enables to render a static website with a generic Yupiik template.
Minisite enables to render a static website with a generic Yupiik template or a custom one with some configuration.
It comes with its companion serve goal to have a live preview.

TIP: as all plugins it requires Java 11 but if you want to use it with Java 8 you can use `minisite-core` module with `exec-maven-plugin` since version 1.1.1.

[source,sh]
----
mvn yupiik-tools:minisite
Expand Down
3 changes: 3 additions & 0 deletions _documentation/src/main/minisite/content/mojos.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ mvn \
== Minisite

xref:mojo/minisite.adoc[minisite] can push the minisite to a remote target (often git backed pages).

TIP: as all plugins it requires Java 11 but if you want to use it with Java 8 you can use `minisite-core` module with `exec-maven-plugin` since version 1.1.1.

Here is the related documentation.

The configuration supports a `git` entry if you want to upload to a Git branch the generated website (like `gh-pages`):
Expand Down
18 changes: 18 additions & 0 deletions minisite-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,22 @@
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>default-compile</id>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ public void run() {

try {
if (Files.isDirectory(from)) {
Files.walkFileTree(from, new SimpleFileVisitor<>() {
Files.walkFileTree(from, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException {
final var target = to.resolve(from.relativize(file));
final Path target = to.resolve(from.relativize(file));
doCopy(file, target);
return super.visitFile(file, attrs);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ private Goal toGoal(final Element element, final boolean requiresDefaults) {
.filter(e -> Boolean.parseBoolean(getString(e, "editable")))
.map(e -> {
final String name = getString(e, "name");
final var defaultConfig = defaults.get(name);
final ParameterConfig defaultConfig = defaults.get(name);
return new Parameter(
name,
getString(e, "type")
Expand Down Expand Up @@ -247,7 +247,7 @@ private String toDocumentation(final String groupId, final String artifactId, fi
return p1.getName().compareTo(p2.getName());
})
.map(p -> {
final var config = p.getConfig();
final ParameterConfig config = p.getConfig();
return p.getName() + (p.isRequired() ? "*" : "") + " (`" + p.getType() + "`)" + "::\n" +
ofNullable(p.getDescription())
.map(String::trim)
Expand All @@ -270,7 +270,7 @@ private String toDocumentation(final String groupId, final String artifactId, fi
}

private String sanitizeDescription(final String it) {
final var text = it
final String text = it
.replace("<p>", "\n").replace("</p>", "")
.replace("<ul>", "").replace("</ul>", "")
.replace("<li>", "* ").replace("</li>", "\n");
Expand All @@ -296,7 +296,7 @@ private Document loadXml(final String pluginXmlLocation) throws ParserConfigurat
}

private static InputStream findPluginXml(final String pluginXmlLocation) throws IOException {
final var path = Path.of(pluginXmlLocation).toAbsolutePath().normalize();
final Path path = Path.of(pluginXmlLocation).toAbsolutePath().normalize();
if (Files.exists(path)) {
return Files.newInputStream(path);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public String toUrl(final MiniSiteConfiguration.GravatarConfiguration configurat

private String hash(final String mail) {
try {
final var md = MessageDigest.getInstance("MD5");
final var array = md.digest(mail.getBytes("CP1252"));
final MessageDigest md = MessageDigest.getInstance("MD5");
final byte[] array = md.digest(mail.getBytes("CP1252"));
return IntStream.range(0, array.length)
.mapToObj(idx -> Integer.toHexString((array[idx] & 0xFF) | 0x100).substring(1, 3))
.collect(joining());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class IndexService {
public Index index(final Path base, final String siteBase, final Predicate<Path> filter) {
final Index result = new Index(new ArrayList<>());
try {
Files.walkFileTree(base, new SimpleFileVisitor<>() {
Files.walkFileTree(base, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException {
if (file.getFileName().toString().endsWith(".html") && filter.test(file)) {
Expand Down

0 comments on commit e68c1d8

Please sign in to comment.