javaclass 0.0.4 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +18 -71
- data/Readme.txt +13 -22
- data/{example_task.rb → dev/example_task.rb} +1 -1
- data/dev/saikuro_task.rb +120 -0
- data/examples/chart_class_dependencies.rb +43 -0
- data/examples/chart_module_dependencies.rb +64 -0
- data/examples/check_interface_names.rb +3 -2
- data/examples/corpus.rb +52 -12
- data/examples/count_classes_in_modules.rb +2 -1
- data/examples/cumulative_dependencies.rb +4 -3
- data/examples/find_all_imported_types.rb +11 -7
- data/examples/find_incoming_dependency_graph.rb +81 -0
- data/examples/find_layers_of_modules.rb +79 -0
- data/examples/find_referenced_modules.rb +4 -6
- data/examples/find_unreferenced_classes.rb +14 -4
- data/examples/generate_class_lists.rb +1 -0
- data/examples/show_jar_api.rb +93 -0
- data/examples/test_corpus.rb +32 -0
- data/history.txt +17 -5
- data/javaclass.gemspec +9 -8
- data/lib/javaclass/analyse/dependencies.rb +1 -1
- data/lib/javaclass/analyse/transitive_dependencies.rb +2 -2
- data/lib/javaclass/classfile/class_magic.rb +1 -1
- data/lib/javaclass/classfile/constant_pool.rb +1 -0
- data/lib/javaclass/classfile/java_class_header_as_java_name.rb +4 -0
- data/lib/javaclass/classfile/java_class_header_shortcuts.rb +2 -0
- data/lib/javaclass/classlist/jar_searcher.rb +11 -5
- data/lib/javaclass/classlist/list.rb +27 -14
- data/lib/javaclass/classpath/any_classpath.rb +1 -1
- data/lib/javaclass/classpath/eclipse_classpath.rb +45 -25
- data/lib/javaclass/classpath/factory.rb +23 -13
- data/lib/javaclass/classpath/maven_artefact.rb +62 -0
- data/lib/javaclass/classpath/tracking_classpath.rb +3 -1
- data/lib/javaclass/dependencies/class_node.rb +36 -0
- data/lib/javaclass/dependencies/classpath_node.rb +37 -0
- data/lib/javaclass/dependencies/edge.rb +41 -0
- data/lib/javaclass/dependencies/graph.rb +53 -0
- data/lib/javaclass/dependencies/graphml_serializer.rb +102 -0
- data/lib/javaclass/dependencies/node.rb +82 -0
- data/lib/javaclass/dependencies/yaml_serializer.rb +103 -0
- data/lib/javaclass/dsl/java_name_factory.rb +2 -2
- data/lib/javaclass/gems/zip_file.rb +41 -33
- data/lib/javaclass/java_name.rb +1 -1
- data/lib/javaclass/java_name_scanner.rb +9 -7
- data/lib/javaclass/string_20.rb +40 -0
- data/lib/javaclass/string_hexdump.rb +18 -2
- data/lib/javaclass/string_ux.rb +3 -7
- data/planned.txt +50 -4
- data/rake_analysis.rb +46 -0
- data/test/data/api/packagename/Broken.class +0 -0
- data/test/logging_folder_classpath.rb +2 -2
- data/test/{test_adder_tree.rb → test_adder_tree_node.rb} +1 -1
- data/test/test_class_magic.rb +1 -1
- data/test/test_eclipse_classpath.rb +1 -1
- data/test/test_edge.rb +60 -0
- data/test/test_factory.rb +1 -1
- data/test/test_graph.rb +28 -0
- data/test/test_java_name.rb +13 -1
- data/test/test_javaclass_api.rb +18 -3
- data/test/test_maven_artefact.rb +37 -0
- data/test/test_node.rb +56 -0
- data/test/test_yaml_serializer.rb +105 -0
- data/test/ts_all_tests.rb +16 -3
- metadata +46 -35
- data/examples/profiler_scratchpad.rb +0 -33
- data/lib/javaclass/analyse/ideas.txt +0 -15
- data/lib/javaclass/classpath/classpaths.txt +0 -2
- data/lib/javaclass/classscanner/ideas.txt +0 -3
@@ -11,8 +11,9 @@
|
|
11
11
|
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
12
12
|
require File.join(File.dirname(__FILE__), 'corpus')
|
13
13
|
|
14
|
-
|
15
|
-
|
14
|
+
corpus = Corpus[:Base]
|
15
|
+
location = corpus.location
|
16
|
+
package = corpus.package
|
16
17
|
#++
|
17
18
|
require 'javaclass/dsl/mixin'
|
18
19
|
|
data/examples/corpus.rb
CHANGED
@@ -1,19 +1,59 @@
|
|
1
1
|
# :nodoc:
|
2
|
+
|
3
|
+
# Attributes of a project in the test corpus of Java projects.
|
4
|
+
# Test corpus has classes in classes/ or classes.zip. Same for test-classes.
|
5
|
+
# Author:: Peter Kofler
|
6
|
+
# Copyright:: Copyright (c) 2009, Peter Kofler.
|
7
|
+
# License:: {BSD License}[link:/files/license_txt.html]
|
8
|
+
#
|
9
|
+
class CorpusInfo < Struct.new(:location, :classes, :testClasses, :packages)
|
10
|
+
|
11
|
+
def self.with_default_folders(location, packages)
|
12
|
+
classes = pure_zip_or_nil(location, 'classes')
|
13
|
+
testClasses = pure_zip_or_nil(location, 'test-classes')
|
14
|
+
CorpusInfo.new(location, classes, testClasses, packages )
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.pure_zip_or_nil(location, name)
|
18
|
+
classes = File.join(location, name)
|
19
|
+
classes = File.join(location, name + '.zip') unless File.exist?(classes)
|
20
|
+
classes = nil unless File.exist?(classes)
|
21
|
+
classes
|
22
|
+
end
|
23
|
+
|
24
|
+
def package
|
25
|
+
if packages.size > 0
|
26
|
+
packages[0]
|
27
|
+
else
|
28
|
+
nil
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
2
34
|
# Set location of the test data corpus.
|
3
35
|
corpus_root = 'E:\OfficeDateien\Corpus'
|
4
36
|
Corpus = Hash[
|
5
37
|
*[
|
6
|
-
%w[Sun10 Java1_JDK-1.0.2(Sun_official)
|
7
|
-
%w[WF Java2_Swing(WF_iMagine)
|
8
|
-
%w[S1 Java5_Batch(S1_Fabric)
|
9
|
-
%w[Harmony15 Java5_JDK-1.5M15-r991518(Apache_Harmony)
|
10
|
-
%w[Harmony16 Java5_JDK-1.6M3-r991881(Apache_Harmony)
|
11
|
-
%w[RCP Java5_RCP_2011(IBM_Costing)
|
12
|
-
%w[BIA Java6_Swing(BIA_Monarch)
|
13
|
-
%w[HBD Java6_Web(HBD_Online)
|
14
|
-
].map { |pair|
|
15
|
-
|
38
|
+
%w[Sun10 Java1_JDK-1.0.2(Sun_official) java],
|
39
|
+
%w[WF Java2_Swing(WF_iMagine) at.workforce],
|
40
|
+
%w[S1 Java5_Batch(S1_Fabric) ],
|
41
|
+
%w[Harmony15 Java5_JDK-1.5M15-r991518(Apache_Harmony) ],
|
42
|
+
%w[Harmony16 Java5_JDK-1.6M3-r991881(Apache_Harmony) ],
|
43
|
+
%w[RCP Java5_RCP_2011(IBM_Costing) ],
|
44
|
+
%w[BIA Java6_Swing(BIA_Monarch) com.bia],
|
45
|
+
%w[HBD Java6_Web(HBD_Online) at.herold],
|
46
|
+
].map { |pair|
|
47
|
+
if pair[2] then package = [pair[2]] else package = [] end
|
48
|
+
c = CorpusInfo.with_default_folders(File.join(corpus_root, pair[1]), package)
|
49
|
+
[pair[0].to_sym, c]
|
16
50
|
}.flatten
|
17
51
|
]
|
18
|
-
|
19
|
-
|
52
|
+
|
53
|
+
# my own projects
|
54
|
+
Corpus[:Base] = CorpusInfo.with_default_folders('E:\Develop\Java', ['at.kugel'])
|
55
|
+
Corpus[:Lib] = CorpusInfo.with_default_folders('E:\Develop\Java\CodeLib', ['at.kugel'])
|
56
|
+
|
57
|
+
# temporary corpus for static analysis
|
58
|
+
Corpus[:Uep2] = CorpusInfo.new('D:\Internet\uep2', 'D:\Internet\cummulated.clz', 'D:\Internet\cummulated_test.clz', ['uep'])
|
59
|
+
Corpus[:Nuss] = CorpusInfo.new('D:\Backend\NUSS', 'D:\Backend\cummulated.clz', 'D:\Backend\cummulated_test.clz', ['at.lotterien'])
|
@@ -13,7 +13,8 @@
|
|
13
13
|
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
14
14
|
require File.join(File.dirname(__FILE__), 'corpus')
|
15
15
|
|
16
|
-
|
16
|
+
corpus = Corpus[:HBD]
|
17
|
+
location = corpus.location
|
17
18
|
#++
|
18
19
|
require 'javaclass/classpath/factory'
|
19
20
|
include JavaClass::Classpath::Factory
|
@@ -13,8 +13,9 @@
|
|
13
13
|
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
14
14
|
require File.join(File.dirname(__FILE__), 'corpus')
|
15
15
|
|
16
|
-
|
17
|
-
|
16
|
+
corpus = Corpus[:HBD]
|
17
|
+
location = corpus.location
|
18
|
+
package = corpus.package
|
18
19
|
start_class = 'at.herold.waf.hbd.servlet.HBDServlet'
|
19
20
|
# 'at/spardat/krimiaps/service/client/service/impl/ClientSmeSearchServiceImpl'
|
20
21
|
# 'at/spardat/krimiaps/service/client/service/impl/ClientPrivateSearchServiceImpl'
|
@@ -35,5 +36,5 @@ dependencies.debug_print
|
|
35
36
|
|
36
37
|
# 2b) or collect all transitive dependencies of a whole package
|
37
38
|
dependencies = cp.transitive_dependencies_package(start_class.to_javaname.package, &filter)
|
38
|
-
puts "#{dependencies.size} classes in transitive dependency graph of package"
|
39
|
+
puts "#{dependencies.size} classes in transitive dependency graph of package #{start_class.to_javaname.package}"
|
39
40
|
# dependencies.debug_print
|
@@ -13,10 +13,10 @@
|
|
13
13
|
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
14
14
|
require File.join(File.dirname(__FILE__), 'corpus')
|
15
15
|
|
16
|
-
|
17
|
-
prod_location =
|
18
|
-
test_location =
|
19
|
-
conf_location = location
|
16
|
+
corpus = Corpus[:Lib]
|
17
|
+
prod_location = corpus.classes
|
18
|
+
test_location = corpus.testClasses
|
19
|
+
conf_location = corpus.location
|
20
20
|
#++
|
21
21
|
require 'javaclass/dsl/mixin'
|
22
22
|
|
@@ -27,15 +27,19 @@ cp = classpath(prod_location)
|
|
27
27
|
prod_classnames = cp.types
|
28
28
|
|
29
29
|
# 3) collect all dependencies of all classes defined there
|
30
|
-
|
30
|
+
imported_types_with_numbers = cp.used_types_map
|
31
|
+
imported_classnames = imported_types_with_numbers.keys
|
31
32
|
|
32
33
|
# 4) also collect all classes referenced from config files, defined in JavaClass::JavaNameScanner
|
33
34
|
hardcoded_classnames = scan_config_for_3rd_party_class_names(conf_location)
|
34
35
|
|
35
36
|
# 5) now we know all classes imported/used by production classes
|
36
|
-
puts '---------- used 3rd party types in production'
|
37
|
+
puts '---------- used 3rd party types in production ; 0 = hardcoded'
|
37
38
|
used_classnames = (imported_classnames + hardcoded_classnames).uniq.sort - prod_classnames
|
38
|
-
puts used_classnames
|
39
|
+
# puts used_classnames
|
40
|
+
used_classnames.each do |name|
|
41
|
+
puts "#{name} ; #{imported_types_with_numbers[name]}"
|
42
|
+
end
|
39
43
|
|
40
44
|
# 6) do the same for test classes, at least org.junit.* should show up here
|
41
45
|
test_cp = classpath(test_location)
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# Example usage of dependency graph: Invert the graph and see incoming dependencies of a module.
|
2
|
+
# After getting all classes of a module, use previously generated dependency graph to iterate
|
3
|
+
# all incoming edges. Then either report all incoming edges as CSV or find all private/inner
|
4
|
+
# classes of the module. Works with an existing dependency graph,
|
5
|
+
# e.g. created by {chart module dependencies example}[link:/files/lib/generated/examples/chart_module_dependencies_txt.html].
|
6
|
+
# Author:: Peter Kofler
|
7
|
+
# Copyright:: Copyright (c) 2012, Peter Kofler.
|
8
|
+
# License:: {BSD License}[link:/files/license_txt.html]
|
9
|
+
#
|
10
|
+
# === Steps
|
11
|
+
|
12
|
+
#--
|
13
|
+
# add the lib of this gem to the load path
|
14
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
15
|
+
require File.join(File.dirname(__FILE__), 'corpus')
|
16
|
+
|
17
|
+
corpus = Corpus[:RCP]
|
18
|
+
location = corpus.location
|
19
|
+
#++
|
20
|
+
require 'javaclass/dsl/mixin'
|
21
|
+
require 'javaclass/classpath/tracking_classpath'
|
22
|
+
require 'javaclass/dependencies/edge'
|
23
|
+
require 'javaclass/dependencies/yaml_serializer'
|
24
|
+
|
25
|
+
# 1) create a classpath of the main model plugin
|
26
|
+
Plugin_name = 'org.codecop.model'
|
27
|
+
cp = classpath(File.join(location, Plugin_name, 'bin'))
|
28
|
+
classes = cp.names
|
29
|
+
puts "#{classes.count} classes found in main plugin"
|
30
|
+
cp.reset_access
|
31
|
+
|
32
|
+
# 2) load a dependency Graph containing the model
|
33
|
+
plugins = JavaClass::Dependencies::YamlSerializer.new.load('plugin_dependencies')
|
34
|
+
|
35
|
+
# used to strip beginning of full qualified names
|
36
|
+
def strip(name)
|
37
|
+
name.sub(/^org\.codecop\./, '*.')
|
38
|
+
end
|
39
|
+
|
40
|
+
# 3) mark all accessed classes in model plugin using the dependency graph
|
41
|
+
plugins.each_node do |plugin|
|
42
|
+
next if plugin.name == Plugin_name
|
43
|
+
plugin.each_edge do |dep, edge|
|
44
|
+
next unless dep.name == Plugin_name
|
45
|
+
cp.mark_accessed(edge.target)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
plugins.each_node do |plugin|
|
50
|
+
plugin.each_dependency_provider do |dep, dependencies|
|
51
|
+
plugin.dependencies[dep] = dependencies.map { |edge|
|
52
|
+
# replace class edges by package edges
|
53
|
+
# JavaClass::Dependencies::Edge.new(edge.source.to_javaname.package, edge.target.to_javaname.package)
|
54
|
+
|
55
|
+
# replace class edges with source plugin, target package
|
56
|
+
# JavaClass::Dependencies::Edge.new(plugin.name, edge.target.to_javaname.package)
|
57
|
+
|
58
|
+
# replace source edges with source plugin
|
59
|
+
JavaClass::Dependencies::Edge.new(plugin.name, edge.target)
|
60
|
+
}.uniq.sort
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
# 4) report all incoming dependencies (edges) for further Excel analysis
|
65
|
+
plugins.each_node do |plugin|
|
66
|
+
next if plugin.name == Plugin_name
|
67
|
+
plugin.each_edge do |dep, edge|
|
68
|
+
next unless dep.name == Plugin_name
|
69
|
+
puts "#{strip(edge.target)};#{strip(plugin.name)};#{strip(edge.source)}"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# 5) report unused classes in model from outside
|
74
|
+
unused_classes = classes.
|
75
|
+
find_all { |clazz| cp.accessed(clazz) == 0 }.
|
76
|
+
reject { |clazz| clazz =~ /\$.*$/ }
|
77
|
+
report = unused_classes.map { |clazz| "#{clazz.to_classname}" }.uniq
|
78
|
+
puts "#{report.size} private classes found:"
|
79
|
+
report.each do |clazz|
|
80
|
+
puts "#{strip(clazz)};(internal);NA"
|
81
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# Example usage of dependency graph: Organize the nodes into layers
|
2
|
+
# depending on their dependencies. Works with an existing dependency graph,
|
3
|
+
# e.g. created by {chart module dependencies example}[link:/files/lib/generated/examples/chart_module_dependencies_txt.html].
|
4
|
+
# Author:: Peter Kofler
|
5
|
+
# Copyright:: Copyright (c) 2012, Peter Kofler.
|
6
|
+
# License:: {BSD License}[link:/files/license_txt.html]
|
7
|
+
#
|
8
|
+
# === Steps
|
9
|
+
|
10
|
+
#--
|
11
|
+
# add the lib of this gem to the load path
|
12
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
13
|
+
|
14
|
+
#++
|
15
|
+
require 'javaclass/dependencies/yaml_serializer'
|
16
|
+
|
17
|
+
# 1) load dependency graph
|
18
|
+
plugins = JavaClass::Dependencies::YamlSerializer.new.load('plugin_dependencies')
|
19
|
+
components = plugins.to_a
|
20
|
+
|
21
|
+
@layerOfComponents = []
|
22
|
+
|
23
|
+
# 2) find modules without any dependencies, these are the first/bottom
|
24
|
+
first_elements = components.find_all { |c| c.dependencies.size == 0 }.sort
|
25
|
+
@layerOfComponents << first_elements
|
26
|
+
components = components - first_elements
|
27
|
+
|
28
|
+
def has_all_deps_satisfied?(component)
|
29
|
+
already_sorted_dependencies = @layerOfComponents.flatten
|
30
|
+
component.dependencies.keys.find { |dependency|
|
31
|
+
!already_sorted_dependencies.include?(dependency)
|
32
|
+
} == nil
|
33
|
+
end
|
34
|
+
|
35
|
+
while components.size > 0
|
36
|
+
cycle = true
|
37
|
+
|
38
|
+
# 3) for each component, check if all dependencies are satisfied combined layers below
|
39
|
+
components.each do |component|
|
40
|
+
|
41
|
+
if has_all_deps_satisfied?(component)
|
42
|
+
components -= [component]
|
43
|
+
|
44
|
+
# 4) if yes, walk up the dependencies until highest/lowest possible
|
45
|
+
index = @layerOfComponents.size - 1
|
46
|
+
while (component.dependencies.keys.find { |dependency| @layerOfComponents[index].include?(dependency) } == nil)
|
47
|
+
index = index -1
|
48
|
+
end
|
49
|
+
index = index + 1 # take next
|
50
|
+
|
51
|
+
# and add to the layers
|
52
|
+
if index == @layerOfComponents.size
|
53
|
+
@layerOfComponents[index] = []
|
54
|
+
end
|
55
|
+
@layerOfComponents[index] << component
|
56
|
+
|
57
|
+
puts "added #{component}"
|
58
|
+
cycle = false
|
59
|
+
break
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
if cycle
|
65
|
+
warn "cycle in #{components.join(', ')}, can't continue with layering"
|
66
|
+
break
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# 5) output the found layering
|
71
|
+
(1..@layerOfComponents.size).each do |i|
|
72
|
+
layer = @layerOfComponents[i-1].sort
|
73
|
+
puts "#{i} " + layer.join(', ')
|
74
|
+
end
|
75
|
+
|
76
|
+
#--
|
77
|
+
# TODO separate components not only by layer, but also be "stream/slice" in layer
|
78
|
+
# If it depends only on a single parent and not on others in the same layer - but a chart would be better for that.
|
79
|
+
#++
|
@@ -13,12 +13,10 @@
|
|
13
13
|
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
14
14
|
require File.join(File.dirname(__FILE__), 'corpus')
|
15
15
|
|
16
|
-
|
17
|
-
location =
|
18
|
-
|
19
|
-
|
20
|
-
main_location = File.join(location, 'classes')
|
21
|
-
test_location = File.join(location, 'test-classes')
|
16
|
+
corpus = Corpus[:BIA]
|
17
|
+
location = corpus.location
|
18
|
+
main_location = corpus.classes
|
19
|
+
test_location = corpus.testClasses
|
22
20
|
#++
|
23
21
|
require 'javaclass/dsl/mixin'
|
24
22
|
|
@@ -1,7 +1,8 @@
|
|
1
1
|
# Advanced example usage of JavaClass::Classpath::TrackingClasspath. Load all
|
2
2
|
# classes of an Eclipse workspace. Then mark all referenced classes. In the end
|
3
3
|
# report remaining classes as unreferenced. This lists *potential* unused classes.
|
4
|
-
# Note that the classes may still be used by reflection.
|
4
|
+
# Note that the classes may still be used by reflection. Also this can be used to
|
5
|
+
# find classes that have a certain number of references to them, e.g. only used once.
|
5
6
|
# Author:: Peter Kofler
|
6
7
|
# Copyright:: Copyright (c) 2009, Peter Kofler.
|
7
8
|
# License:: {BSD License}[link:/files/license_txt.html]
|
@@ -13,9 +14,9 @@
|
|
13
14
|
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
14
15
|
require File.join(File.dirname(__FILE__), 'corpus')
|
15
16
|
|
16
|
-
location = Corpus[:
|
17
|
-
package1 = '
|
18
|
-
package2 = '
|
17
|
+
location = Corpus[:Lib].location
|
18
|
+
package1 = 'at.kugel'
|
19
|
+
package2 = 'org.codecop'
|
19
20
|
#++
|
20
21
|
require 'javaclass/dsl/mixin'
|
21
22
|
require 'javaclass/classpath/tracking_classpath'
|
@@ -63,3 +64,12 @@ puts 'test classes mapped'
|
|
63
64
|
unused_classes = classes.find_all { |clazz| cp.accessed(clazz) == 0 }
|
64
65
|
report = unused_classes.map { |clazz| "#{clazz.to_classname}" }
|
65
66
|
puts "#{report.size} unused classes found:\n #{report.join("\n ")}"
|
67
|
+
|
68
|
+
# 7) find only once accessed classes and report them
|
69
|
+
once_used_classes = classes.find_all { |clazz| cp.accessed(clazz) == 1 }
|
70
|
+
report = once_used_classes.map { |clazz| "#{clazz.to_classname}" }
|
71
|
+
puts "#{report.size} once used classes found:\n #{report.join("\n ")}"
|
72
|
+
|
73
|
+
twice_used_classes = classes.find_all { |clazz| cp.accessed(clazz) == 2 }
|
74
|
+
report = twice_used_classes.map { |clazz| "#{clazz.to_classname}" }
|
75
|
+
puts "#{report.size} twice used classes found:\n #{report.join("\n ")}"
|
@@ -30,6 +30,7 @@ JDKS = [
|
|
30
30
|
JDK_CONFIG.new(5, '1.5.0-07', [PROGRAMS + '\jdk1.5.0_07\jre\lib', PROGRAMS + '\jdk1.5.0_07\lib\dt.jar']),
|
31
31
|
JDK_CONFIG.new(6, '1.6.0-26', [PROGRAMS + '\jdk1.6.0_26\jre\lib', PROGRAMS + '\jdk1.6.0_26\lib\dt.jar']),
|
32
32
|
JDK_CONFIG.new(7, '1.7.0', [PROGRAMS + '\jdk1.7.0\jre\lib', PROGRAMS + '\jdk1.7.0\lib\dt.jar']),
|
33
|
+
JDK_CONFIG.new(8, '1.8.0', [PROGRAMS + '\jdk1.8.0_25\jre\lib', PROGRAMS + '\jdk1.8.0_25\lib\dt.jar']),
|
33
34
|
]
|
34
35
|
#++
|
35
36
|
# configuration for some JDKs
|
@@ -0,0 +1,93 @@
|
|
1
|
+
# Generate a JavaClass::ClassList, which contains all class of a given
|
2
|
+
# JAR in the local Maven repository. Use JavaClass::Classpath::MavenArtefact
|
3
|
+
# to identify and (possibly download) the JAR under question.
|
4
|
+
# Author:: Peter Kofler
|
5
|
+
# Copyright:: Copyright (c) 2009, Peter Kofler.
|
6
|
+
# License:: {BSD License}[link:/files/license_txt.html]
|
7
|
+
#
|
8
|
+
# === Usage
|
9
|
+
|
10
|
+
#--
|
11
|
+
# add the lib of this gem to the load path
|
12
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
13
|
+
#++
|
14
|
+
require 'javaclass/classlist/jar_searcher'
|
15
|
+
require 'javaclass/classpath/maven_artefact'
|
16
|
+
require 'javaclass/classlist/list'
|
17
|
+
|
18
|
+
#--
|
19
|
+
JARS = [
|
20
|
+
# some Apache Commons
|
21
|
+
# JavaClass::Classpath::MavenArtefact.new('commons-beanutils', 'commons-beanutils', '1.8.3', 'Commons BeanUtils'),
|
22
|
+
# JavaClass::Classpath::MavenArtefact.new('commons-cli', 'commons-cli', '1.2'),
|
23
|
+
# JavaClass::Classpath::MavenArtefact.new('commons-codec', 'commons-codec', '1.6'),
|
24
|
+
# JavaClass::Classpath::MavenArtefact.new('commons-collections', 'commons-collections', '3.2.1'),
|
25
|
+
# JavaClass::Classpath::MavenArtefact.new('commons-configuration', 'commons-configuration', '1.8'),
|
26
|
+
# JavaClass::Classpath::MavenArtefact.new('commons-digester', 'commons-digester', '2.1'),
|
27
|
+
# JavaClass::Classpath::MavenArtefact.new('org.apache.commons', 'commons-digester3', '3.2'),
|
28
|
+
# JavaClass::Classpath::MavenArtefact.new('org.apache.commons', 'commons-email', '1.2'),
|
29
|
+
# JavaClass::Classpath::MavenArtefact.new('org.apache.commons', 'commons-exec', '1.1'),
|
30
|
+
# JavaClass::Classpath::MavenArtefact.new('commons-httpclient', 'commons-httpclient', '3.0', 'Jakarta Httpclient'),
|
31
|
+
# JavaClass::Classpath::MavenArtefact.new('org.apache.commons', 'commons-id', '1.0-SNAPSHOT'),
|
32
|
+
# JavaClass::Classpath::MavenArtefact.new('commons-io', 'commons-io', '2.4'),
|
33
|
+
# JavaClass::Classpath::MavenArtefact.new('org.apache.commons', 'commons-jexl', '2.1.1', 'Commons JEXL'),
|
34
|
+
# JavaClass::Classpath::MavenArtefact.new('commons-jxpath', 'commons-jxpath', '1.3', 'Commons JXPath'),
|
35
|
+
JavaClass::Classpath::MavenArtefact.new('commons-lang', 'commons-lang', '2.6'),
|
36
|
+
# JavaClass::Classpath::MavenArtefact.new('org.apache.commons', 'commons-lang3', '3.1'),
|
37
|
+
# JavaClass::Classpath::MavenArtefact.new('org.apache.commons', 'commons-math', '2.2'),
|
38
|
+
# JavaClass::Classpath::MavenArtefact.new('org.apache.commons', 'commons-math3', '3.0'),
|
39
|
+
# JavaClass::Classpath::MavenArtefact.new('commons-net', 'commons-net', '3.1'),
|
40
|
+
# JavaClass::Classpath::MavenArtefact.new('oro', 'oro', '2.0.8', 'Jakarta ORO'),
|
41
|
+
]
|
42
|
+
#++
|
43
|
+
# Define configuration for some Maven artefacts
|
44
|
+
# JARS = [ JavaClass::Classpath::MavenArtefact.new('commons-lang', 'commons-lang', '2.6'),, ... ]
|
45
|
+
|
46
|
+
# For all artefacts listed in +JARS+, load classes and write list files.
|
47
|
+
JARS.each do |artefact|
|
48
|
+
|
49
|
+
# 1) create a new JavaClass::ClassList::List to contain the classes of this JAR
|
50
|
+
list = JavaClass::ClassList::List.new
|
51
|
+
|
52
|
+
# 2) create a JavaClass::ClassList::JarSearcher
|
53
|
+
searcher = JavaClass::ClassList::JarSearcher.new
|
54
|
+
searcher.skip_package_classes = true
|
55
|
+
|
56
|
+
# 3) create the classpath of the artefact's JAR
|
57
|
+
artefact.download_if_needed
|
58
|
+
classpath = artefact.classpath
|
59
|
+
|
60
|
+
# 4) scan the JAR and add classes to the list
|
61
|
+
searcher.add_list_from_classpath(artefact.version, classpath, list)
|
62
|
+
|
63
|
+
# 5) save the list to a file named "Commons Lang 2.6.txt" (after the artefact)
|
64
|
+
File.open("#{artefact.title} #{artefact.version}.txt", "w") do |f|
|
65
|
+
# print title
|
66
|
+
f.print "*** #{artefact.title}\n"
|
67
|
+
|
68
|
+
list.packages.each { |pkg|
|
69
|
+
f.print "\n"
|
70
|
+
# print package name
|
71
|
+
f.print "* #{pkg.name}\n"
|
72
|
+
|
73
|
+
# print class names
|
74
|
+
pkg.classes.each { |c| f.print " #{c.name}\n" }
|
75
|
+
}
|
76
|
+
end
|
77
|
+
|
78
|
+
puts "processed #{artefact.name}"
|
79
|
+
end
|
80
|
+
|
81
|
+
# 6) the generated file looks like
|
82
|
+
# *** Commons Lang
|
83
|
+
#
|
84
|
+
# * org.apache.commons.lang
|
85
|
+
# ArrayUtils
|
86
|
+
# BitField
|
87
|
+
# ...
|
88
|
+
#
|
89
|
+
# * org.apache.commons.lang.builder
|
90
|
+
# CompareToBuilder
|
91
|
+
# EqualsBuilder
|
92
|
+
# HashCodeBuilder
|
93
|
+
# ...
|