Skip to content

Commit 72e6b8b

Browse files
authored
Merge pull request #11 from jruby/using-polyglot-extension
Using polyglot extension
2 parents df949a4 + a68e7e4 commit 72e6b8b

File tree

13 files changed

+589
-33
lines changed

13 files changed

+589
-33
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ pom*xml
33
pom*xml.bkp
44
*.gem
55
*.lock
6+
lib/extensions/

.mvn/extensions.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
<extension>
99
<groupId>io.takari.polyglot</groupId>
1010
<artifactId>polyglot-ruby</artifactId>
11-
<version>0.4.8</version>
11+
<version>0.7.1</version>
1212
</extension>
1313
</extensions>

.mvn/wrapper/maven-wrapper.jar

61.1 KB
Binary file not shown.

.mvn/wrapper/maven-wrapper.properties

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip
18+
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar

Mavenfile

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,26 @@
11
# -*- mode:ruby -*-
22

33
gemspec
4-
54
properties 'push.skip': true, 'jruby.version': '9.3.1.0'
65

6+
load File.join( basedir,'lib/maven/ruby/version.rb')
7+
8+
jar "io.takari.polyglot:polyglot-ruby:#{Maven::Ruby::POLYGLOT_VERSION}", scope: :provided
9+
10+
execute 'cleanup extensions', 'initialize' do |ctx|
11+
FileUtils.rm_rf "#{ctx.project.build.directory}/../lib/extensions"
12+
end
13+
14+
plugin :dependency do
15+
16+
execute_goal(:"copy-dependencies",
17+
phase: 'prepare-package',
18+
includeScope: :provided,
19+
includeGroupIds: 'io.takari.polyglot',
20+
outputDirectory: '${project.build.directory}/../lib/extensions')
21+
22+
end
23+
724
profile :id => :release do
825
properties 'maven.test.skip' => true, 'invoker.skip' => true
926
properties 'push.skip' => false

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,19 @@ other is closer to maven in its naming.
5656

5757
it is licensed under (EPL-1.0)[https://www.eclipse.org/legal/epl-v10.html]
5858

59-
## contributing #
59+
## building ##
60+
61+
Prepare and pack the gem under ./pkg
62+
```
63+
./mvnw install
64+
```
65+
66+
Push the gem to rubygems.org
67+
```
68+
./mvnw deploy -Prelease
69+
```
70+
71+
## contributing ##
6072

6173
1. Fork it
6274
2. Create your feature branch (`git checkout -b my-new-feature`)

lib/maven/ruby/version.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module Maven
22
module Ruby
3-
VERSION = '3.3.12'.freeze
3+
VERSION = '3.9.0'.freeze
4+
POLYGLOT_VERSION = "0.7.1".freeze
45
end
56
end

lib/polyglot_jars/.keep

Whitespace-only changes.

lib/ruby_maven.rb

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,16 @@
2020
#
2121
require 'maven'
2222
require 'maven/ruby/maven'
23+
require 'maven/ruby/version'
2324

2425
module RubyMaven
25-
POLYGLOT_VERSION = "0.1.15"
2626

2727
def self.exec( *args )
2828
if File.exist?('settings.xml') and not args.member?('-s') and not args.member?('--settings')
2929
args << '-s'
3030
args << 'settings.xml'
3131
end
3232
if args.member?('-version') or args.member?('--version') or args.member?('-v')
33-
warn "Polyglot Maven Extension #{version}"
3433
launch( '--version' )
3534
elsif defined? Bundler
3635
# it can be switching from ruby to jruby with invoking maven
@@ -58,40 +57,37 @@ def self.version
5857
xml = File.read( File.join( dir, '.mvn/extensions.xml' ) )
5958
xml.sub( /.*<version>/m, '' ).sub(/<\/version>.*/m, '' )
6059
rescue Errno::ENOENT => e
61-
nil
60+
Maven::Ruby::POLYGLOT_VERSION
6261
end
63-
POLYGLOT_VERSION.replace(polyglot_version) if polyglot_version
64-
POLYGLOT_VERSION
6562
end
6663

6764
def self.launch( *args )
65+
if args.member?('--version') or args.member?('--show-version')
66+
warn "Polyglot Maven Extension #{Maven::Ruby::POLYGLOT_VERSION} via ruby-maven #{Maven::Ruby::VERSION}"
67+
end
6868
old_maven_home = ENV['M2_HOME']
6969
ENV['M2_HOME'] = Maven.home
70-
71-
extensions = File.join( '.mvn/extensions.xml' )
72-
if has_extensions = File.exist?( extensions )
73-
# tests need copy instead of move
74-
FileUtils.cp( extensions, extensions + ".orig" )
75-
else
76-
FileUtils.mkdir_p( '.mvn' )
70+
ext_dir = File.join(Maven.lib, 'ext')
71+
FileUtils.mkdir_p(ext_dir)
72+
local_dir = File.join(__dir__, 'polyglot_jars')
73+
Dir.new(local_dir).select do |file|
74+
file =~ /.*\.jar$/
75+
end.each do |jar|
76+
source = File.join(local_dir, jar)
77+
if jar =~ /polyglot-.*-#{Maven::Ruby::POLYGLOT_VERSION}.jar/
78+
# ruby maven defines the polyglot version and this jar sets up its classpath
79+
# i.e. on upgrade or downgrade the right version will be picked
80+
FileUtils.cp(source, File.join(ext_dir, jar.sub(/-[0-9.]*(-SNAPSHOT)?.jar$/, '.jar')))
81+
elsif not File.exists?(File.join(ext_dir, jar)) and not jar =~ /jruby-(core|stdlib).*/
82+
# jar files are immutable as they carry the version
83+
warn jar
84+
FileUtils.cp(source, File.join(ext_dir, jar.sub(/-9.4.5.0/, '')))
85+
end
7786
end
78-
FileUtils.cp( File.join( dir, extensions ), extensions ) rescue nil
79-
80-
# setup version
81-
self.version
8287

8388
Maven.exec( *args )
8489

8590
ensure
8691
ENV['M2_HOME'] = old_maven_home
87-
88-
FileUtils.rm_f( extensions )
89-
if has_extensions
90-
FileUtils.move( extensions + '.orig', extensions )
91-
else
92-
dir = File.dirname( extensions )
93-
# delete empty .mvn directory
94-
FileUtils.rm_rf( dir ) if Dir[File.join(dir, '*')].size == 0
95-
end
9692
end
9793
end

0 commit comments

Comments
 (0)