servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r1089368 - /servicemix/scripts/find_unused_properties.rb
Date Wed, 06 Apr 2011 09:16:21 GMT
Author: gertv
Date: Wed Apr  6 09:16:20 2011
New Revision: 1089368

URL: http://svn.apache.org/viewvc?rev=1089368&view=rev
Log:
Keeping the script around for future reference/use - thanks to Joris Schoolmeesters for sharing
it

Added:
    servicemix/scripts/find_unused_properties.rb

Added: servicemix/scripts/find_unused_properties.rb
URL: http://svn.apache.org/viewvc/servicemix/scripts/find_unused_properties.rb?rev=1089368&view=auto
==============================================================================
--- servicemix/scripts/find_unused_properties.rb (added)
+++ servicemix/scripts/find_unused_properties.rb Wed Apr  6 09:16:20 2011
@@ -0,0 +1,94 @@
+#!/usr/bin/ruby
+
+=begin
+========================================================================
+
+  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.
+
+========================================================================
+=end
+
+
+require 'rexml/document'
+include REXML
+
+file = File.new(ARGV[0])
+dir = File.dirname(File.expand_path(ARGV[0]))
+puts dir
+
+doc = Document.new file
+
+properties = Array.new
+
+puts '-----------------------------------------------------------------------------BEGIN
SCANNING PARENT POM-----------------------------------------------------------------------'

+doc.root.each_element('/project/properties/*') {|version| properties << version.name}
+
+#omit these properties
+properties.delete('sonar.skippedModules')
+
+properties.each {|e| puts e}
+
+dependencies = Hash.new
+
+doc.root.each_element('//dependencies/dependency') {|dependency|
+            artifact = dependency.text("artifactId")
+            group = dependency.text("groupId")
+            dependencies["#{group}/#{artifact}"] = dependency.text("version")[2..-2] 
+}
+
+#dependencies.each {|x,y| puts "#{x} -> #{y}" }
+		
+puts '-----------------------------------------------------------------------------BEGIN
SCANNING RECURSIVE POMS-----------------------------------------------------------------------'
+Dir.chdir(dir)
+
+Dir.glob("**/pom.xml") {|pom| 
+	
+	next if pom =~ /target/
+
+	File.open("#{dir}/#{pom}").each { |line|
+    		line.sub(/\$\{.*\}/) { |found|
+      			properties.delete(found[2..-2])
+    		}
+	}
+
+#properties.each { |element| puts "... still looking for #{element}" }
+
+	doc = Document.new File.new(pom)
+	doc.root.each_element('//dependencies/dependency') {|dep|
+		artifact = dep.text("artifactId")
+ 	        group = dep.text("groupId")
+		description = artifact + "/" + group
+
+		if (dependencies.has_key?(description))
+			properties.delete(dependencies[description])
+		end
+	}
+
+}
+#properties.each { |element| puts "... still looking for #{element}" }
+
+puts '-----------------------------------------------------------------------------BEGIN
SCANNING SOURCE FILES-----------------------------------------------------------------------'
+Dir.glob("**/src/**/*.*") {|sourcefile|
+	next if sourcefile =~ /target/
+
+        File.open("#{dir}/#{sourcefile}").each { |line|
+                line.sub(/\$\{.*\}/) { |found|
+                        properties.delete(found[2..-2])
+                }
+	}
+} 
+properties.each { |element| puts "... still looking for #{element}" }
+



Mime
View raw message