Bug 6003: Create config-filtering-parent 27/39427/7
authorVratko Polak <vrpolak@cisco.com>
Tue, 23 Aug 2016 17:14:09 +0000 (19:14 +0200)
committerVratko Polak <vrpolak@cisco.com>
Thu, 22 Sep 2016 07:54:22 +0000 (09:54 +0200)
The Bug requests an addition of resource filtering functionality to config-parent.
There are several issues with replacing config-parent functionality:
- It is a top-level non-karaf feature, subject to API freeze.
- maven-resource-plugin operates on directories (as opposed to files).
- Users (ODL or otherwise) may change config.file value.
+ Groovy script can be used to extract directory name...
- but it is not easy propagate computed values to sibling plugins.
  http://stackoverflow.com/questions/21867095/setting-properties-in-maven-with-gmaven
- Using two profiles in config-parent does not work easily
  http://stackoverflow.com/questions/1504850/maven-activate-child-profile-based-on-property
  (unless creation of temporary files in local filesystem is abused).

Therefore, a descendant parent pom is defined in this Change.
Presence of ${config.file} activates profiles in both config-parent and config-filtering-parent.

Small edits to config-plugin:
+ Add profile ID to distinguish filtering and non-filtering profiles.

Change-Id: Ia9ef770be232e04e4ba73f634a51b50665ee18ab
Signed-off-by: Vratko Polak <vrpolak@cisco.com>
opendaylight/config/config-filtering-parent/pom.xml [new file with mode: 0644]
opendaylight/config/config-parent/pom.xml
opendaylight/config/pom.xml

diff --git a/opendaylight/config/config-filtering-parent/pom.xml b/opendaylight/config/config-filtering-parent/pom.xml
new file mode 100644 (file)
index 0000000..7a88ed0
--- /dev/null
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+
+This program and the accompanying materials are made available under the
+terms of the Eclipse Public License v1.0 which accompanies this distribution,
+and is available at http://www.eclipse.org/legal/epl-v10.html
+-->
+<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>
+    <groupId>org.opendaylight.controller</groupId>
+    <artifactId>config-parent</artifactId>
+    <version>0.6.0-SNAPSHOT</version>
+    <relativePath>../config-parent</relativePath>
+  </parent>
+
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.opendaylight.controller</groupId>
+  <artifactId>config-filtering-parent</artifactId>
+  <packaging>pom</packaging>
+
+  <properties>
+    <config.dir>src/main/config</config.dir>
+    <config.filename>default-config.xml</config.filename>
+    <config.file>${config.dir}/${config.filename}</config.file>
+    <generated.config.dir>target/generated-config</generated.config.dir>
+    <generated.config.file>${generated.config.dir}/${config.filename}</generated.config.file>
+  </properties>
+
+  <profiles>
+    <profile>
+      <id>apply-filtering-before-attaching-config</id>
+      <activation>
+        <file>
+          <exists>${config.file}</exists>
+        </file>
+      </activation>
+      <build>
+        <pluginManagement>
+          <plugins>
+            <plugin>
+              <artifactId>maven-resources-plugin</artifactId>
+              <executions>
+                <execution>
+                  <id>copy-resources</id>
+                  <phase>validate</phase>
+                  <goals>
+                    <goal>copy-resources</goal>
+                  </goals>
+                  <configuration>
+                    <outputDirectory>${generated.config.dir}</outputDirectory>
+                    <resources>
+                      <resource>
+                        <directory>${config.dir}</directory>
+                        <filtering>true</filtering>
+                      </resource>
+                    </resources>
+                  </configuration>
+                </execution>
+              </executions>
+            </plugin>
+            <plugin>
+              <groupId>org.codehaus.mojo</groupId>
+              <artifactId>build-helper-maven-plugin</artifactId>
+              <executions>
+                <execution>
+                  <id>attach-artifacts</id>
+                  <goals>
+                    <goal>attach-artifact</goal>
+                  </goals>
+                  <phase>package</phase>
+                  <configuration>
+                    <artifacts>
+                      <artifact>
+                        <file>${generated.config.file}</file>
+                        <type>xml</type>
+                        <classifier>config</classifier>
+                      </artifact>
+                    </artifacts>
+                  </configuration>
+                </execution>
+              </executions>
+            </plugin>
+          </plugins>
+        </pluginManagement>
+        <plugins>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-resources-plugin</artifactId>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+  </profiles>
+</project>
index d246872..87e3dcf 100644 (file)
@@ -177,6 +177,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
   </build>
   <profiles>
     <profile>
+      <id>attach-config-without-filtering</id>
       <activation>
         <file>
           <exists>${config.file}</exists>
index bb7e56c..4ff1516 100644 (file)
@@ -42,6 +42,7 @@
 
     <module>config-artifacts</module>
     <module>config-parent</module>
+    <module>config-filtering-parent</module>
     <module>config-persister-impl</module>
     <module>config-it-base</module>
   </modules>

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.