You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Jason Rutherglen <ja...@gmail.com> on 2012/07/23 06:16:54 UTC

Maven shade transforming internal strings?

I'm shade transforming Apache Solr, which has several dependencies and
seems to work.

However the internal class strings are being transformed, eg
'System.getProperty("os.name");' where 'os.name' is being transformed to '
shade.package.os.name'.  Other than excluding every internal string, how
can I turn off the transformation of internal class strings?

Re: Maven shade transforming internal strings?

Posted by Jason Rutherglen <ja...@gmail.com>.
Wayne, I agree with your point, however I think the include / exclude it
may make sense for them to accept a type such as <include
type="literal">java.lang.Thread</include>.  This gives better fine grained
control of what is being relocated.

On Mon, Jul 23, 2012 at 12:50 PM, Wayne Fay <wa...@gmail.com> wrote:

> > everything except what is in the exclude(s).  It seems like a bug that
> > non-classnames such as string constants are also being sent to the
> > relocator.  Given every string literal is being relocated, I can't
> imagine
> > a pattern to exclude those.
>
> How should Shade handle code like Class.forName("java.lang.Thread")
> unless it also considers (and thus relocates) string constants?
>
> Wayne
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Maven shade transforming internal strings?

Posted by Benson Margulies <bi...@gmail.com>.
On Mon, Jul 23, 2012 at 12:50 PM, Wayne Fay <wa...@gmail.com> wrote:
>> everything except what is in the exclude(s).  It seems like a bug that
>> non-classnames such as string constants are also being sent to the
>> relocator.  Given every string literal is being relocated, I can't imagine
>> a pattern to exclude those.
>
> How should Shade handle code like Class.forName("java.lang.Thread")
> unless it also considers (and thus relocates) string constants?

Since you can also have

   String foo = "java.lang.Thread";

I don't see how we could add selectivity by class receiving the
string. So the only option would be forking the filtering of string
constants, and that makes me squeamish. I really think that a more
selective <package/> is the way to go here.


>
> Wayne
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Maven shade transforming internal strings?

Posted by Wayne Fay <wa...@gmail.com>.
> everything except what is in the exclude(s).  It seems like a bug that
> non-classnames such as string constants are also being sent to the
> relocator.  Given every string literal is being relocated, I can't imagine
> a pattern to exclude those.

How should Shade handle code like Class.forName("java.lang.Thread")
unless it also considers (and thus relocates) string constants?

Wayne

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Maven shade transforming internal strings?

Posted by Jason Rutherglen <ja...@gmail.com>.
For this uber jar, the goal is for it to go hog wild and relocate
everything except what is in the exclude(s).  It seems like a bug that
non-classnames such as string constants are also being sent to the
relocator.  Given every string literal is being relocated, I can't imagine
a pattern to exclude those.

Perhaps it's best include the packages that should be relocated, rather
than exclude the ones that should not be.

It seems like the following code could be the problem, where it should be
passing the type of the 'name'.

Matcher m = classPattern.matcher( name );
if ( m.matches() )
{
  prefix = m.group( 1 ) + "L";
  suffix = ";";
  name = m.group( 2 );
}

for ( Relocator r : relocators )
{
  if ( r.canRelocateClass( name ) )
  {
    value = prefix + r.relocateClass( name ) + suffix;
    break;
  }
  else if ( r.canRelocatePath( name ) )
  {
    value = prefix + r.relocatePath( name ) + suffix;
    break;
  }
}

On Mon, Jul 23, 2012 at 12:01 PM, Benson Margulies <bi...@gmail.com>wrote:

> Hmm.
>
> You don't have a <pattern> element, so shade is going hog-wild. I
> appreciate that you're asking a specific question about controlling
> its behavior for string constants, but is it possible that you could
> come up with a pattern that wouldn't hit things like 'os.name'?
>
>
>
>
>
> On Mon, Jul 23, 2012 at 10:37 AM, Jason Rutherglen
> <ja...@gmail.com> wrote:
> > Hi Benson, This is the xml for the transform:
> >
> > http://pastebin.com/9nx18WiN
> >
> > Thanks!
> >
> > On Mon, Jul 23, 2012 at 10:21 AM, Benson Margulies <
> bimargulies@gmail.com>wrote:
> >
> >> On Mon, Jul 23, 2012 at 12:16 AM, Jason Rutherglen
> >> <ja...@gmail.com> wrote:
> >> > I'm shade transforming Apache Solr, which has several dependencies and
> >> > seems to work.
> >> >
> >> > However the internal class strings are being transformed, eg
> >> > 'System.getProperty("os.name");' where 'os.name' is being transformed
> >> to '
> >> > shade.package.os.name'.  Other than excluding every internal string,
> how
> >> > can I turn off the transformation of internal class strings?
> >>
> >> What were your transformation rules?
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> >> For additional commands, e-mail: users-help@maven.apache.org
> >>
> >>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Maven shade transforming internal strings?

Posted by Benson Margulies <bi...@gmail.com>.
Hmm.

You don't have a <pattern> element, so shade is going hog-wild. I
appreciate that you're asking a specific question about controlling
its behavior for string constants, but is it possible that you could
come up with a pattern that wouldn't hit things like 'os.name'?





On Mon, Jul 23, 2012 at 10:37 AM, Jason Rutherglen
<ja...@gmail.com> wrote:
> Hi Benson, This is the xml for the transform:
>
> http://pastebin.com/9nx18WiN
>
> Thanks!
>
> On Mon, Jul 23, 2012 at 10:21 AM, Benson Margulies <bi...@gmail.com>wrote:
>
>> On Mon, Jul 23, 2012 at 12:16 AM, Jason Rutherglen
>> <ja...@gmail.com> wrote:
>> > I'm shade transforming Apache Solr, which has several dependencies and
>> > seems to work.
>> >
>> > However the internal class strings are being transformed, eg
>> > 'System.getProperty("os.name");' where 'os.name' is being transformed
>> to '
>> > shade.package.os.name'.  Other than excluding every internal string, how
>> > can I turn off the transformation of internal class strings?
>>
>> What were your transformation rules?
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Maven shade transforming internal strings?

Posted by Jason Rutherglen <ja...@gmail.com>.
Hi Benson, This is the xml for the transform:

http://pastebin.com/9nx18WiN

Thanks!

On Mon, Jul 23, 2012 at 10:21 AM, Benson Margulies <bi...@gmail.com>wrote:

> On Mon, Jul 23, 2012 at 12:16 AM, Jason Rutherglen
> <ja...@gmail.com> wrote:
> > I'm shade transforming Apache Solr, which has several dependencies and
> > seems to work.
> >
> > However the internal class strings are being transformed, eg
> > 'System.getProperty("os.name");' where 'os.name' is being transformed
> to '
> > shade.package.os.name'.  Other than excluding every internal string, how
> > can I turn off the transformation of internal class strings?
>
> What were your transformation rules?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Maven shade transforming internal strings?

Posted by Benson Margulies <bi...@gmail.com>.
On Mon, Jul 23, 2012 at 12:16 AM, Jason Rutherglen
<ja...@gmail.com> wrote:
> I'm shade transforming Apache Solr, which has several dependencies and
> seems to work.
>
> However the internal class strings are being transformed, eg
> 'System.getProperty("os.name");' where 'os.name' is being transformed to '
> shade.package.os.name'.  Other than excluding every internal string, how
> can I turn off the transformation of internal class strings?

What were your transformation rules?

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org