Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

activate Reproducible Builds #12

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
820b406
Env manager module (#11)
rmannibucau Feb 5, 2024
6b53318
[env manager] add run command
rmannibucau Feb 5, 2024
447504b
[style] fix missing headers
rmannibucau Feb 5, 2024
3cad043
[asciidoc] avoid wrapping p in callouts
rmannibucau Feb 5, 2024
1c1df81
[asciidoc] even less wrapping in callouts
rmannibucau Feb 5, 2024
0f4c232
[env manager] add run command test and support windows PathExt
rmannibucau Feb 5, 2024
eb222a4
[env manager] fix run executed command debug statement
rmannibucau Feb 5, 2024
3279782
[env manager] more efficient zulu cache and add filters to list command
rmannibucau Feb 6, 2024
0c17e4f
[style] missing header
rmannibucau Feb 6, 2024
f6e4a68
[env manager] move to reactive programming to do remoting concurrently
rmannibucau Feb 6, 2024
ee22a67
[env-manager] simple offline support
rmannibucau Feb 6, 2024
132acf0
[env manager] tolerate to not mention apache- prefix for central prov…
rmannibucau Feb 6, 2024
5cc967d
[env-manager] using zulu api instead of the slow scraping
rmannibucau Feb 6, 2024
81213cb
[env-manager] simplify central provider and only drop Apache from the…
rmannibucau Feb 7, 2024
2810d86
[env-manager] enable candidate to provide metadata
rmannibucau Feb 7, 2024
89117a6
[style] missing header
rmannibucau Feb 7, 2024
40f0c15
[env-manager] basic color support
rmannibucau Feb 7, 2024
ec6c98d
[env-manager] no progress bar on CI + no quote on windows in env command
rmannibucau Feb 7, 2024
7a7f7fe
[minisite] ensure there is no link issue on windows
rmannibucau Feb 7, 2024
3fa30f3
[tests] make env-manager tests running on windows
rmannibucau Feb 7, 2024
a383939
[env-manager] some adjustments for windows + fix zulu OS filtering
rmannibucau Feb 7, 2024
538d6e8
[env-manager] ensure run works on windows
rmannibucau Feb 7, 2024
3541027
[env-manager] enable to use env with an inlinerc file content
rmannibucau Feb 9, 2024
5e1ce46
[env-manager] support inline args for env command
rmannibucau Feb 10, 2024
824937d
[env-manager] better log message formatting for env command
rmannibucau Feb 11, 2024
2131ff1
activate Reproducible Builds
hboutemy Feb 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 29 additions & 1 deletion _documentation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
under the License.

-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>yupiik-tools-maven-plugin-parent</artifactId>
<groupId>io.yupiik.maven</groupId>
Expand Down Expand Up @@ -67,6 +68,12 @@
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.yupiik.dev</groupId>
<artifactId>env-manager</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-settings</artifactId>
Expand All @@ -85,8 +92,29 @@
<version>1.7.36</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.yupiik.fusion</groupId>
<artifactId>fusion-documentation</artifactId>
<version>${fusion.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<plugins>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>17</source>
<target>17</target>
<release>17</release>
</configuration>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>doc</id>
Expand Down
17 changes: 16 additions & 1 deletion _documentation/src/main/java/io/yupiik/tools/doc/Generate.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package io.yupiik.tools.doc;

import io.yupiik.fusion.documentation.DocumentationGenerator;
import io.yupiik.maven.service.git.Git;
import io.yupiik.maven.service.git.GitService;
import io.yupiik.tools.common.asciidoctor.AsciidoctorConfiguration;
Expand Down Expand Up @@ -53,6 +54,19 @@ public static void main(final String... args) throws Exception {
"toBase", doc.resolve("content/mojo").toString(),
"pluginXml", doc.resolve("../../../../yupiik-tools-maven-plugin/target/classes/META-INF/maven/plugin.xml").toString()));

final var generateEnvManagerConfiguration = new PreAction();
generateEnvManagerConfiguration.setType(DocumentationGenerator.class.getName());
generateEnvManagerConfiguration.setConfiguration(Map.of(
"includeEnvironmentNames", "true",
"module", "yem",
"urls", doc
.resolve("../../../../env-manager/target/classes/META-INF/fusion/configuration/documentation.json")
.normalize()
.toUri().toURL().toExternalForm()));

final var generateEnvManagerCommands = new PreAction();
generateEnvManagerCommands.setType(YemCommands.class.getName());

final var configuration = new MiniSiteConfiguration();
configuration.setIndexText("Yupiik Tools");
configuration.setIndexSubTitle("adoc:" +
Expand All @@ -77,7 +91,7 @@ public static void main(final String... args) throws Exception {
configuration.setSource(doc);
configuration.setTarget(out);
configuration.setSiteBase("/tools-maven-plugin");
configuration.setPreActions(List.of(mojoAction));
configuration.setPreActions(List.of(mojoAction, generateEnvManagerConfiguration, generateEnvManagerCommands));
configuration.setGenerateSiteMap(true);
configuration.setGenerateIndex(true);
configuration.setProjectName(projectName);
Expand All @@ -90,6 +104,7 @@ public static void main(final String... args) throws Exception {
configuration.setActionClassLoader(() -> new ClassLoader(Thread.currentThread().getContextClassLoader()) {
// avoid it to be closed too early by wrapping it in a not URLCLassLoader
});
configuration.setAttributes(Map.of("partialsdir", doc + "/content/_partials"));
configuration.setAsciidoc(new YupiikAsciidoc());
configuration.setAsciidoctorConfiguration(new AsciidoctorConfiguration() {
@Override
Expand Down
62 changes: 62 additions & 0 deletions _documentation/src/main/java/io/yupiik/tools/doc/YemCommands.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright (c) 2020 - 2023 - Yupiik SAS - https://www.yupiik.com
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package io.yupiik.tools.doc;

import io.yupiik.dev.YemModule;
import io.yupiik.fusion.cli.CliAwaiter;
import io.yupiik.fusion.cli.internal.CliModule;
import io.yupiik.fusion.framework.api.ConfiguringContainer;
import io.yupiik.fusion.framework.api.container.bean.ProvidedInstanceBean;
import io.yupiik.fusion.framework.api.main.Args;
import io.yupiik.fusion.framework.api.scope.DefaultScoped;
import io.yupiik.fusion.json.internal.framework.JsonModule;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;

public class YemCommands implements Runnable {
private final Path sourceBase;

public YemCommands(final Path sourceBase) {
this.sourceBase = sourceBase;
}

@Override
public void run() { // cheap way to generate the help, todo: make it sexier and contribute it to fusion-documentation?
try (final var container = ConfiguringContainer.of()
.disableAutoDiscovery(true)
.register(new ProvidedInstanceBean<>(DefaultScoped.class, Args.class, () -> new Args(List.of())))
.register(new JsonModule(), new YemModule(), new CliModule())
.start();
final var awaiter = container.lookup(CliAwaiter.class)) {
awaiter.instance().await();
throw new IllegalStateException("Should have failed since CliAwaiter didn't find any command");
} catch (final IllegalArgumentException iae) {
try {
Files.writeString(
Files.createDirectories(sourceBase.resolve("content/_partials/generated")).resolve("commands.yem.adoc"),
iae.getMessage().substring(iae.getMessage().indexOf(':') + 1).strip()
// structure next lines
.replace(" Parameters:", "** Parameters:")
.replace(" --", "*** --"));
} catch (final IOException e) {
throw new IllegalStateException(e);
}
}
}
}
114 changes: 114 additions & 0 deletions _documentation/src/main/minisite/content/yem.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
= YEM (Environment Manager)
:minisite-index: 600
:minisite-index-title: YEM
:minisite-index-icon: robot
:minisite-index-description: Yupiik Environment manager

[abstract]
Setting up dev environment can be a nightmare.
_yem_ intends to make it easier.

== Inspiration

_yem_ is inspired from SDKMan, Chocolatey and other alternatives.
The main differences are:

* _yem_ does not come with a remote storage but it tries to reuse existing ones - priviledging immutable one when possible (compared to SDKMan where you can loose the version you picked),
* _yem_ intends to be portable (linux/windows at least),
* _yem_ is extensible if needed (new source or tool/distribution).

== Configuration

IMPORTANT: the atomic configuration is listed there but used on the command line you must ensure to prefix any option by `-` and replace dots by `-`. Example: `central.base` becomes `--central-base`.

include::{partialsdir}/generated/documentation.yem.adoc[lines=4..-1]

== CLI

The command line uses spaces between option and value: `yem install --tool java --version 21.0.2`.

=== Commands

include::{partialsdir}/generated/commands.yem.adoc[]

== Auto-path

A bit like SDKMan, _yem_ supports to initialize an environment from a file but with some differences.

The file must be a `properties` file.
Each tool/distribution setup has several properties:

[source,properties]
----
prefix.version = 1.2.3 <1>
prefix.provider = xxxx <2>
prefix.relaxed = [true|false] <3>
prefix.envVarName = xxxx <4>
prefix.addToPath = [true|false] <5>
prefix.failOnMissing = [true|false] <6>
prefix.installIfMissing = [true|false] <7>
prefix.toolName = 1.2.3 <8>
----
<.> Version of the tool to install, using `relaxed` option it can be a version prefix (`21.` for ex),
<.> Provider to use to resolve the tool, if you want to force `zulu` provider instead of using SDKMan to install Java versions for example,
<.> Should version be matched exactly or the first matching one be used,
<.> When `addToPath` is `true` (default) the environment name to setup for this tool - deduced from tool name otherwise, generally `uppercase(tool)_HOME` with dot replaced by underscores,
<.> Should the `PATH` be set too - note that when it is the case `YEM_ORIGINAL_PATH` is set too allowing to reset `PATH` when exiting the folder,
<.> Should the execution fail if a tool is missing (mainly for debug purposes),
<.> Should tools be installed automatically when missing - CI friendly,
<.> If your prefix does not match the tool name, the tool name to use.

Only the `version` property is required of `prefix` matches a tool name.
You can get as much group of properties as needed tools (one for java 11, one for java 17, one for maven 4 etc...).

== Alias support

The `run` command supports aliases.
They globally use a `.yemrc` file as for `env` command but support additional properties.

These additional properties must match the pattern `xxx.alias = yyyy` where `xxx` is an alias name and `yyyy` a command.
The usage of `yem run -- xxxx` will be equivalent to run `yyyy` command (can have arguments predefined) in the context of the `.yemrc` file, including the environment - Java, Apache Maven etc...

== TIP

If you need to see more logs from _yem_ you can add the following system properties: `-Djava.util.logging.manager=io.yupiik.logging.jul.YupiikLogManager -Dio.yupiik.logging.jul.handler.StandardHandler.level=FINEST -Dio.yupiik.level=FINEST`.

You can also force some default configuration (typically central `gavs` or `offlineMode`) in `~/.yupiik/yem/rc`.
If you don't want this global file to be taken into account temporarly (or not) you can set the environment variable `YEM_DISABLE_GLOBAL_RC_FILE` to `true`.

== Shell/Bash setup

Yem is portable but we detail there only shell setup.

The idea is to leverage `env` command.
Add to your global `~/.bashrc` (or `~/.profile`) configuration the following line:

[source,bash]
----
yem_env() {
eval $(yem env)
}
if [[ -n "$ZSH_VERSION" ]]; then
chpwd_functions+=(yem_env)
else
trimmed_prompt_command="${PROMPT_COMMAND%"${PROMPT_COMMAND##*[![:space:]]}"}"
[[ -z "$trimmed_prompt_command" ]] && PROMPT_COMMAND="yem_env" || PROMPT_COMMAND="${trimmed_prompt_command%\;};yem_env"
fi
yem_env
----

--
TIP: if you don't use zsh shell you can simplify it:

[source,bash]
----
yem_env() {
eval $(yem env)
}
trimmed_prompt_command="${PROMPT_COMMAND%"${PROMPT_COMMAND##*[![:space:]]}"}"
[[ -z "$trimmed_prompt_command" ]] && PROMPT_COMMAND="yem_env" || PROMPT_COMMAND="${trimmed_prompt_command%\;};yem_env"
yem_env
----
--

TIP: it is also recommended to set some default versions in `~/.yupiik/yem/rc`
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ public void visitText(final Text element) {
final boolean parentNeedsP = state.lastElement.size() > 1 && isList(state.lastElement.get(state.lastElement.size() - 2).type());
final boolean wrap = useWrappers &&
(parentNeedsP || (element.style().size() != 1 && (isParagraph || state.inCallOut || !element.options().isEmpty())));
final boolean useP = parentNeedsP || isParagraph || state.inCallOut;
final boolean useP = parentNeedsP || isParagraph || !state.inCallOut;
if (wrap) {
builder.append(" <").append(useP ? "p" : "span");
writeCommonAttributes(element.options(), null);
Expand Down Expand Up @@ -594,10 +594,13 @@ public void visitCode(final Code element) {
builder.append(" <div class=\"colist arabic\">\n");
builder.append(" <ol>\n");
element.callOuts().forEach(c -> {
final boolean nowrap = state.nowrap;
builder.append(" <li>\n");
state.inCallOut = true;
state.nowrap = true;
visitElement(c.text());
state.inCallOut = false;
state.nowrap = nowrap;
builder.append(" </li>\n");
});
builder.append(" </ol>\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -576,8 +576,42 @@ void codeInSectionTitleComplex() {
void linkWithImage() {
assertRenderingContent(
"link:http://foo.bar[this is image:foo.png[alt]]",
" <a href=\"http://foo.bar\">this is <img src=\"foo.png\" alt=\"alt\">\n" +
"</a>\n");
"""
<a href="http://foo.bar">this is <img src="foo.png" alt="alt">
</a>
""");
}

@Test
void callouts() {
assertRenderingContent("""
[source,properties]
----
prefix.version = 1.2.3 <1>
----
<.> Version of the tool to install, using `relaxed` option it can be a version prefix (`21.` for ex),""",
"""
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-properties hljs" data-lang="properties">prefix.version = 1.2.3 <b class="conum">(1)</b></code></pre>
</div>
</div>
<div class="colist arabic">
<ol>
<li>
<span>
Version of the tool to install, using\s
</span>
<code>relaxed</code> <span>
option it can be a version prefix (
</span>
<code>21.</code> <span>
for ex),
</span>
</li>
</ol>
</div>
""");
}

private void assertRendering(final String adoc, final String html) {
Expand Down