groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Richard Heintze <sieg_hein...@yahoo.com>
Subject Re: Wanted: Help converting groovy script to "groovy -e"
Date Tue, 20 Oct 2015 00:35:38 GMT
Well can I make it a bug by filing a bug report somewhere? 


     On Monday, October 19, 2015 3:42 AM, Thibault Kruse <tibokruse@googlemail.com>
wrote:
   

 Your problem is (possibly) a bug, but my solution is a feature
request. Just because my feature request would also fix your bug does
not mean that your bug should be fixed using my feature request (in
particular if my feature request would cause different bugs).

On Mon, Oct 19, 2015 at 4:58 AM, Richard Heintze <sieg_heintze@yahoo.com> wrote:
> Why is this not a bug?
> When I try to use the groovy.grapes.Grap.grab with "groovy -e" it does not
> work for me. It does work for you because you fixed it Where is the new
> feature? "groovy -e" is old and grapes are old.
>
>
>
> On Friday, October 16, 2015 12:53 AM, Thibault Kruse
> <tibokruse@googlemail.com> wrote:
>
>
> Groovy has many automated tests, but being a programming language it is
> difficult to ever have enough tests.
> My pull request also was tested that way, you can see that on github.
>
> However so far we talk about a feature request, not a bug.
>
> Changing classloader behavior is nothing anyone should treat lightly, nor
> can the existing automated tests give sufficient confidence. So someone with
> enough overview and experience will have to review.
>
>
>
> On Thursday, October 15, 2015, Richard Heintze <sieg_heintze@yahoo.com>
> wrote:
>
> Thank you Thibault. So who does the testing for the groovy project? Are
> there dedicating testers or is this done by developers? So someone needs to
> run some automated (or *yikes* manual!) tests! Is this on someone's to do
> list? If not, whose "to do" list does it need to be on?
>
> Since this is a known bug with a known fix, is it on the list for the next
> release of groovy?
>
> Thanks Siegfried
>
>
>
> On Sunday, October 11, 2015 11:16 AM, Thibault Kruse
> <tibokruse@googlemail.com> wrote:
>
>
> sorry if some of my mails did not go on this list, that was not
> intentional. Yes, #104 is still awaiting review, and it is only one
> commit therein that is of relevance
> (https://github.com/tkruse/incubator-groovy/commit/c1a2b74839f9c).
>
> The commit would cause Grapes to add new classes to a higher
> Classloader in the hierarchy than now.
>
> The main question is whether this could realistically break anyone's
> client code.
>
>
> On Sun, Oct 11, 2015 at 7:41 PM, Richard Heintze <sieg_heintze@yahoo.com>
> wrote:
>> According to the title of a earlier response from Thibault in this email
>> chain, this is concerning
>> https://github.com/apache/incubator-groovy/pull/104 (although after
>> reviewing it again I would not have known it unless he had said so).
>> According to my conversations with Thibault (again in this email chain)
>> fixing the tab completion also fixes the broken grapes in the groovy
>> command
>> line "-e" switch. I would like to use grapes in my "groovy -e
>> 'groovy.grapes.Grape.Grap....'" command and Thibault explained that this
>> was
>> fixed in his fork because of his fixes but was awaiting for a review to be
>> merged into main. So it has been month and a half so far. Is someone
>> planning on approving (or at least reviewing) Thibault's merge soon so I
>> can
>> download it?
>>
>> Thanks
>> Siegfried
>>
>>
>>
>> On Friday, October 9, 2015 9:12 AM, Pascal Schumacher
>> <pascalschumacher@gmx.net> wrote:
>>
>>
>> Hi Siegfried,
>>
>> I guess you are talking about
>> https://github.com/apache/incubator-groovy/pull/104 or more specific this
>> commit:
>>
>> https://github.com/tkruse/incubator-groovy/commit/c1a2b74839f9c4539d772c311af7acc39c9e41a1
>> (Grapes: Select higher-level classloader to add new URLs to. )?
>>
>> -Pascal
>>
>> Am 08.10.2015 um 03:35 schrieb Richard Heintze:
>>
>>
>> Can someone give me an update getting Thibault's fix (patch) to my problem
>> into a release? Last Thibault explained to me (in a private email) was
>> that
>> he had implemented the fix (before I discovered the problem) but was
>> waiting
>> for someone with more expertise in class loaders to merge his changes into
>> the main stream.
>>
>> Thanks
>> Siegfried
>>
>> On Monday, September 7, 2015 2:50 PM, Pascal Schumacher
>> <pascalschumacher@gmx.net> wrote:
>>
>>
>> Hi Richard,
>>
>> you can download groovy snapshots from
>> https://oss.jfrog.org/oss-snapshot-local/org/codehaus/groovy/
>>
>> -Pascal
>>
>> Am 07.09.2015 um 23:43 schrieb Richard Heintze:
>>
>> Thibault:
>> Can you help me reproduce your environment?
>> (1) I cannot find groovy 2.5.0-Snapshot on
>> http://groovy-lang.org/download.html#distro .  Do I need 2.5.0-Snapshot or
>> will 2.4.4 do? Can I download 2.5.0 without having to build it myself? Is
>> it
>> difficult to build on windows? Where do I download it from?
>> (2) I'm confused about that link: it just takes me to the mailing list
>> page.
>> Can you give a link to the patch?
>> Thanks
>> siegfried
>>
>>
>>
>> On Saturday, September 5, 2015 10:41 AM, Thibault Kruse
>> <tibokruse@googlemail.com> wrote:
>>
>>
>> Actually, sorry, this was using Groovy 2.5.0-SNAPSHOT from master.
>> With my patch to Grape classloading.
>>
>> http://groovy.329449.n5.nabble.com/groovysh-import-completion-for-Grape-loaded-classes-td5727025.html
>>
>> With 2.4.x, I get Caught: java.sql.SQLException: No suitable driver
>> found for jdbc:h2:mem:test_mem
>>
>> So I guess my patch for grapes does the same as you do.
>>
>> On Sat, Sep 5, 2015 at 7:12 PM, Richard Heintze <sieg_heintze@yahoo.com>
>> wrote:
>>> Well shucks! I just cut and pasted your code to windows/Cygwin and then
>>> to
>>> Ubuntu. I got the exact same results on both machines!
>>>
>>>  What version and which Linux are you using? What version of groovy?
>>>
>>> Can anyone else detect what I am doing wrong?
>>>
>>>
>>> groovy -e "import groovy.xml.MarkupBuilder;
>>> import groovy.sql.Sql
>>> groovy.grape.Grape.grab(group:'com.h2database', module:'h2',
>>> version:'1.4.188')
>>> def sql = Sql.newInstance('jdbc:h2:mem:test_mem', 'sa', '',
>>> 'org.h2.Driver');
>>> println(sql)
>>> "
>>> Caught: java.lang.ClassNotFoundException: org.h2.Driver
>>> java.lang.ClassNotFoundException: org.h2.Driver
>>>  at script_from_command_line.run(script_from_command_line:4)
>>>
>>> Process compilation exited abnormally with code 1
>>>
>>>
>>>
>>> On Saturday, September 5, 2015 2:07 AM, Thibault Kruse
>>> <tibokruse@googlemail.com> wrote:
>>>
>>>
>>> I am not sure what the classloader business is about. I get your -e
>>> examplke running on Linux:
>>>
>>> $ groovy -e "import groovy.xml.MarkupBuilder;
>>> import groovy.sql.Sql
>>> groovy.grape.Grape.grab(group:'com.h2database', module:'h2',
>>> version:'1.4.188')
>>> def sql = Sql.newInstance('jdbc:h2:mem:test_mem', 'sa', '',
>>> 'org.h2.Driver');
>>> println(sql)
>>> "
>>> groovy.sql.Sql@6ba2507
>>>
>>> On Fri, Sep 4, 2015 at 6:13 PM, Richard Heintze <sieg_heintze@yahoo.com>
>>> wrote:
>>>>
>>>> The script below works with groovy 2.3.0-beta-2 with the groovy program.
>>>> I
>>>> want to move the SQL code to separate text files and execute it from (1)
>>>> "groovy -e" (2) groovy-console and (3) groovysh.
>>>>
>>>> After looking at
>>>>
>>>>
>>>>
>>>> http://www.techper.net/2010/04/19/groovy-grape-adding-dependencies-to-root-classloader/
>>>> here is my first attempt using Cygwin on windows 8 and groovy that is
>>>> not
>>>> working:
>>>>
>>>>
>>>> groovy -e "import groovy.sql.Sql
>>>> import groovy.xml.MarkupBuilder;
>>>> import groovy.sql.Sql
>>>>
>>>> def classLoader = this.getClass().getClassLoader();
>>>> while
>>>>
>>>>
>>>>
>>>> (!classLoader.getClass().getName().equals('org.codehaus.groovy.tools.RootLoader'))
>>>> {
>>>>  classLoader = classLoader.getParent()
>>>> }
>>>> groovy.grape.Grape.grab(group:'com.h2database', module:'h2',
>>>> version:'1.4.188')
>>>> def sql = Sql.newInstance('jdbc:h2:mem:test_mem', 'sa', '',
>>>> 'org.h2.Driver');"
>>>> Caught: java.lang.ClassNotFoundException: org.h2.Driver
>>>> java.lang.ClassNotFoundException: org.h2.Driver
>>>>  at script_from_command_line.run(script_from_command_line:10)
>>>>
>>>>
>>>> As you can see, I'm trying to convert the @GrabConfig which does not
>>>> seem
>>>> to
>>>> work with "groovy -e".
>>>>
>>>>
>>>> Thanks
>>>> Siegfried
>>>>
>>>>
>>>>
>>>>
>>>> This works:
>>>>
>>>> import groovy.sql.Sql
>>>> import groovy.xml.MarkupBuilder
>>>> @GrabConfig(systemClassLoader=true)
>>>> @Grab(group='com.h2database', module='h2', version='1.4.188')
>>>> sqltext = ["""
>>>> create table gov_unit (
>>>>  id  integer NOT NULL,
>>>>  parent_id integer DEFAULT 3,
>>>>  name  varchar(10),
>>>>  type  varchar(8),
>>>>  constraint gov_unit_pk
>>>>  primary key (id),
>>>>  constraint gov_unit_type_chk
>>>>  check (type in ('County','Township','City','State')),
>>>>        constraint gov_unit_loop
>>>>                foreign key (parent_id)
>>>>                references gov_unit
>>>>  );
>>>> insert into gov_unit values (3,null,'Michigan','State');
>>>> insert into gov_unit values (2,3,'Alger','County');
>>>> insert into gov_unit values (1,2,'Munising','City');
>>>> insert into gov_unit values (4,2,'Munising','Township');
>>>> insert into gov_unit values (5,2,'Au Train','Township');
>>>> insert into gov_unit values (6,3,'Baraga','County');
>>>> insert into gov_unit values (7,3,'Ontonagon','County');
>>>> insert into gov_unit values (8,7,'Interior','Township');
>>>> insert into gov_unit values (9,3,'Dickinson','County');
>>>> insert into gov_unit values (10,3,'Gogebic','County');
>>>> insert into gov_unit values (11,3,'Delta','County');
>>>> insert into gov_unit values (12,11,'Masonville','Township');
>>>> ""","""
>>>> WITH RECURSIVE gov (depth, id, parent_id, name, type) AS(
>>>>    SELECT 1 AS depth, parent.* FROM gov_unit parent WHERE
>>>> parent.parent_id
>>>> IS NULL
>>>>  UNION ALL
>>>>    SELECT parent.depth+1 AS depth, child.* FROM  gov parent, gov_unit
>>>> child
>>>> WHERE child.parent_id = parent.id
>>>> )
>>>> SELECT * FROM gov ;
>>>> """]
>>>>
>>>> def sql = Sql.newInstance("jdbc:h2:mem:test_mem", "sa", "",
>>>> "org.h2.Driver")
>>>> sql.execute sqltext[0]
>>>>
>>>> def xml = new groovy.xml.MarkupBuilder(new
>>>> FileWriter(java.io.FileDescriptor.out))
>>>>
>>>> xml.table (name:"gov_unit") {
>>>>  sql.rows(sqltext[1]).each{ row->
>>>>    xml.gov_unit (
>>>>    row
>>>>    ) }
>>>> }
>>>
>>>
>>
>>
>>
>>
>>
>>
>>
>>
>
>
>
>


  
Mime
View raw message