This is an automated email from the ASF dual-hosted git repository. cstamas pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven-resolver.git
The following commit(s) were added to refs/heads/master by this push: new 8f84876b [MRESOLVER-623] Merge and deploy docgen (#591) 8f84876b is described below commit 8f84876b45ffe7ea39bd615d222fb7a03ccb9fa5 Author: Tamas Cservenak <ta...@cservenak.net> AuthorDate: Fri Oct 25 09:27:31 2024 +0200 [MRESOLVER-623] Merge and deploy docgen (#591) And make it support both, maven and resolver. Also, deploy the collected properties. --- https://issues.apache.org/jira/browse/MRESOLVER-623 https://issues.apache.org/jira/browse/MRESOLVER-613 --- maven-resolver-tools/pom.xml | 77 +++- .../eclipse/aether/tools/CollectConfiguration.java | 426 +++++++++++++-------- .../resources/{page.vm => configuration.md.vm} | 6 +- .../{props.vm => configuration.properties.vm} | 2 + .../resources/{yaml.vm => configuration.yaml.vm} | 2 + pom.xml | 11 + src/site/markdown/configuration.md | 1 - 7 files changed, 347 insertions(+), 178 deletions(-) diff --git a/maven-resolver-tools/pom.xml b/maven-resolver-tools/pom.xml index 67a176e3..85725fb6 100644 --- a/maven-resolver-tools/pom.xml +++ b/maven-resolver-tools/pom.xml @@ -33,7 +33,6 @@ <properties> <javaVersion>17</javaVersion> - <maven.deploy.skip>true</maven.deploy.skip> </properties> <dependencies> @@ -41,68 +40,84 @@ <dependency> <groupId>org.apache.maven.resolver</groupId> <artifactId>maven-resolver-api</artifactId> + <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.maven.resolver</groupId> <artifactId>maven-resolver-spi</artifactId> + <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.maven.resolver</groupId> <artifactId>maven-resolver-util</artifactId> + <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.maven.resolver</groupId> <artifactId>maven-resolver-impl</artifactId> + <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.maven.resolver</groupId> <artifactId>maven-resolver-named-locks</artifactId> + <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.maven.resolver</groupId> <artifactId>maven-resolver-named-locks-hazelcast</artifactId> + <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.maven.resolver</groupId> <artifactId>maven-resolver-named-locks-redisson</artifactId> + <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.maven.resolver</groupId> <artifactId>maven-resolver-connector-basic</artifactId> + <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.maven.resolver</groupId> <artifactId>maven-resolver-transport-apache</artifactId> + <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.maven.resolver</groupId> <artifactId>maven-resolver-transport-classpath</artifactId> + <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.maven.resolver</groupId> <artifactId>maven-resolver-transport-file</artifactId> + <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.maven.resolver</groupId> <artifactId>maven-resolver-transport-jdk</artifactId> + <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.maven.resolver</groupId> <artifactId>maven-resolver-transport-jetty</artifactId> + <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.maven.resolver</groupId> <artifactId>maven-resolver-transport-wagon</artifactId> + <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.maven.resolver</groupId> <artifactId>maven-resolver-generator-gnupg</artifactId> + <scope>provided</scope> </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> + <groupId>org.apache.maven.resolver</groupId> + <artifactId>maven-resolver-generator-sigstore</artifactId> + <scope>provided</scope> </dependency> + <dependency> <groupId>org.jboss.forge.roaster</groupId> <artifactId>roaster-api</artifactId> @@ -113,24 +128,42 @@ <artifactId>roaster-jdt</artifactId> <version>2.29.0.Final</version> </dependency> + <dependency> + <groupId>org.ow2.asm</groupId> + <artifactId>asm</artifactId> + <version>9.7.1</version> + </dependency> <dependency> <groupId>org.apache.velocity</groupId> <artifactId>velocity-engine-core</artifactId> <version>2.4.1</version> </dependency> - - <!-- Not needed during compile --> + <dependency> + <groupId>org.codehaus.plexus</groupId> + <artifactId>plexus-utils</artifactId> + </dependency> + <dependency> + <groupId>info.picocli</groupId> + <artifactId>picocli</artifactId> + <version>4.7.6</version> + </dependency> <dependency> <groupId>org.slf4j</groupId> - <artifactId>slf4j-simple</artifactId> - <scope>runtime</scope> + <artifactId>slf4j-api</artifactId> </dependency> + + <!-- Not needed during compile --> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>3.17.0</version> <scope>runtime</scope> </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-nop</artifactId> + <scope>runtime</scope> + </dependency> </dependencies> <build> @@ -149,10 +182,26 @@ <configuration> <mainClass>org.eclipse.aether.tools.CollectConfiguration</mainClass> <arguments> + <argument>--mode=resolver</argument> + <argument>--templates=configuration.md</argument> + <argument>${basedir}/..</argument> + <argument>${basedir}/../src/site/markdown/</argument> + </arguments> + </configuration> + </execution> + <execution> + <id>render-configuration-artifacts</id> + <goals> + <goal>java</goal> + </goals> + <phase>verify</phase> + <configuration> + <mainClass>org.eclipse.aether.tools.CollectConfiguration</mainClass> + <arguments> + <argument>--mode=resolver</argument> + <argument>--templates=configuration.properties,configuration.yaml</argument> <argument>${basedir}/..</argument> - <argument>${basedir}/../src/site/markdown/configuration.md</argument> - <argument>${basedir}/target/maven-resolver.properties</argument> - <argument>${basedir}/target/maven-resolver.yaml</argument> + <argument>${basedir}/target/</argument> </arguments> </configuration> </execution> @@ -164,7 +213,7 @@ <version>3.6.0</version> <executions> <execution> - <id>attach</id> + <id>attach-configuration-artifacts</id> <goals> <goal>attach-artifact</goal> </goals> @@ -173,11 +222,11 @@ <artifacts> <artifact> <type>properties</type> - <file>${basedir}/target/maven-resolver.properties</file> + <file>${basedir}/target/configuration.properties</file> </artifact> <artifact> <type>yaml</type> - <file>${basedir}/target/maven-resolver.yaml</file> + <file>${basedir}/target/configuration.yaml</file> </artifact> </artifacts> </configuration> diff --git a/maven-resolver-tools/src/main/java/org/eclipse/aether/tools/CollectConfiguration.java b/maven-resolver-tools/src/main/java/org/eclipse/aether/tools/CollectConfiguration.java index 746e17cd..f6d73415 100644 --- a/maven-resolver-tools/src/main/java/org/eclipse/aether/tools/CollectConfiguration.java +++ b/maven-resolver-tools/src/main/java/org/eclipse/aether/tools/CollectConfiguration.java @@ -18,115 +18,291 @@ */ package org.eclipse.aether.tools; -import java.io.BufferedWriter; import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; import java.io.UncheckedIOException; +import java.io.Writer; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Properties; -import java.util.TreeMap; +import java.util.concurrent.Callable; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.spi.ToolProvider; +import java.util.stream.Stream; import org.apache.velocity.VelocityContext; import org.apache.velocity.app.VelocityEngine; import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader; +import org.codehaus.plexus.util.io.CachingWriter; import org.jboss.forge.roaster.Roaster; +import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.AST; +import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.ASTNode; +import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.Javadoc; import org.jboss.forge.roaster.model.JavaDoc; import org.jboss.forge.roaster.model.JavaDocCapable; import org.jboss.forge.roaster.model.JavaDocTag; import org.jboss.forge.roaster.model.JavaType; +import org.jboss.forge.roaster.model.impl.JavaDocImpl; import org.jboss.forge.roaster.model.source.FieldSource; import org.jboss.forge.roaster.model.source.JavaClassSource; +import org.jboss.forge.roaster.model.source.JavaDocSource; +import org.objectweb.asm.AnnotationVisitor; +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassVisitor; +import org.objectweb.asm.FieldVisitor; +import org.objectweb.asm.Opcodes; +import picocli.CommandLine; -public class CollectConfiguration { - public static void main(String[] args) throws Exception { - Path start = Paths.get(args.length > 0 ? args[0] : "."); - Path output = Paths.get(args.length > 1 ? args[1] : "output"); - Path props = Paths.get(args.length > 2 ? args[2] : "props"); - Path yaml = Paths.get(args.length > 3 ? args[3] : "yaml"); - - TreeMap<String, ConfigurationKey> discoveredKeys = new TreeMap<>(); - Files.walk(start) - .map(Path::toAbsolutePath) - .filter(p -> p.getFileName().toString().endsWith(".java")) - .filter(p -> p.toString().contains("/src/main/java/")) - .filter(p -> !p.toString().endsWith("/module-info.java")) - .forEach(p -> { - JavaType<?> type = parse(p); - if (type instanceof JavaClassSource javaClassSource) { - javaClassSource.getFields().stream() - .filter(CollectConfiguration::hasConfigurationSource) - .forEach(f -> { - Map<String, String> constants = extractConstants(Paths.get(p.toString() - .replace("/src/main/java/", "/target/classes/") - .replace(".java", ".class"))); - - String name = f.getName(); - String key = constants.get(name); - String fqName = f.getOrigin().getCanonicalName() + "." + name; - String configurationType = getConfigurationType(f); - String defValue = getTag(f, "@configurationDefaultValue"); - if (defValue != null && defValue.startsWith("{@link #") && defValue.endsWith("}")) { - // constant "lookup" - String lookupValue = - constants.get(defValue.substring(8, defValue.length() - 1)); - if (lookupValue == null) { - // currently we hard fail if javadoc cannot be looked up - // workaround: at cost of redundancy, but declare constants in situ for now - // (in same class) - throw new IllegalArgumentException( - "Could not look up " + defValue + " for configuration " + fqName); - } - defValue = lookupValue; - } - if ("java.lang.Long".equals(configurationType) - && (defValue.endsWith("l") || defValue.endsWith("L"))) { - defValue = defValue.substring(0, defValue.length() - 1); - } - discoveredKeys.put( - key, - new ConfigurationKey( - key, - defValue, - fqName, - cleanseJavadoc(f), - nvl(getSince(f), ""), - getConfigurationSource(f), - configurationType, - toBoolean(getTag(f, "@configurationRepoIdSuffix")))); - }); - } - }); - - VelocityEngine velocityEngine = new VelocityEngine(); - Properties properties = new Properties(); - properties.setProperty("resource.loaders", "classpath"); - properties.setProperty("resource.loader.classpath.class", ClasspathResourceLoader.class.getName()); - velocityEngine.init(properties); - - VelocityContext context = new VelocityContext(); - context.put("keys", discoveredKeys.values()); - - try (BufferedWriter fileWriter = Files.newBufferedWriter(output)) { - velocityEngine.getTemplate("page.vm").merge(context, fileWriter); +@CommandLine.Command(name = "docgen", description = "Maven Documentation Generator") +public class CollectConfiguration implements Callable<Integer> { + public static void main(String[] args) { + new CommandLine(new CollectConfiguration()).execute(args); + } + + protected static final String KEY = "key"; + + enum Mode { + maven, + resolver + } + + @CommandLine.Option( + names = {"-m", "--mode"}, + arity = "1", + paramLabel = "mode", + description = "The mode of generator (what is being scanned?), supported modes are 'maven', 'resolver'") + protected Mode mode; + + @CommandLine.Option( + names = {"-t", "--templates"}, + arity = "1", + split = ",", + paramLabel = "template", + description = "The template names to write content out without '.vm' extension") + protected List<String> templates; + + @CommandLine.Parameters(index = "0", description = "The root directory to process sources from") + protected Path rootDirectory; + + @CommandLine.Parameters(index = "1", description = "The directory to generate output(s) to") + protected Path outputDirectory; + + @Override + public Integer call() { + try { + rootDirectory = rootDirectory.toAbsolutePath().normalize(); + outputDirectory = outputDirectory.toAbsolutePath().normalize(); + + ArrayList<Map<String, String>> discoveredKeys = new ArrayList<>(); + try (Stream<Path> stream = Files.walk(rootDirectory)) { + if (mode == Mode.maven) { + System.out.println("Processing Maven sources from " + rootDirectory); + stream.map(Path::toAbsolutePath) + .filter(p -> p.getFileName().toString().endsWith(".class")) + .filter(p -> p.toString().contains("/target/classes/")) + .forEach(p -> { + processMavenClass(p, discoveredKeys); + }); + } else if (mode == Mode.resolver) { + System.out.println("Processing Resolver sources from " + rootDirectory); + stream.map(Path::toAbsolutePath) + .filter(p -> p.getFileName().toString().endsWith(".java")) + .filter(p -> p.toString().contains("/src/main/java/")) + .filter(p -> !p.toString().endsWith("/module-info.java")) + .forEach(p -> processResolverClass(p, discoveredKeys)); + } else { + throw new IllegalStateException("Unsupported mode " + mode); + } + } + + Collections.sort(discoveredKeys, Comparator.comparing(e -> e.get(KEY))); + + Properties properties = new Properties(); + properties.setProperty("resource.loaders", "classpath"); + properties.setProperty("resource.loader.classpath.class", ClasspathResourceLoader.class.getName()); + VelocityEngine velocityEngine = new VelocityEngine(); + velocityEngine.init(properties); + + VelocityContext context = new VelocityContext(); + context.put("keys", discoveredKeys); + + for (String template : templates) { + Path output = outputDirectory.resolve(template); + System.out.println("Writing out to " + output); + try (Writer fileWriter = new CachingWriter(output, StandardCharsets.UTF_8)) { + velocityEngine.getTemplate(template + ".vm").merge(context, fileWriter); + } + } + return 0; + } catch (Exception e) { + e.printStackTrace(System.err); + return 1; } - try (BufferedWriter fileWriter = Files.newBufferedWriter(props)) { - velocityEngine.getTemplate("props.vm").merge(context, fileWriter); + } + + protected void processMavenClass(Path path, List<Map<String, String>> discoveredKeys) { + try { + ClassReader classReader = new ClassReader(Files.newInputStream(path)); + classReader.accept( + new ClassVisitor(Opcodes.ASM9) { + @Override + public FieldVisitor visitField( + int fieldAccess, + String fieldName, + String fieldDescriptor, + String fieldSignature, + Object fieldValue) { + return new FieldVisitor(Opcodes.ASM9) { + @Override + public AnnotationVisitor visitAnnotation( + String annotationDescriptor, boolean annotationVisible) { + if (annotationDescriptor.equals("Lorg/apache/maven/api/annotations/Config;")) { + return new AnnotationVisitor(Opcodes.ASM9) { + final Map<String, Object> values = new HashMap<>(); + + @Override + public void visit(String name, Object value) { + values.put(name, value); + } + + @Override + public void visitEnum(String name, String descriptor, String value) { + values.put(name, value); + } + + @Override + public void visitEnd() { + JavaType<?> jtype = parse(Paths.get(path.toString() + .replace("/target/classes/", "/src/main/java/") + .replace(".class", ".java"))); + FieldSource<JavaClassSource> f = + ((JavaClassSource) jtype).getField(fieldName); + + String fqName = null; + String desc = cloneJavadoc(f.getJavaDoc()) + .removeAllTags() + .getFullText() + .replace("*", "\\*"); + String since = getSince(f); + String source = + switch ((values.get("source") != null + ? (String) values.get("source") + : "USER_PROPERTIES") // TODO: enum + .toLowerCase()) { + case "model" -> "Model properties"; + case "user_properties" -> "User properties"; + default -> throw new IllegalStateException(); + }; + String type = + switch ((values.get("type") != null + ? (String) values.get("type") + : "java.lang.String")) { + case "java.lang.String" -> "String"; + case "java.lang.Integer" -> "Integer"; + case "java.lang.Boolean" -> "Boolean"; + default -> throw new IllegalStateException(); + }; + discoveredKeys.add(Map.of( + KEY, + fieldValue.toString(), + "defaultValue", + values.get("defaultValue") != null + ? values.get("defaultValue") + .toString() + : "", + "fqName", + nvl(fqName, ""), + "description", + desc, + "since", + nvl(since, ""), + "configurationSource", + source, + "configurationType", + type)); + } + }; + } + return null; + } + }; + } + }, + 0); + } catch (IOException e) { + throw new RuntimeException(e); } - try (BufferedWriter fileWriter = Files.newBufferedWriter(yaml)) { - velocityEngine.getTemplate("yaml.vm").merge(context, fileWriter); + } + + protected void processResolverClass(Path path, List<Map<String, String>> discoveredKeys) { + JavaType<?> type = parse(path); + if (type instanceof JavaClassSource javaClassSource) { + javaClassSource.getFields().stream() + .filter(this::hasConfigurationSource) + .forEach(f -> { + Map<String, String> constants = extractConstants(Paths.get(path.toString() + .replace("/src/main/java/", "/target/classes/") + .replace(".java", ".class"))); + + String name = f.getName(); + String key = constants.get(name); + String fqName = f.getOrigin().getCanonicalName() + "." + name; + String configurationType = getConfigurationType(f); + String defValue = getTag(f, "@configurationDefaultValue"); + if (defValue != null && defValue.startsWith("{@link #") && defValue.endsWith("}")) { + // constant "lookup" + String lookupValue = constants.get(defValue.substring(8, defValue.length() - 1)); + if (lookupValue == null) { + // currently we hard fail if javadoc cannot be looked up + // workaround: at cost of redundancy, but declare constants in situ for now + // (in same class) + throw new IllegalArgumentException( + "Could not look up " + defValue + " for configuration " + fqName); + } + defValue = lookupValue; + if ("java.lang.Long".equals(configurationType) + && (defValue.endsWith("l") || defValue.endsWith("L"))) { + defValue = defValue.substring(0, defValue.length() - 1); + } + } + discoveredKeys.add(Map.of( + KEY, + key, + "defaultValue", + nvl(defValue, ""), + "fqName", + fqName, + "description", + cleanseJavadoc(f), + "since", + nvl(getSince(f), ""), + "configurationSource", + getConfigurationSource(f), + "configurationType", + configurationType, + "supportRepoIdSuffix", + toYesNo(getTag(f, "@configurationRepoIdSuffix")))); + }); } } - private static String cleanseJavadoc(FieldSource<JavaClassSource> javaClassSource) { + protected JavaDocSource<Object> cloneJavadoc(JavaDocSource<?> javaDoc) { + Javadoc jd = (Javadoc) javaDoc.getInternal(); + return new JavaDocImpl<>(javaDoc.getOrigin(), (Javadoc) + ASTNode.copySubtree(AST.newAST(jd.getAST().apiLevel(), false), jd)); + } + + protected String cleanseJavadoc(FieldSource<JavaClassSource> javaClassSource) { JavaDoc<FieldSource<JavaClassSource>> javaDoc = javaClassSource.getJavaDoc(); String[] text = javaDoc.getFullText().split("\n"); StringBuilder result = new StringBuilder(); @@ -138,7 +314,7 @@ public class CollectConfiguration { return cleanseTags(result.toString()); } - private static String cleanseTags(String text) { + protected String cleanseTags(String text) { // {@code XXX} -> <pre>XXX</pre> // {@link XXX} -> ??? pre for now Pattern pattern = Pattern.compile("(\\{@\\w\\w\\w\\w (.+?)})"); @@ -159,7 +335,7 @@ public class CollectConfiguration { return result.toString(); } - private static JavaType<?> parse(Path path) { + protected JavaType<?> parse(Path path) { try { return Roaster.parse(path.toFile()); } catch (IOException e) { @@ -167,85 +343,19 @@ public class CollectConfiguration { } } - private static boolean toBoolean(String value) { - return ("yes".equalsIgnoreCase(value) || "true".equalsIgnoreCase(value)); - } - - /** - * Would be record, but... Velocity have no idea what it is nor how to handle it. - */ - public static class ConfigurationKey { - private final String key; - private final String defaultValue; - private final String fqName; - private final String description; - private final String since; - private final String configurationSource; - private final String configurationType; - private final boolean supportRepoIdSuffix; - - @SuppressWarnings("checkstyle:parameternumber") - public ConfigurationKey( - String key, - String defaultValue, - String fqName, - String description, - String since, - String configurationSource, - String configurationType, - boolean supportRepoIdSuffix) { - this.key = key; - this.defaultValue = defaultValue; - this.fqName = fqName; - this.description = description; - this.since = since; - this.configurationSource = configurationSource; - this.configurationType = configurationType; - this.supportRepoIdSuffix = supportRepoIdSuffix; - } - - public String getKey() { - return key; - } - - public String getDefaultValue() { - return defaultValue; - } - - public String getFqName() { - return fqName; - } - - public String getDescription() { - return description; - } - - public String getSince() { - return since; - } - - public String getConfigurationSource() { - return configurationSource; - } - - public String getConfigurationType() { - return configurationType; - } - - public boolean isSupportRepoIdSuffix() { - return supportRepoIdSuffix; - } + protected String toYesNo(String value) { + return "yes".equalsIgnoreCase(value) || "true".equalsIgnoreCase(value) ? "Yes" : "No"; } - private static String nvl(String string, String def) { + protected String nvl(String string, String def) { return string == null ? def : string; } - private static boolean hasConfigurationSource(JavaDocCapable<?> javaDocCapable) { + protected boolean hasConfigurationSource(JavaDocCapable<?> javaDocCapable) { return getTag(javaDocCapable, "@configurationSource") != null; } - private static String getConfigurationType(JavaDocCapable<?> javaDocCapable) { + protected String getConfigurationType(JavaDocCapable<?> javaDocCapable) { String type = getTag(javaDocCapable, "@configurationType"); if (type != null) { String linkPrefix = "{@link "; @@ -261,7 +371,7 @@ public class CollectConfiguration { return nvl(type, "n/a"); } - private static String getConfigurationSource(JavaDocCapable<?> javaDocCapable) { + protected String getConfigurationSource(JavaDocCapable<?> javaDocCapable) { String source = getTag(javaDocCapable, "@configurationSource"); if ("{@link RepositorySystemSession#getConfigProperties()}".equals(source)) { return "Session Configuration"; @@ -272,7 +382,7 @@ public class CollectConfiguration { } } - private static String getSince(JavaDocCapable<?> javaDocCapable) { + protected String getSince(JavaDocCapable<?> javaDocCapable) { List<JavaDocTag> tags; if (javaDocCapable != null) { if (javaDocCapable instanceof FieldSource<?> fieldSource) { @@ -292,7 +402,7 @@ public class CollectConfiguration { return null; } - private static String getTag(JavaDocCapable<?> javaDocCapable, String tagName) { + protected String getTag(JavaDocCapable<?> javaDocCapable, String tagName) { List<JavaDocTag> tags; if (javaDocCapable != null) { if (javaDocCapable instanceof FieldSource<?> fieldSource) { @@ -307,19 +417,19 @@ public class CollectConfiguration { return null; } - private static final Pattern CONSTANT_PATTERN = Pattern.compile(".*static final.* ([A-Z_]+) = (.*);"); + protected static final Pattern CONSTANT_PATTERN = Pattern.compile(".*static final.* ([A-Z_]+) = (.*);"); - private static final ToolProvider JAVAP = ToolProvider.findFirst("javap").orElseThrow(); + protected static final ToolProvider JAVAP = ToolProvider.findFirst("javap").orElseThrow(); /** * Builds "constant table" for one single class. - * + * <p> * Limitations: * - works only for single class (no inherited constants) * - does not work for fields that are Enum.name() * - more to come */ - private static Map<String, String> extractConstants(Path file) { + protected static Map<String, String> extractConstants(Path file) { StringWriter out = new StringWriter(); JAVAP.run(new PrintWriter(out), new PrintWriter(System.err), "-constants", file.toString()); Map<String, String> result = new HashMap<>(); diff --git a/maven-resolver-tools/src/main/resources/page.vm b/maven-resolver-tools/src/main/resources/configuration.md.vm similarity index 95% rename from maven-resolver-tools/src/main/resources/page.vm rename to maven-resolver-tools/src/main/resources/configuration.md.vm index 46c565de..60e6e811 100644 --- a/maven-resolver-tools/src/main/resources/page.vm +++ b/maven-resolver-tools/src/main/resources/configuration.md.vm @@ -39,10 +39,6 @@ under the License. ]]# -#macro(yesno $val) - #if ($val) Yes #else No #end -#end - #macro(value $val) #if ($val) `$val` #else - #end #end @@ -50,7 +46,7 @@ under the License. | No | Key | Type | Description | Default Value | Since | Supports Repo ID suffix | Source | | --- | --- | --- | --- | --- | --- | --- | --- | #foreach($key in $keys) -| $foreach.count. | `$key.key` | `$key.configurationType` | $key.description | #value( $key.defaultValue ) | $key.since | #yesno( $key.supportRepoIdSuffix ) | $key.configurationSource | +| $foreach.count. | `$key.key` | `$key.configurationType` | $key.description | #value( $key.defaultValue ) | $key.since | $key.supportRepoIdSuffix | $key.configurationSource | #end #[[ diff --git a/maven-resolver-tools/src/main/resources/props.vm b/maven-resolver-tools/src/main/resources/configuration.properties.vm similarity index 98% rename from maven-resolver-tools/src/main/resources/props.vm rename to maven-resolver-tools/src/main/resources/configuration.properties.vm index dfa5a2b1..33f2a553 100644 --- a/maven-resolver-tools/src/main/resources/props.vm +++ b/maven-resolver-tools/src/main/resources/configuration.properties.vm @@ -43,6 +43,8 @@ props.${foreach.count}.defaultValue = ${key.defaultValue} #if( !${key.since.empty} ) props.${foreach.count}.since = ${key.since} #end +#if(${key.supportRepoIdSuffix}) props.${foreach.count}.supportRepoIdSuffix = ${key.supportRepoIdSuffix} +#end props.${foreach.count}.configurationSource = ${key.configurationSource} #end diff --git a/maven-resolver-tools/src/main/resources/yaml.vm b/maven-resolver-tools/src/main/resources/configuration.yaml.vm similarity index 97% rename from maven-resolver-tools/src/main/resources/yaml.vm rename to maven-resolver-tools/src/main/resources/configuration.yaml.vm index 6c97d872..07933068 100644 --- a/maven-resolver-tools/src/main/resources/yaml.vm +++ b/maven-resolver-tools/src/main/resources/configuration.yaml.vm @@ -43,6 +43,8 @@ props: #if( !${key.since.empty} ) since: ${key.since} #end + #if(${key.supportRepoIdSuffix}) supportRepoIdSuffix: ${key.supportRepoIdSuffix} + #end configurationSource: ${key.configurationSource} #end diff --git a/pom.xml b/pom.xml index f325acee..ce36f439 100644 --- a/pom.xml +++ b/pom.xml @@ -201,6 +201,11 @@ <artifactId>maven-resolver-generator-gnupg</artifactId> <version>${project.version}</version> </dependency> + <dependency> + <groupId>org.apache.maven.resolver</groupId> + <artifactId>maven-resolver-generator-sigstore</artifactId> + <version>${project.version}</version> + </dependency> <dependency> <groupId>org.apache.maven.resolver</groupId> <artifactId>maven-resolver-supplier-mvn3</artifactId> @@ -291,6 +296,12 @@ <version>${slf4jVersion}</version> <scope>test</scope> </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-nop</artifactId> + <version>${slf4jVersion}</version> + <scope>test</scope> + </dependency> <dependency> <groupId>com.google.jimfs</groupId> diff --git a/src/site/markdown/configuration.md b/src/site/markdown/configuration.md index 8ca725dc..13c94a97 100644 --- a/src/site/markdown/configuration.md +++ b/src/site/markdown/configuration.md @@ -22,7 +22,6 @@ under the License. - | No | Key | Type | Description | Default Value | Since | Supports Repo ID suffix | Source | | --- | --- | --- | --- | --- | --- | --- | --- | | 1. | `"aether.artifactResolver.postProcessor.trustedChecksums"` | `Boolean` | Is post processor enabled. | `false` | 1.9.0 | No | Session Configuration |