From 06d0f886e1b028e5a841709f3cb803eb5adfcaa3 Mon Sep 17 00:00:00 2001 From: Ryan Goulding Date: Fri, 23 Jun 2017 15:02:16 -0400 Subject: [PATCH 1/1] Bug 8739: Autogenerate date for yang in archetype A couple of lines to autogenerate the date based on the day that the archetype is run. The date is then formatted appropriately and used as the yang revision. This helps keep the yang data model writer honest. Change-Id: Ic885b71a777119702b3ce78a21623298c44ad9c1 Signed-off-by: Ryan Goulding --- .../api/src/main/yang/__artifactId__.yang | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/opendaylight/archetypes/opendaylight-startup/src/main/resources/archetype-resources/api/src/main/yang/__artifactId__.yang b/opendaylight/archetypes/opendaylight-startup/src/main/resources/archetype-resources/api/src/main/yang/__artifactId__.yang index e46446981c..a2e2108c3c 100644 --- a/opendaylight/archetypes/opendaylight-startup/src/main/resources/archetype-resources/api/src/main/yang/__artifactId__.yang +++ b/opendaylight/archetypes/opendaylight-startup/src/main/resources/archetype-resources/api/src/main/yang/__artifactId__.yang @@ -1,9 +1,12 @@ +#set( $ldt = $package.getClass().forName("java.time.LocalDateTime").getMethod("now").invoke(null) ) +#set( $dtf = $package.getClass().forName("java.time.format.DateTimeFormatter").getMethod("ofPattern", $package.getClass()).invoke(null, "yyyy-MM-dd") ) +#set( $date = $ldt.format($dtf) ) module ${artifactId} { yang-version 1; namespace "urn:opendaylight:params:xml:ns:yang:${artifactId}"; prefix "${artifactId}"; - revision "2015-01-05" { + revision "${date}" { description "Initial revision of ${artifactId} model"; } } -- 2.36.6