From 8ce89a920477dc18a4982bce28cf67a3381f0875 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Thu, 29 Aug 2024 16:35:40 +0200 Subject: [PATCH] Make config properties metadata available --- maven-resolver-tools/pom.xml | 28 +++++++++++ .../aether/tools/CollectConfiguration.java | 8 ++++ .../src/main/resources/props.vm | 48 +++++++++++++++++++ .../src/main/resources/yaml.vm | 48 +++++++++++++++++++ 4 files changed, 132 insertions(+) create mode 100644 maven-resolver-tools/src/main/resources/props.vm create mode 100644 maven-resolver-tools/src/main/resources/yaml.vm diff --git a/maven-resolver-tools/pom.xml b/maven-resolver-tools/pom.xml index f6aca1510..1b96ba1e4 100644 --- a/maven-resolver-tools/pom.xml +++ b/maven-resolver-tools/pom.xml @@ -151,11 +151,39 @@ ${basedir}/.. ${basedir}/../src/site/markdown/configuration.md + ${basedir}/target/maven-resolver.properties + ${basedir}/target/maven-resolver.yaml + + org.codehaus.mojo + build-helper-maven-plugin + 3.6.0 + + + attach + + attach-artifact + + verify + + + + properties + ${basedir}/target/maven-resolver.properties + + + yaml + ${basedir}/target/maven-resolver.yaml + + + + + + 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 bac0550a2..0cb75142a 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 @@ -49,6 +49,8 @@ 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 discoveredKeys = new TreeMap<>(); Files.walk(start) @@ -115,6 +117,12 @@ public static void main(String[] args) throws Exception { try (BufferedWriter fileWriter = Files.newBufferedWriter(output)) { velocityEngine.getTemplate("page.vm").merge(context, fileWriter); } + try (BufferedWriter fileWriter = Files.newBufferedWriter(props)) { + velocityEngine.getTemplate("props.vm").merge(context, fileWriter); + } + try (BufferedWriter fileWriter = Files.newBufferedWriter(yaml)) { + velocityEngine.getTemplate("yaml.vm").merge(context, fileWriter); + } } private static JavaType parse(Path path) { diff --git a/maven-resolver-tools/src/main/resources/props.vm b/maven-resolver-tools/src/main/resources/props.vm new file mode 100644 index 000000000..dfa5a2b1a --- /dev/null +++ b/maven-resolver-tools/src/main/resources/props.vm @@ -0,0 +1,48 @@ +## +## Licensed to the Apache Software Foundation (ASF) under one +## or more contributor license agreements. See the NOTICE file +## distributed with this work for additional information +## regarding copyright ownership. The ASF licenses this file +## to you 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. +## +#[[# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. +#]]# +props.count = ${keys.size()} +#foreach($key in $keys) +props.${foreach.count}.key = ${key.key} +props.${foreach.count}.configurationType = ${key.configurationType} +props.${foreach.count}.description = ${key.description} +props.${foreach.count}.defaultValue = ${key.defaultValue} +#if( !${key.since.empty} ) +props.${foreach.count}.since = ${key.since} +#end +props.${foreach.count}.supportRepoIdSuffix = ${key.supportRepoIdSuffix} +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/yaml.vm new file mode 100644 index 000000000..6c97d8722 --- /dev/null +++ b/maven-resolver-tools/src/main/resources/yaml.vm @@ -0,0 +1,48 @@ +## +## Licensed to the Apache Software Foundation (ASF) under one +## or more contributor license agreements. See the NOTICE file +## distributed with this work for additional information +## regarding copyright ownership. The ASF licenses this file +## to you 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. +## +#[[# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. +#]]# +props: + #foreach($key in $keys) + - key: ${key.key} + configurationType: ${key.configurationType} + description: "${key.description.replaceAll('"', '\\"')}" + defaultValue: ${key.defaultValue} + #if( !${key.since.empty} ) + since: ${key.since} + #end + supportRepoIdSuffix: ${key.supportRepoIdSuffix} + configurationSource: ${key.configurationSource} + #end