Hi Gavin,

so, here is the incriminated code in my plugin:

    private Boolean scopesAreValid(Secret secret) {
        return client
        .getAccessKeyScopes(secret)
        .stream()
        .map(AccessKeyScope::getIdentifier)
        .collect(ImmutableList.toImmutableList())
        .containsAll(MANDATORY_SCOPES);
    }

which imports: import com.google.common.collect.ImmutableList;

I thought that the shading would do the switch by itself, but as you hinted
me in your mail, I just tried to change the import with import
shaded.com.google.common.collect.ImmutableList;  and re-run mvn hpi:run,
which gives me the error package shaded.com.google.common.collect does not
exist.

Le mar. 18 août 2020 à 10:42, 'Gavin Mogan' via Jenkins Developers <
[email protected]> a écrit :

> Did you switch your imports to use the new shaded library? Is the object
> coming from your code or external?
>
> If you create the object with the new shaded imports does it have that
> method?
>
> On Tue., Aug. 18, 2020, 1:35 a.m. Goyot, Martin, <[email protected]>
> wrote:
>
>> Yes, you are right sorry.
>>
>> *What did you try ?*
>>
>> So, I have a dependency on guava 29.0-jre. I had a problem due to the
>> Guava in Jenkins so I decided to give shading a try. Here is what I added
>> to my pom.xml:
>>
>>     <build>
>>         <pluginManagement>
>>             <plugins>
>>                 <plugin>
>>                     <groupId>org.codehaus.mojo</groupId>
>>                     <artifactId>findbugs-maven-plugin</artifactId>
>>                     <version>3.0.5</version>
>>                 </plugin>
>>                 <plugin>
>>                     <groupId>org.jenkins-ci.tools</groupId>
>>                     <artifactId>maven-hpi-plugin</artifactId>
>>                 </plugin>
>>             </plugins>
>>         </pluginManagement>
>>         <plugins>
>>             <plugin>
>>                 <groupId>org.apache.maven.plugins</groupId>
>>                 <artifactId>maven-shade-plugin</artifactId>
>>                 <version>3.2.4</version>
>>                 <executions>
>>                     <execution>
>>                         <phase>package</phase>
>>                         <goals>
>>                             <goal>shade</goal>
>>                         </goals>
>>                         <configuration>
>>                             <relocations>
>>                                 <relocation>
>>                                     <pattern>com.google.common</pattern>
>>
>> <shadedPattern>shaded.com.google.common</shadedPattern>
>>                                 </relocation>
>>                             </relocations>
>>                         </configuration>
>>                     </execution>
>>                 </executions>
>>             </plugin>
>>         </plugins>
>>     </build>
>>
>> I then tried to run mvn hpi:run to check if my bug (toImmutableList() no
>> such method) was gone.
>>
>> *What happened ?*
>>
>> The bug still is present, I still get a toImmutableList no such methode.
>> Also, in the trace of the mvn hpi:run I don't see any call to shading,
>> while if I execute mvn package I see it, which seems normal as the selected
>> <phase> is package but then what should I use ?
>>
>> *What did you expect ?*
>>
>> To see the call to shading in the trace, and my bug to be gone.
>>
>> Le lun. 17 août 2020 à 23:11, 'Gavin Mogan' via Jenkins Developers <
>> [email protected]> a écrit :
>>
>>> > But can't seem to get it to work.
>>>
>>> A question online/async question should always include the 3 items:
>>>
>>> What did you try (sorta provided)?
>>> What happened?
>>> What did you expect to happen?
>>>
>>>
>>>
>>> On Mon, Aug 17, 2020 at 5:35 AM Goyot, Martin <[email protected]>
>>> wrote:
>>>
>>>> Hi there,
>>>>
>>>> I have an issue with a dependency on my plugin and would like to shade
>>>> it. I've found the docs here:
>>>> https://www.jenkins.io/doc/developer/plugin-development/dependencies-and-class-loading/#shading
>>>>
>>>> But can't seem to get it to work. Right now I'm trying on Guava, I have
>>>> this in my <build> section in pom.xml:
>>>>
>>>>     <build>
>>>>         <pluginManagement>
>>>>             <plugins>
>>>>                 <plugin>
>>>>                     <groupId>org.codehaus.mojo</groupId>
>>>>                     <artifactId>findbugs-maven-plugin</artifactId>
>>>>                     <version>3.0.5</version>
>>>>                 </plugin>
>>>>                 <plugin>
>>>>                     <groupId>org.jenkins-ci.tools</groupId>
>>>>                     <artifactId>maven-hpi-plugin</artifactId>
>>>>                 </plugin>
>>>>             </plugins>
>>>>         </pluginManagement>
>>>>         <plugins>
>>>>             <plugin>
>>>>                 <groupId>org.apache.maven.plugins</groupId>
>>>>                 <artifactId>maven-shade-plugin</artifactId>
>>>>                 <version>3.2.4</version>
>>>>                 <executions>
>>>>                     <execution>
>>>>                         <phase>package</phase>
>>>>                         <goals>
>>>>                             <goal>shade</goal>
>>>>                         </goals>
>>>>                         <configuration>
>>>>                             <relocations>
>>>>                                 <relocation>
>>>>                                     <pattern>com.google.common</pattern>
>>>>
>>>> <shadedPattern>shaded.com.google.common</shadedPattern>
>>>>                                 </relocation>
>>>>                             </relocations>
>>>>                         </configuration>
>>>>                     </execution>
>>>>                 </executions>
>>>>             </plugin>
>>>>         </plugins>
>>>>     </build>
>>>>
>>>> Any idea on how to proceed ?
>>>>
>>>> Thanks in advance !
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Jenkins Developers" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to [email protected].
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/jenkinsci-dev/CA%2Bb6JB9fZvyE%3DS1ZGtuu3gD%3D13vDgxsc2w_o0TMfV%3DFnRNYLgQ%40mail.gmail.com
>>>> <https://groups.google.com/d/msgid/jenkinsci-dev/CA%2Bb6JB9fZvyE%3DS1ZGtuu3gD%3D13vDgxsc2w_o0TMfV%3DFnRNYLgQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Jenkins Developers" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/jenkinsci-dev/CAG%3D_DuvS1HCY-7V0M8TLdi%2BKHr2jg6jEOhca7WDJmLKxJ-cv8g%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/jenkinsci-dev/CAG%3D_DuvS1HCY-7V0M8TLdi%2BKHr2jg6jEOhca7WDJmLKxJ-cv8g%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Jenkins Developers" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/jenkinsci-dev/CA%2Bb6JB9g140rfL1EGvy9fBCf-GAK-9FJ3zA4f%2B72z89wQnzwWQ%40mail.gmail.com
>> <https://groups.google.com/d/msgid/jenkinsci-dev/CA%2Bb6JB9g140rfL1EGvy9fBCf-GAK-9FJ3zA4f%2B72z89wQnzwWQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Jenkins Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-dev/CAG%3D_DutZZvfbSMbQ%3DZ%3DErH6N55SyjyzrBsYwYz3fBqfB3wF0rw%40mail.gmail.com
> <https://groups.google.com/d/msgid/jenkinsci-dev/CAG%3D_DutZZvfbSMbQ%3DZ%3DErH6N55SyjyzrBsYwYz3fBqfB3wF0rw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/CA%2Bb6JB-5_q%3Dz_cfrAsqqmLAfYtyRPtdwZMoGfVhd5wKz1hHcqA%40mail.gmail.com.

Reply via email to