Skip to content

Commit

Permalink
File.exists? no longer exist?
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Dec 11, 2024
1 parent fd6e5fd commit 131e0ff
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions lib/maven/tools/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def gemfile( name = 'Gemfile', options = {} )
options = name
name = 'Gemfile'
end
name = ::File.join( basedir, name ) unless ::File.exists?( name )
name = ::File.join( basedir, name ) unless ::File.exist?( name )
if @context == :project
build do
extension! 'org.jruby.maven:mavengem-wagon', '${mavengem.wagon.version}'
Expand All @@ -149,7 +149,7 @@ def gemfile( name = 'Gemfile', options = {} )
@inside_gemfile = true
# the eval might need those options for gemspec declaration
lockfile = ::File.expand_path( name + '.lock' )
if File.exists? lockfile
if File.exist? lockfile
pr = profile :gemfile do
activation do
file( :missing => name.sub(/#{basedir}./, '') + '.lock' )
Expand Down Expand Up @@ -304,7 +304,7 @@ def setup_gem_support( options, spec = nil, config = {} )
end
# TODO rename "no_rubygems_repo" to "no_jar_support"
if options[ :no_rubygems_repo ] != true && jar && ( source ||
::File.exists?( ::File.join( basedir, 'src', 'main', 'java' ) ) )
::File.exist?( ::File.join( basedir, 'src', 'main', 'java' ) ) )
unless spec.nil? || spec.platform.to_s.match( /java|jruby/ )
warn "gem is not a java platform gem but has a jar and source"
end
Expand Down Expand Up @@ -361,7 +361,7 @@ def jarfile( file = 'Jarfile', options = {} )
warn "DEPRECATED use filename instead"
file = jfile.file
end
file = ::File.join( basedir, file ) unless ::File.exists?( file )
file = ::File.join( basedir, file ) unless ::File.exist?( file )
dsl = Maven::Tools::DSL::Jarfile.new( @current, file, options[ :skip_lock ] )

# TODO this setup should be part of DSL::Jarfile
Expand Down
2 changes: 1 addition & 1 deletion lib/maven/tools/dsl/gem_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def setup_gem_support( project, options, spec = nil )
# TODO rename "no_rubygems_repo" to "no_jar_support"
if( options[ :no_rubygems_repo ] != true &&
jar &&
( source || File.exists?( File.join( project.basedir,
( source || File.exist?( File.join( project.basedir,
'src/main/java' ) ) ) )

unless spec.nil? || spec.platform.to_s.match( /java|jruby/ )
Expand Down
2 changes: 1 addition & 1 deletion lib/maven/tools/dsl/jarfile_lock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class JarfileLock

def initialize( jarfile )
@file = File.expand_path( jarfile + ".lock" ) if jarfile
if @file && File.exists?( @file )
if @file && File.exist?( @file )
lock = YAML.load( File.read( @file ) )
case lock
when Hash
Expand Down
2 changes: 1 addition & 1 deletion lib/maven/tools/dsl/jars_lock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class JarsLock

def initialize( parent, file = 'Jars.lock' )
file = File.join( parent.basedir, file )
if File.exists?(file)
if File.exist?(file)
parent.profile File.basename(file) do
parent.activation do
parent.file( :exists => File.basename(file) )
Expand Down
2 changes: 1 addition & 1 deletion lib/maven/tools/gemfile_lock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def initialize(file)
current = nil
bundler = false
f = file.is_a?(File) ? file.path: file
if File.exists? f
if File.exist? f
File.readlines(f).each do |line|
if line =~ /^BUNDLED WITH/
bundler = true
Expand Down
8 changes: 4 additions & 4 deletions lib/maven/tools/jarfile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ def mtime
end

def exists?
::File.exists?(@file)
::File.exist?(@file)
end

def mtime_lock
::File.mtime(@lockfile)
end

def exists_lock?
::File.exists?(@lockfile)
::File.exist?(@lockfile)
end

def load_lockfile
Expand Down Expand Up @@ -83,7 +83,7 @@ def self.eval_file( file )

def eval_file( file )
warn "#{self.class} is deprecated"
if ::File.exists?( file )
if ::File.exist?( file )
eval( ::File.read( file ), nil, file )
self
end
Expand Down Expand Up @@ -178,7 +178,7 @@ def setup_locked( parent )

def populate_unlocked( container = nil, &block )
warn 'DEPRECATED use Maven::Tools::DSL::Jarfile instead'
if ::File.exists?(@file)
if ::File.exist?(@file)
dsl = Maven::Tools::DSL::Jarfile.new( nil, @file )

if block
Expand Down
2 changes: 1 addition & 1 deletion lib/maven/tools/pom.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def to_file( file )
end

def to_model( file )
if ::File.exists?( file )
if ::File.exist?( file )
case file
when /pom.rb/
eval_pom( "tesla do\n#{ ::File.read( file ) }\nend", file )
Expand Down
2 changes: 1 addition & 1 deletion spec/pom_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
it "should convert #{dir}" do
pom = Maven::Tools::POM.new( dir )
file = File.join( dir, 'pom.xml' )
file = File.join( File.dirname( dir ), 'pom.xml' ) unless File.exists? file
file = File.join( File.dirname( dir ), 'pom.xml' ) unless File.exist? file
pom_xml = File.read( file )
pom_xml.sub!( /<!--(.|\n)*-->\n/, '' )
pom_xml.sub!( /<?.*?>\n/, '' )
Expand Down

0 comments on commit 131e0ff

Please sign in to comment.