Class JavaClass::Classpath::MavenClasspath
In: lib/javaclass/classpath/maven_classpath.rb
Parent: CompositeClasspath

A Maven folder structure aware classpath. Maven submodules are supported.

Author:Peter Kofler

Methods

Constants

POM_XML = 'pom.xml'

Public Class methods

Create a classpath for a Maven base project folder

[Source]

# File lib/javaclass/classpath/maven_classpath.rb, line 18
      def initialize(folder)
        unless MavenClasspath::valid_location?(folder)
          raise IOError, "folder #{folder} not a Maven project"
        end
        pom = File.join(folder, POM_XML)
        super(pom)
        add_if_exist(File.join(folder, 'target/classes'))
        add_if_exist(File.join(folder, 'target/test-classes'))

        # look for submodules
        Dir.entries(folder).each do |dir|
          next if dir =~ /^(?:\.|\.\.|src|target|pom.xml|\.settings)$/
          folder = File.join(folder, dir)
          add_element(MavenClasspath.new(folder)) if MavenClasspath::valid_location?(folder)
        end
      end

Check if the file is a valid location for a Maven classpath.

[Source]

# File lib/javaclass/classpath/maven_classpath.rb, line 13
      def self.valid_location?(file)
        FileTest.exist?(file) && FileTest.directory?(file) && FileTest.exist?(File.join(file, POM_XML))
      end

[Validate]