Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate plugin to use dry-struct from virtus #36

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
583 changes: 249 additions & 334 deletions lib/maven/tools/model.rb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/maven/tools/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
#
module Maven
module Tools
VERSION = '1.1.7'.freeze
VERSION = '1.2.0'.freeze
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured 1.2 due to the dependency changes

end
end
4 changes: 2 additions & 2 deletions lib/maven/tools/visitor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def camel_case_lower( str )
buffer.push( buffer.empty? ? e : e.capitalize )
end.join
end

def accept_project( project )
accept( 'project', project )
@io.close if @io.respond_to? :close
Expand Down Expand Up @@ -144,7 +144,7 @@ def accept_hash( name, hash )
end_tag( name )
end
end

def escape_value( value )
value = value.to_s.dup
value.gsub!( /&/, '&' )
Expand Down
9 changes: 8 additions & 1 deletion maven-tools.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@ Gem::Specification.new do |s|
s.test_files += Dir['spec/**/*gemspec']
s.test_files += Dir['spec/**/*gem']

s.add_runtime_dependency 'virtus', '~> 1.0'
s.add_runtime_dependency 'dry-container', '~> 0.7.2'
s.add_runtime_dependency 'dry-configurable', '~> 0.12.1'
s.add_runtime_dependency 'dry-core', '~> 0.6.0'
s.add_runtime_dependency 'dry-inflector', '~> 0.2.0'
s.add_runtime_dependency 'dry-types', '~> 1.5.1'
s.add_runtime_dependency 'dry-struct', '~> 1.4.0'
s.add_runtime_dependency 'dry-struct-setters', '~> 0.4.0'
Comment on lines +31 to +37
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These were the dependency versions whose releases worked on the version of Ruby in the JRuby dependency



# get them out from here until jruby-maven-plugin installs test gems somewhere else then runtime gems

Expand Down
66 changes: 47 additions & 19 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>rubygems</groupId>
<artifactId>maven-tools</artifactId>
<version>1.1.6</version>
<version>1.2.0</version>
<packaging>gem</packaging>
<name>helpers for maven related tasks</name>
<url>http://github.com/torquebox/maven-tools</url>
Expand All @@ -19,17 +19,8 @@
</scm>
<repositories>
<repository>
<id>rubygems</id>
<name>Rubygems Proxy</name>
<url>http://rubygems-proxy.torquebox.org/releases</url>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The torquebox domain lapsed recently

<layout>default</layout>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
<id>mavengems</id>
<url>mavengem:https://rubygems.org</url>
</repository>
</repositories>
<properties>
Expand All @@ -39,31 +30,67 @@
<dependencies>
<dependency>
<groupId>rubygems</groupId>
<artifactId>virtus</artifactId>
<version>[1.0,1.99999]</version>
<artifactId>dry-container</artifactId>
<version>0.7.2</version>
<type>gem</type>
</dependency>
<dependency>
<groupId>rubygems</groupId>
<artifactId>dry-configurable</artifactId>
<version>0.12.1</version>
<type>gem</type>
</dependency>
<dependency>
<groupId>rubygems</groupId>
<artifactId>dry-core</artifactId>
<version>0.6.0</version>
<type>gem</type>
</dependency>
<dependency>
<groupId>rubygems</groupId>
<artifactId>dry-inflector</artifactId>
<version>0.2.0</version>
<type>gem</type>
</dependency>
<dependency>
<groupId>rubygems</groupId>
<artifactId>dry-types</artifactId>
<version>1.5.1</version>
<type>gem</type>
</dependency>
<dependency>
<groupId>rubygems</groupId>
<artifactId>dry-struct</artifactId>
<version>1.4.0</version>
<type>gem</type>
</dependency>
<dependency>
<groupId>rubygems</groupId>
<artifactId>dry-struct-setters</artifactId>
<version>0.4.0</version>
<type>gem</type>
</dependency>
<dependency>
<groupId>rubygems</groupId>
<artifactId>rake</artifactId>
<version>[10.0,10.99999]</version>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Version ranges didn't seem to work with wagon

<version>10.5.0</version>
<type>gem</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>rubygems</groupId>
<artifactId>minitest</artifactId>
<version>[5.3,5.99999]</version>
<version>5.15.0</version>
<type>gem</type>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<extensions>
<extension>
<groupId>de.saumya.mojo</groupId>
<artifactId>gem-extension</artifactId>
<version>${jruby.plugins.version}</version>
<groupId>org.torquebox.mojo</groupId>
<artifactId>mavengem-wagon</artifactId>
<version>1.0.3</version>
</extension>
</extensions>
<directory>${basedir}/pkg</directory>
Expand All @@ -72,6 +99,7 @@
<groupId>de.saumya.mojo</groupId>
<artifactId>gem-maven-plugin</artifactId>
<version>${jruby.plugins.version}</version>
<extensions>true</extensions>
<configuration>
<gemspec>maven-tools.gemspec</gemspec>
</configuration>
Expand Down
82 changes: 41 additions & 41 deletions spec/artifact_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,67 +4,67 @@
describe Maven::Tools::Artifact do

it 'should convert from coordinate' do
Maven::Tools::Artifact.from_coordinate( 'sdas:das:jar:tes:123' ).to_s.must_equal 'sdas:das:jar:tes:123'
Maven::Tools::Artifact.from_coordinate( 'sdas:das:jar:123' ).to_s.must_equal 'sdas:das:jar:123'
Maven::Tools::Artifact.from_coordinate( 'sdas:das:jar:tes:[123,234]' ).to_s.must_equal 'sdas:das:jar:tes:[123,234]'
Maven::Tools::Artifact.from_coordinate( 'sdas:das:jar:[123,234]' ).to_s.must_equal 'sdas:das:jar:[123,234]'
Maven::Tools::Artifact.from_coordinate( 'sdas:das:jar:tes:123:[de:fr,gb:us]' ).to_s.must_equal 'sdas:das:jar:tes:123:[de:fr,gb:us]'
Maven::Tools::Artifact.from_coordinate( 'sdas:das:jar:123:[de:fr,gb:us]' ).to_s.must_equal 'sdas:das:jar:123:[de:fr,gb:us]'
Maven::Tools::Artifact.from_coordinate( 'sdas:das:jar:tes:[123,234]:[de:fr,gb:us]' ).to_s.must_equal 'sdas:das:jar:tes:[123,234]:[de:fr,gb:us]'
Maven::Tools::Artifact.from_coordinate( 'sdas:das:jar:[123,234]:[de:fr,gb:us]' ).to_s.must_equal 'sdas:das:jar:[123,234]:[de:fr,gb:us]'
_(Maven::Tools::Artifact.from_coordinate( 'sdas:das:jar:tes:123' ).to_s).must_equal 'sdas:das:jar:tes:123'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minitest was complaining about deprecated calls

_(Maven::Tools::Artifact.from_coordinate( 'sdas:das:jar:123' ).to_s).must_equal 'sdas:das:jar:123'
_(Maven::Tools::Artifact.from_coordinate( 'sdas:das:jar:tes:[123,234]' ).to_s).must_equal 'sdas:das:jar:tes:[123,234]'
_(Maven::Tools::Artifact.from_coordinate( 'sdas:das:jar:[123,234]' ).to_s).must_equal 'sdas:das:jar:[123,234]'
_(Maven::Tools::Artifact.from_coordinate( 'sdas:das:jar:tes:123:[de:fr,gb:us]' ).to_s).must_equal 'sdas:das:jar:tes:123:[de:fr,gb:us]'
_(Maven::Tools::Artifact.from_coordinate( 'sdas:das:jar:123:[de:fr,gb:us]' ).to_s).must_equal 'sdas:das:jar:123:[de:fr,gb:us]'
_(Maven::Tools::Artifact.from_coordinate( 'sdas:das:jar:tes:[123,234]:[de:fr,gb:us]' ).to_s).must_equal 'sdas:das:jar:tes:[123,234]:[de:fr,gb:us]'
_(Maven::Tools::Artifact.from_coordinate( 'sdas:das:jar:[123,234]:[de:fr,gb:us]' ).to_s).must_equal 'sdas:das:jar:[123,234]:[de:fr,gb:us]'
end

it 'should setup artifact' do
Maven::Tools::Artifact.new( "sdas", "das", "jar", "123", "tes" ).to_s.must_equal 'sdas:das:jar:tes:123'
Maven::Tools::Artifact.new( "sdas", "das", "jar", "123" ).to_s.must_equal 'sdas:das:jar:123'
Maven::Tools::Artifact.new( "sdas.asd", "das", "jar", "123", ["fds:fre"] ).to_s.must_equal 'sdas.asd:das:jar:123:[fds:fre]'
Maven::Tools::Artifact.new( "sdas.asd", "das", "jar","123", "bla", ["fds:fre", "ferf:de"] ).to_s.must_equal 'sdas.asd:das:jar:bla:123:[fds:fre,ferf:de]'
Maven::Tools::Artifact.new( "sdas.asd", "das", "jar", "123", "blub", ["fds:fre", "ferf:de"] ).to_s.must_equal 'sdas.asd:das:jar:blub:123:[fds:fre,ferf:de]'
_(Maven::Tools::Artifact.new( "sdas", "das", "jar", "123", "tes" ).to_s).must_equal 'sdas:das:jar:tes:123'
_(Maven::Tools::Artifact.new( "sdas", "das", "jar", "123" ).to_s).must_equal 'sdas:das:jar:123'
_(Maven::Tools::Artifact.new( "sdas.asd", "das", "jar", "123", ["fds:fre"] ).to_s).must_equal 'sdas.asd:das:jar:123:[fds:fre]'
_(Maven::Tools::Artifact.new( "sdas.asd", "das", "jar","123", "bla", ["fds:fre", "ferf:de"] ).to_s).must_equal 'sdas.asd:das:jar:bla:123:[fds:fre,ferf:de]'
_(Maven::Tools::Artifact.new( "sdas.asd", "das", "jar", "123", "blub", ["fds:fre", "ferf:de"] ).to_s).must_equal 'sdas.asd:das:jar:blub:123:[fds:fre,ferf:de]'
end

it 'should convert ruby version contraints - gems' do
Maven::Tools::Artifact.from( :gem, 'rubygems:asd', '=1' ).to_s.must_equal 'rubygems:asd:gem:[1,1.0.0.0.0.1)'
Maven::Tools::Artifact.from( :gem, 'rubygems:asd', '>=1' ).to_s.must_equal 'rubygems:asd:gem:[1,)'
Maven::Tools::Artifact.from( :gem, 'rubygems:asd', '<=1' ).to_s.must_equal 'rubygems:asd:gem:[0,1]'
Maven::Tools::Artifact.from( :gem, 'rubygems:asd', '>1' ).to_s.must_equal 'rubygems:asd:gem:(1,)'
Maven::Tools::Artifact.from( :gem, 'rubygems:asd', '<1' ).to_s.must_equal 'rubygems:asd:gem:[0,1)'
Maven::Tools::Artifact.from( :gem, 'rubygems:asd', '!=1' ).to_s.must_equal 'rubygems:asd:gem:(1,)'
Maven::Tools::Artifact.from( :gem, 'rubygems:asd', '<2', '>1' ).to_s.must_equal 'rubygems:asd:gem:(1,2)'
Maven::Tools::Artifact.from( :gem, 'rubygems:asd', '<=2', '>1' ).to_s.must_equal 'rubygems:asd:gem:(1,2]'
Maven::Tools::Artifact.from( :gem, 'rubygems:asd', '<2', '>=1' ).to_s.must_equal 'rubygems:asd:gem:[1,2)'
Maven::Tools::Artifact.from( :gem, 'rubygems:asd', '<=2', '>=1' ).to_s.must_equal 'rubygems:asd:gem:[1,2]'
_(Maven::Tools::Artifact.from( :gem, 'rubygems:asd', '=1' ).to_s).must_equal 'rubygems:asd:gem:[1,1.0.0.0.0.1)'
_(Maven::Tools::Artifact.from( :gem, 'rubygems:asd', '>=1' ).to_s).must_equal 'rubygems:asd:gem:[1,)'
_(Maven::Tools::Artifact.from( :gem, 'rubygems:asd', '<=1' ).to_s).must_equal 'rubygems:asd:gem:[0,1]'
_(Maven::Tools::Artifact.from( :gem, 'rubygems:asd', '>1' ).to_s).must_equal 'rubygems:asd:gem:(1,)'
_(Maven::Tools::Artifact.from( :gem, 'rubygems:asd', '<1' ).to_s).must_equal 'rubygems:asd:gem:[0,1)'
_(Maven::Tools::Artifact.from( :gem, 'rubygems:asd', '!=1' ).to_s).must_equal 'rubygems:asd:gem:(1,)'
_(Maven::Tools::Artifact.from( :gem, 'rubygems:asd', '<2', '>1' ).to_s).must_equal 'rubygems:asd:gem:(1,2)'
_(Maven::Tools::Artifact.from( :gem, 'rubygems:asd', '<=2', '>1' ).to_s).must_equal 'rubygems:asd:gem:(1,2]'
_(Maven::Tools::Artifact.from( :gem, 'rubygems:asd', '<2', '>=1' ).to_s).must_equal 'rubygems:asd:gem:[1,2)'
_(Maven::Tools::Artifact.from( :gem, 'rubygems:asd', '<=2', '>=1' ).to_s).must_equal 'rubygems:asd:gem:[1,2]'
end

it 'should convert ruby version contraints - jars' do
Maven::Tools::Artifact.from( :jar, 'org.something:asd', '=1' ).to_s.must_equal 'org.something:asd:jar:[1,1.0.0.0.0.1)'
Maven::Tools::Artifact.from( :jar, 'org.something:asd', '>=1' ).to_s.must_equal 'org.something:asd:jar:[1,)'
Maven::Tools::Artifact.from( :jar, 'org.something:asd', '<=1' ).to_s.must_equal 'org.something:asd:jar:[0,1]'
Maven::Tools::Artifact.from( :jar, 'org.something:asd', '>1' ).to_s.must_equal 'org.something:asd:jar:(1,)'
Maven::Tools::Artifact.from( :jar, 'org.something:asd', '<1' ).to_s.must_equal 'org.something:asd:jar:[0,1)'
Maven::Tools::Artifact.from( :jar, 'org.something:asd', '!=1' ).to_s.must_equal 'org.something:asd:jar:(1,)'
Maven::Tools::Artifact.from( :jar, 'org.something:asd', '<2', '>1' ).to_s.must_equal 'org.something:asd:jar:(1,2)'
Maven::Tools::Artifact.from( :jar, 'org.something:asd', '<=2', '>1' ).to_s.must_equal 'org.something:asd:jar:(1,2]'
Maven::Tools::Artifact.from( :jar, 'org.something:asd', '<2', '>=1' ).to_s.must_equal 'org.something:asd:jar:[1,2)'
Maven::Tools::Artifact.from( :jar, 'org.something:asd', '<=2', '>=1' ).to_s.must_equal 'org.something:asd:jar:[1,2]'
_(Maven::Tools::Artifact.from( :jar, 'org.something:asd', '=1' ).to_s).must_equal 'org.something:asd:jar:[1,1.0.0.0.0.1)'
_(Maven::Tools::Artifact.from( :jar, 'org.something:asd', '>=1' ).to_s).must_equal 'org.something:asd:jar:[1,)'
_(Maven::Tools::Artifact.from( :jar, 'org.something:asd', '<=1' ).to_s).must_equal 'org.something:asd:jar:[0,1]'
_(Maven::Tools::Artifact.from( :jar, 'org.something:asd', '>1' ).to_s).must_equal 'org.something:asd:jar:(1,)'
_(Maven::Tools::Artifact.from( :jar, 'org.something:asd', '<1' ).to_s).must_equal 'org.something:asd:jar:[0,1)'
_(Maven::Tools::Artifact.from( :jar, 'org.something:asd', '!=1' ).to_s).must_equal 'org.something:asd:jar:(1,)'
_(Maven::Tools::Artifact.from( :jar, 'org.something:asd', '<2', '>1' ).to_s).must_equal 'org.something:asd:jar:(1,2)'
_(Maven::Tools::Artifact.from( :jar, 'org.something:asd', '<=2', '>1' ).to_s).must_equal 'org.something:asd:jar:(1,2]'
_(Maven::Tools::Artifact.from( :jar, 'org.something:asd', '<2', '>=1' ).to_s).must_equal 'org.something:asd:jar:[1,2)'
_(Maven::Tools::Artifact.from( :jar, 'org.something:asd', '<=2', '>=1' ).to_s).must_equal 'org.something:asd:jar:[1,2]'
end

it 'passes in scope to artifact' do
a = Maven::Tools::Artifact.from( :jar, 'org.something:asd', '1' )
a.to_s.must_equal 'org.something:asd:jar:1'
_(a.to_s).must_equal 'org.something:asd:jar:1'
a[ :scope ].must_be_nil
a = Maven::Tools::Artifact.from( :jar, 'org.something:asd', '1', :scope => :provided )
a.to_s.must_equal 'org.something:asd:jar:1'
a[ :scope ].must_equal :provided
_(a.to_s).must_equal 'org.something:asd:jar:1'
_(a[ :scope ]).must_equal :provided
end
it 'passes in exclusions to artifact' do
a = Maven::Tools::Artifact.from( :jar, 'org.something:asd', '1' )
a.to_s.must_equal 'org.something:asd:jar:1'
_(a.to_s).must_equal 'org.something:asd:jar:1'
a[ :exclusions ].must_be_nil
a = Maven::Tools::Artifact.from( :jar, 'org.something:asd', '1', :exclusions => ["org.something:dsa"] )
a.to_s.must_equal 'org.something:asd:jar:1:[org.something:dsa]'
a[ :exclusions ].must_equal [ 'org.something:dsa' ]
_(a.to_s).must_equal 'org.something:asd:jar:1:[org.something:dsa]'
_(a[ :exclusions ]).must_equal [ 'org.something:dsa' ]
a = Maven::Tools::Artifact.from( :jar, 'org.something:asd', '1', :exclusions => ["org.something:dsa", "org.anything:qwe"] )
a.to_s.must_equal 'org.something:asd:jar:1:[org.something:dsa,org.anything:qwe]'
a[ :exclusions ].must_equal [ 'org.something:dsa', 'org.anything:qwe' ]
_(a.to_s).must_equal 'org.something:asd:jar:1:[org.something:dsa,org.anything:qwe]'
_(a[ :exclusions ]).must_equal [ 'org.something:dsa', 'org.anything:qwe' ]
end
end
Loading