Skip to content

Commit

Permalink
[MRESOLVER-604] Make config properties metadata available (#574)
Browse files Browse the repository at this point in the history
Make config properties metadata available

---

https://issues.apache.org/jira/browse/MRESOLVER-604
  • Loading branch information
gnodet authored Oct 12, 2024
1 parent 92b46ba commit 1200b9f
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 0 deletions.
28 changes: 28 additions & 0 deletions maven-resolver-tools/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,39 @@
<arguments>
<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>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.6.0</version>
<executions>
<execution>
<id>attach</id>
<goals>
<goal>attach-artifact</goal>
</goals>
<phase>verify</phase>
<configuration>
<artifacts>
<artifact>
<type>properties</type>
<file>${basedir}/target/maven-resolver.properties</file>
</artifact>
<artifact>
<type>yaml</type>
<file>${basedir}/target/maven-resolver.yaml</file>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, ConfigurationKey> discoveredKeys = new TreeMap<>();
Files.walk(start)
Expand Down Expand Up @@ -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) {
Expand Down
48 changes: 48 additions & 0 deletions maven-resolver-tools/src/main/resources/props.vm
Original file line number Diff line number Diff line change
@@ -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
48 changes: 48 additions & 0 deletions maven-resolver-tools/src/main/resources/yaml.vm
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 1200b9f

Please sign in to comment.