You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Scott Wilson <ho...@gmail.com> on 2020/01/22 23:59:04 UTC

Maven feature request

*Hi Robert and devs*


*I have been using maven for a few years and I LOVE it!*


*I have a feature request.*


*(1) When adding a dependency to pom.xml the default scope is everywhere*

*ie src/main/java/....*

*and src/tst/java/...*


*(2) When adding <test> as the scope then the dependency can ONLY be used
under src/tst/java...*

*If referencing the dependency in src/main/java/... then it will not
compile*


*(3) My feature request:*

*I want the exact opposite. I'd like a new scope called <main>*

*If the scope is <main> then the dependency can ONLY be used under
src/main/java/...*

*If referencing the dependency in tst/main/java/.... then it will not
compile*


*I read up on scopes
(**https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope
<https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope>)
*and
AFAIK this is not currently supported, but I have a specific reason for
wanting this.


*I'd really appreciate if someone can add that for me and let me know when
it's done.*

*Please let me know if you have any questions.*


*Regards*

*Scott Wilson*

*http://linkedin.com/in/hockeyeh <http://linkedin.com/in/hockeyeh>*

Re: Maven feature request

Posted by Paul Hammant <pa...@hammant.org.INVALID>.
Selenium co-creator here (albeit v1),

WebElement is pubic API and not impl-detail.  If you're making a library
for downstream *testing* teams to use, then selenium-java jumps from
test-scope to prod-scope of course and is now a transitive dep. Many
build/test tools makers are in the same place for "what is our prod code vs
test code".

And in that we-ship-a-lib-that-uses-selenium space, then perhaps there
you're wanting to wrap WebElement. I do so for FluentSelenium -
https://github.com/SeleniumHQ/fluent-selenium/blob/master/java/src/main/java/org/seleniumhq/selenium/fluent/FluentWebElement.java
- but even then I make a getWebElement() for situations where they *really
frickin want to*.

If not a we-ship-a-lib-that-uses-selenium case, then I'm not following -
Selenium is classically a test-scoped thing.

If you're worried about hacker teams quietly promoting selenium-java from
test-scope to no-scope and then those jars quietly being zipped into the
(say) WAR file that heads to production, just use mvn-dependency:tree and
python to discover that's happened, or unzip the uber/shade jar to look for
verbotten classes, and then fail the CI build.



On Thu, Jan 23, 2020 at 11:00 PM Scott Wilson <ho...@gmail.com> wrote:

> Hi Paul
>
> I write test automation and try to stick to a solid design. I find others
> break solid design principles so having a <main> scope will prevent people
> from breaking some basic principles.
>
> For example, if using Selenium I've seen multiple people expose WebElement
> in a public method (that should be a private implementation detail). This
> is just an example of horrible implementation I've seen multiple people do
> without thinking. The new <main> scope will not prevent that however it
> will prevent the following.
>
> I've seen people create src/tst/java/helloworld/MyTest.java which accesses
> a WebElement directly in their Junit / TestNG class. The new <main> scope
> will prevent stuff like that from happening. What they should really do is
> create src/main/java/helloworld/MyPage.java which implements the
> functionality using WebElement, then get an instance of MyPage from their
> src/tst/java/helloworld/MyTest.java.
>
> That is just one obvious example but I've seen other poor implementations
> using other dependencies which are as obvious what is good vs bad design
> unless this principle is understood.
>
> Scott
>
>
>
> On Wed, Jan 22, 2020 at 11:43 PM Karl Heinz Marbaise <kh...@gmx.de>
> wrote:
>
> > Hi,
> >
> > On 23.01.20 00:59, Scott Wilson wrote:
> > > *Hi Robert and devs*
> > >
> > >
> > > *I have been using maven for a few years and I LOVE it!*
> > >
> > >
> > > *I have a feature request.*
> > >
> > >
> > > *(1) When adding a dependency to pom.xml the default scope is
> everywhere*
> > >
> > > *ie src/main/java/....*
> > >
> > > *and src/tst/java/...*
> > >
> > >
> > > *(2) When adding <test> as the scope then the dependency can ONLY be
> used
> > > under src/tst/java...*
> > >
> > > *If referencing the dependency in src/main/java/... then it will not
> > > compile* >
> > >
> > > *(3) My feature request:*
> > >
> > > *I want the exact opposite. I'd like a new scope called <main>*
> > >
> > > *If the scope is <main> then the dependency can ONLY be used under
> > > src/main/java/...*
> > >
> > > *If referencing the dependency in tst/main/java/.... then it will not
> > > compile*
> >
> > This would result in the problem that you neever can run / compile your
> > unit- and integration tests cause something is missing on the classpath
> > so in result your project would be unusable...
> >
> >
> >
> > >
> > >
> > > *I read up on scopes
> > > (**
> >
> https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope
> > > <
> >
> https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope
> > >)
> > > *and
> > > AFAIK this is not currently supported, but I have a specific reason for
> > > wanting this.
> >
> > It would be great if you could shared this with us
> >
> >
> > Kind regards
> > Karl Heinz Marbaise
> >
> >
> > >
> > >
> > > *I'd really appreciate if someone can add that for me and let me know
> > when
> > > it's done.*
> > >
> > > *Please let me know if you have any questions.*
> > >
> > >
> > > *Regards*
> > >
> > > *Scott Wilson*
> > >
> > > *http://linkedin.com/in/hockeyeh <http://linkedin.com/in/hockeyeh>*
> > >
> >
>

Re: Maven feature request

Posted by Scott Wilson <ho...@gmail.com>.
Hi Paul

I write test automation and try to stick to a solid design. I find others
break solid design principles so having a <main> scope will prevent people
from breaking some basic principles.

For example, if using Selenium I've seen multiple people expose WebElement
in a public method (that should be a private implementation detail). This
is just an example of horrible implementation I've seen multiple people do
without thinking. The new <main> scope will not prevent that however it
will prevent the following.

I've seen people create src/tst/java/helloworld/MyTest.java which accesses
a WebElement directly in their Junit / TestNG class. The new <main> scope
will prevent stuff like that from happening. What they should really do is
create src/main/java/helloworld/MyPage.java which implements the
functionality using WebElement, then get an instance of MyPage from their
src/tst/java/helloworld/MyTest.java.

That is just one obvious example but I've seen other poor implementations
using other dependencies which are as obvious what is good vs bad design
unless this principle is understood.

Scott



On Wed, Jan 22, 2020 at 11:43 PM Karl Heinz Marbaise <kh...@gmx.de>
wrote:

> Hi,
>
> On 23.01.20 00:59, Scott Wilson wrote:
> > *Hi Robert and devs*
> >
> >
> > *I have been using maven for a few years and I LOVE it!*
> >
> >
> > *I have a feature request.*
> >
> >
> > *(1) When adding a dependency to pom.xml the default scope is everywhere*
> >
> > *ie src/main/java/....*
> >
> > *and src/tst/java/...*
> >
> >
> > *(2) When adding <test> as the scope then the dependency can ONLY be used
> > under src/tst/java...*
> >
> > *If referencing the dependency in src/main/java/... then it will not
> > compile* >
> >
> > *(3) My feature request:*
> >
> > *I want the exact opposite. I'd like a new scope called <main>*
> >
> > *If the scope is <main> then the dependency can ONLY be used under
> > src/main/java/...*
> >
> > *If referencing the dependency in tst/main/java/.... then it will not
> > compile*
>
> This would result in the problem that you neever can run / compile your
> unit- and integration tests cause something is missing on the classpath
> so in result your project would be unusable...
>
>
>
> >
> >
> > *I read up on scopes
> > (**
> https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope
> > <
> https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope
> >)
> > *and
> > AFAIK this is not currently supported, but I have a specific reason for
> > wanting this.
>
> It would be great if you could shared this with us
>
>
> Kind regards
> Karl Heinz Marbaise
>
>
> >
> >
> > *I'd really appreciate if someone can add that for me and let me know
> when
> > it's done.*
> >
> > *Please let me know if you have any questions.*
> >
> >
> > *Regards*
> >
> > *Scott Wilson*
> >
> > *http://linkedin.com/in/hockeyeh <http://linkedin.com/in/hockeyeh>*
> >
>

Re: Maven feature request

Posted by Karl Heinz Marbaise <kh...@gmx.de>.
Hi,

On 23.01.20 00:59, Scott Wilson wrote:
> *Hi Robert and devs*
>
>
> *I have been using maven for a few years and I LOVE it!*
>
>
> *I have a feature request.*
>
>
> *(1) When adding a dependency to pom.xml the default scope is everywhere*
>
> *ie src/main/java/....*
>
> *and src/tst/java/...*
>
>
> *(2) When adding <test> as the scope then the dependency can ONLY be used
> under src/tst/java...*
>
> *If referencing the dependency in src/main/java/... then it will not
> compile* >
>
> *(3) My feature request:*
>
> *I want the exact opposite. I'd like a new scope called <main>*
>
> *If the scope is <main> then the dependency can ONLY be used under
> src/main/java/...*
>
> *If referencing the dependency in tst/main/java/.... then it will not
> compile*

This would result in the problem that you neever can run / compile your
unit- and integration tests cause something is missing on the classpath
so in result your project would be unusable...



>
>
> *I read up on scopes
> (**https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope
> <https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope>)
> *and
> AFAIK this is not currently supported, but I have a specific reason for
> wanting this.

It would be great if you could shared this with us


Kind regards
Karl Heinz Marbaise


>
>
> *I'd really appreciate if someone can add that for me and let me know when
> it's done.*
>
> *Please let me know if you have any questions.*
>
>
> *Regards*
>
> *Scott Wilson*
>
> *http://linkedin.com/in/hockeyeh <http://linkedin.com/in/hockeyeh>*
>

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


Re: Maven feature request

Posted by Scott Wilson <ho...@gmail.com>.
Wow - thank you Robert. I'll check this out as well.

I will send a LinkedIn connection request to you guys - please accept

Scott



On Sat, Jan 25, 2020 at 3:34 AM Robert Scholte <rf...@apache.org> wrote:

> You might be interested in the bannedDependencies rule[1] of the Maven
> Enforcer Plugin (The Loving Iron Fist of Maven™)
>
> Robert
>
> [1]
> https://maven.apache.org/enforcer/enforcer-rules/bannedDependencies.html
>
> On 25-1-2020 04:48:46, Scott Wilson <ho...@gmail.com> wrote:
> Ok Thank you Elliotte. I've googled checkstyle so will read up on that.
>
> Another solution: I created a dependency-checker.cfg and .sh file that
> looks for my dependencies in the wrong places and fails if it finds any
> violations.
> It's not as elegant as a checkstyle rule but is a starting point and I'll
> figure out the checkstyle.
>
> Hey, if you and the rest of your team would like to connect on linkedin
> I'd love to have you in my network!
> linkedin.com/in/HockeyEh
>
> Scott
> linkedin.com/in/HockeyEh
>
>
>
>
> On Fri, Jan 24, 2020 at 8:34 AM Elliotte Rusty Harold <el...@ibiblio.org>
> wrote:
>
>> That's not going to work for the same reason.
>> classpathDependencyExcludes removes a jar from the classpath, and you
>> need the jar in the classpath, at least in most circumstances. A
>> custom checkstyle rule might solve your problem, but you can't do it
>> by changing the classpath.
>>
>> On Fri, Jan 24, 2020 at 9:19 AM Scott Wilson <ho...@gmail.com> wrote:
>> >
>> > Thank you for replying Elliotte,
>> > I hired someone on Fiverr to try to figure out a workaround for this.
>> He was not successful however he may have been close.  He added
>> <classpathDependencyExcludes> to the build path in the pom.xml. Can you
>> take a look at the attached pom and see if there's anything I can do to
>> make this work? He was using gson in this example.
>> >
>> > Scott
>> >
>> >
>> >
>> > On Fri, Jan 24, 2020 at 5:02 AM Elliotte Rusty Harold <
>> elharo@ibiblio.org> wrote:
>> >>
>> >> That's a really interesting idea and I can see the use of it. I'm not
>> >> sure it fits with how scopes work in Maven or classpaths in Java
>> >> though. A scope generally defines which jars are and are not added to
>> >> the classpaths of which goals/plugins/stages, not which parts of the
>> >> source tree can see what. Perhaps this would work if your proposed
>> >> main scope were added to compile and run but not test? However, I
>> >> suspect the transitive dependencies would still be needed in the
>> >> classpath or the tests will fail with runtime NoClassDefFoundErrors
>> >> and the like.
>> >>
>> >> What you want sounds a little like strict_java_deps in bazel:
>> >> https://blog.bazel.build/2017/06/28/sjd-unused_deps.html
>> >>
>> >> On Thu, Jan 23, 2020 at 2:17 AM Scott Wilson <ho...@gmail.com>
>> wrote:
>> >> >
>> >> > *Hi Robert and devs*
>> >> >
>> >> >
>> >> > *I have been using maven for a few years and I LOVE it!*
>> >> >
>> >> >
>> >> > *I have a feature request.*
>> >> >
>> >> >
>> >> > *(1) When adding a dependency to pom.xml the default scope is
>> everywhere*
>> >> >
>> >> > *ie src/main/java/....*
>> >> >
>> >> > *and src/tst/java/...*
>> >> >
>> >> >
>> >> > *(2) When adding <test> as the scope then the dependency can ONLY be
>> used
>> >> > under src/tst/java...*
>> >> >
>> >> > *If referencing the dependency in src/main/java/... then it will not
>> >> > compile*
>> >> >
>> >> >
>> >> > *(3) My feature request:*
>> >> >
>> >> > *I want the exact opposite. I'd like a new scope called <main>*
>> >> >
>> >> > *If the scope is <main> then the dependency can ONLY be used under
>> >> > src/main/java/...*
>> >> >
>> >> > *If referencing the dependency in tst/main/java/.... then it will not
>> >> > compile*
>> >> >
>> >> >
>> >> > *I read up on scopes
>> >> > (**
>> https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope
>> >> > <
>> https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope
>> >)
>> >> > *and
>> >> > AFAIK this is not currently supported, but I have a specific reason
>> for
>> >> > wanting this.
>> >> >
>> >> >
>> >> > *I'd really appreciate if someone can add that for me and let me
>> know when
>> >> > it's done.*
>> >> >
>> >> > *Please let me know if you have any questions.*
>> >> >
>> >> >
>> >> > *Regards*
>> >> >
>> >> > *Scott Wilson*
>> >> >
>> >> > *http://linkedin.com/in/hockeyeh <http://linkedin.com/in/hockeyeh>*
>> >>
>> >>
>> >>
>> >> --
>> >> Elliotte Rusty Harold
>> >> elharo@ibiblio.org
>>
>>
>>
>> --
>> Elliotte Rusty Harold
>> elharo@ibiblio.org
>>
>

Re: Maven feature request

Posted by Robert Scholte <rf...@apache.org>.
You might be interested in the bannedDependencies rule[1] of the Maven Enforcer Plugin (The Loving Iron Fist of Maven™)

Robert

[1] https://maven.apache.org/enforcer/enforcer-rules/bannedDependencies.html
On 25-1-2020 04:48:46, Scott Wilson <ho...@gmail.com> wrote:
Ok Thank you Elliotte. I've googled checkstyle so will read up on that.

Another solution: I created a dependency-checker.cfg and .sh file that looks for my dependencies in the wrong places and fails if it finds any violations.
It's not as elegant as a checkstyle rule but is a starting point and I'll figure out the checkstyle.

Hey, if you and the rest of your team would like to connect on linkedin I'd love to have you in my network!
linkedin.com/in/HockeyEh [http://linkedin.com/in/HockeyEh]

Scott
linkedin.com/in/HockeyEh [http://linkedin.com/in/HockeyEh]




On Fri, Jan 24, 2020 at 8:34 AM Elliotte Rusty Harold <elharo@ibiblio.org [mailto:elharo@ibiblio.org]> wrote:

That's not going to work for the same reason.
classpathDependencyExcludes removes a jar from the classpath, and you
need the jar in the classpath, at least in most circumstances. A
custom checkstyle rule might solve your problem, but you can't do it
by changing the classpath.

On Fri, Jan 24, 2020 at 9:19 AM Scott Wilson <hockeyeh@gmail.com [mailto:hockeyeh@gmail.com]> wrote:
>
> Thank you for replying Elliotte,
> I hired someone on Fiverr to try to figure out a workaround for this. He was not successful however he may have been close. He added <classpathDependencyExcludes> to the build path in the pom.xml. Can you take a look at the attached pom and see if there's anything I can do to make this work? He was using gson in this example.
>
> Scott
>
>
>
> On Fri, Jan 24, 2020 at 5:02 AM Elliotte Rusty Harold <elharo@ibiblio.org [mailto:elharo@ibiblio.org]> wrote:
>>
>> That's a really interesting idea and I can see the use of it. I'm not
>> sure it fits with how scopes work in Maven or classpaths in Java
>> though. A scope generally defines which jars are and are not added to
>> the classpaths of which goals/plugins/stages, not which parts of the
>> source tree can see what. Perhaps this would work if your proposed
>> main scope were added to compile and run but not test? However, I
>> suspect the transitive dependencies would still be needed in the
>> classpath or the tests will fail with runtime NoClassDefFoundErrors
>> and the like.
>>
>> What you want sounds a little like strict_java_deps in bazel:
>> https://blog.bazel.build/2017/06/28/sjd-unused_deps.html [https://blog.bazel.build/2017/06/28/sjd-unused_deps.html]
>>
>> On Thu, Jan 23, 2020 at 2:17 AM Scott Wilson <hockeyeh@gmail.com [mailto:hockeyeh@gmail.com]> wrote:
>> >
>> > *Hi Robert and devs*
>> >
>> >
>> > *I have been using maven for a few years and I LOVE it!*
>> >
>> >
>> > *I have a feature request.*
>> >
>> >
>> > *(1) When adding a dependency to pom.xml the default scope is everywhere*
>> >
>> > *ie src/main/java/....*
>> >
>> > *and src/tst/java/...*
>> >
>> >
>> > *(2) When adding <test> as the scope then the dependency can ONLY be used
>> > under src/tst/java...*
>> >
>> > *If referencing the dependency in src/main/java/... then it will not
>> > compile*
>> >
>> >
>> > *(3) My feature request:*
>> >
>> > *I want the exact opposite. I'd like a new scope called <main>*
>> >
>> > *If the scope is <main> then the dependency can ONLY be used under
>> > src/main/java/...*
>> >
>> > *If referencing the dependency in tst/main/java/.... then it will not
>> > compile*
>> >
>> >
>> > *I read up on scopes
>> > (**https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope [https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope]
>> > <https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope [https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope]>)
>> > *and
>> > AFAIK this is not currently supported, but I have a specific reason for
>> > wanting this.
>> >
>> >
>> > *I'd really appreciate if someone can add that for me and let me know when
>> > it's done.*
>> >
>> > *Please let me know if you have any questions.*
>> >
>> >
>> > *Regards*
>> >
>> > *Scott Wilson*
>> >
>> > *http://linkedin.com/in/hockeyeh [http://linkedin.com/in/hockeyeh] <http://linkedin.com/in/hockeyeh [http://linkedin.com/in/hockeyeh]>*
>>
>>
>>
>> --
>> Elliotte Rusty Harold
>> elharo@ibiblio.org [mailto:elharo@ibiblio.org]



--
Elliotte Rusty Harold
elharo@ibiblio.org [mailto:elharo@ibiblio.org]

Re: Maven feature request

Posted by Scott Wilson <ho...@gmail.com>.
Ok Thank you Elliotte. I've googled checkstyle so will read up on that.

Another solution: I created a dependency-checker.cfg and .sh file that
looks for my dependencies in the wrong places and fails if it finds any
violations.
It's not as elegant as a checkstyle rule but is a starting point and I'll
figure out the checkstyle.

Hey, if you and the rest of your team would like to connect on linkedin I'd
love to have you in my network!
linkedin.com/in/HockeyEh

Scott
linkedin.com/in/HockeyEh




On Fri, Jan 24, 2020 at 8:34 AM Elliotte Rusty Harold <el...@ibiblio.org>
wrote:

> That's not going to work for the same reason.
> classpathDependencyExcludes removes a jar from the classpath, and you
> need the jar in the classpath, at least in most circumstances. A
> custom checkstyle rule might solve your problem, but you can't do it
> by changing the classpath.
>
> On Fri, Jan 24, 2020 at 9:19 AM Scott Wilson <ho...@gmail.com> wrote:
> >
> > Thank you for replying Elliotte,
> > I hired someone on Fiverr to try to figure out a workaround for this. He
> was not successful however he may have been close.  He added
> <classpathDependencyExcludes> to the build path in the pom.xml. Can you
> take a look at the attached pom and see if there's anything I can do to
> make this work? He was using gson in this example.
> >
> > Scott
> >
> >
> >
> > On Fri, Jan 24, 2020 at 5:02 AM Elliotte Rusty Harold <
> elharo@ibiblio.org> wrote:
> >>
> >> That's a really interesting idea and I can see the use of it. I'm not
> >> sure it fits with how scopes work in Maven or classpaths in Java
> >> though. A scope generally defines which jars are and are not added to
> >> the classpaths of which goals/plugins/stages, not which parts of the
> >> source tree can see what. Perhaps this would work if your proposed
> >> main scope were added to compile and run but not test? However, I
> >> suspect the transitive dependencies would still be needed in the
> >> classpath or the tests will fail with runtime NoClassDefFoundErrors
> >> and the like.
> >>
> >> What you want sounds a little like strict_java_deps in bazel:
> >> https://blog.bazel.build/2017/06/28/sjd-unused_deps.html
> >>
> >> On Thu, Jan 23, 2020 at 2:17 AM Scott Wilson <ho...@gmail.com>
> wrote:
> >> >
> >> > *Hi Robert and devs*
> >> >
> >> >
> >> > *I have been using maven for a few years and I LOVE it!*
> >> >
> >> >
> >> > *I have a feature request.*
> >> >
> >> >
> >> > *(1) When adding a dependency to pom.xml the default scope is
> everywhere*
> >> >
> >> > *ie src/main/java/....*
> >> >
> >> > *and src/tst/java/...*
> >> >
> >> >
> >> > *(2) When adding <test> as the scope then the dependency can ONLY be
> used
> >> > under src/tst/java...*
> >> >
> >> > *If referencing the dependency in src/main/java/... then it will not
> >> > compile*
> >> >
> >> >
> >> > *(3) My feature request:*
> >> >
> >> > *I want the exact opposite. I'd like a new scope called <main>*
> >> >
> >> > *If the scope is <main> then the dependency can ONLY be used under
> >> > src/main/java/...*
> >> >
> >> > *If referencing the dependency in tst/main/java/.... then it will not
> >> > compile*
> >> >
> >> >
> >> > *I read up on scopes
> >> > (**
> https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope
> >> > <
> https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope
> >)
> >> > *and
> >> > AFAIK this is not currently supported, but I have a specific reason
> for
> >> > wanting this.
> >> >
> >> >
> >> > *I'd really appreciate if someone can add that for me and let me know
> when
> >> > it's done.*
> >> >
> >> > *Please let me know if you have any questions.*
> >> >
> >> >
> >> > *Regards*
> >> >
> >> > *Scott Wilson*
> >> >
> >> > *http://linkedin.com/in/hockeyeh <http://linkedin.com/in/hockeyeh>*
> >>
> >>
> >>
> >> --
> >> Elliotte Rusty Harold
> >> elharo@ibiblio.org
>
>
>
> --
> Elliotte Rusty Harold
> elharo@ibiblio.org
>

Re: Maven feature request

Posted by Elliotte Rusty Harold <el...@ibiblio.org>.
That's not going to work for the same reason.
classpathDependencyExcludes removes a jar from the classpath, and you
need the jar in the classpath, at least in most circumstances. A
custom checkstyle rule might solve your problem, but you can't do it
by changing the classpath.

On Fri, Jan 24, 2020 at 9:19 AM Scott Wilson <ho...@gmail.com> wrote:
>
> Thank you for replying Elliotte,
> I hired someone on Fiverr to try to figure out a workaround for this. He was not successful however he may have been close.  He added <classpathDependencyExcludes> to the build path in the pom.xml. Can you take a look at the attached pom and see if there's anything I can do to make this work? He was using gson in this example.
>
> Scott
>
>
>
> On Fri, Jan 24, 2020 at 5:02 AM Elliotte Rusty Harold <el...@ibiblio.org> wrote:
>>
>> That's a really interesting idea and I can see the use of it. I'm not
>> sure it fits with how scopes work in Maven or classpaths in Java
>> though. A scope generally defines which jars are and are not added to
>> the classpaths of which goals/plugins/stages, not which parts of the
>> source tree can see what. Perhaps this would work if your proposed
>> main scope were added to compile and run but not test? However, I
>> suspect the transitive dependencies would still be needed in the
>> classpath or the tests will fail with runtime NoClassDefFoundErrors
>> and the like.
>>
>> What you want sounds a little like strict_java_deps in bazel:
>> https://blog.bazel.build/2017/06/28/sjd-unused_deps.html
>>
>> On Thu, Jan 23, 2020 at 2:17 AM Scott Wilson <ho...@gmail.com> wrote:
>> >
>> > *Hi Robert and devs*
>> >
>> >
>> > *I have been using maven for a few years and I LOVE it!*
>> >
>> >
>> > *I have a feature request.*
>> >
>> >
>> > *(1) When adding a dependency to pom.xml the default scope is everywhere*
>> >
>> > *ie src/main/java/....*
>> >
>> > *and src/tst/java/...*
>> >
>> >
>> > *(2) When adding <test> as the scope then the dependency can ONLY be used
>> > under src/tst/java...*
>> >
>> > *If referencing the dependency in src/main/java/... then it will not
>> > compile*
>> >
>> >
>> > *(3) My feature request:*
>> >
>> > *I want the exact opposite. I'd like a new scope called <main>*
>> >
>> > *If the scope is <main> then the dependency can ONLY be used under
>> > src/main/java/...*
>> >
>> > *If referencing the dependency in tst/main/java/.... then it will not
>> > compile*
>> >
>> >
>> > *I read up on scopes
>> > (**https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope
>> > <https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope>)
>> > *and
>> > AFAIK this is not currently supported, but I have a specific reason for
>> > wanting this.
>> >
>> >
>> > *I'd really appreciate if someone can add that for me and let me know when
>> > it's done.*
>> >
>> > *Please let me know if you have any questions.*
>> >
>> >
>> > *Regards*
>> >
>> > *Scott Wilson*
>> >
>> > *http://linkedin.com/in/hockeyeh <http://linkedin.com/in/hockeyeh>*
>>
>>
>>
>> --
>> Elliotte Rusty Harold
>> elharo@ibiblio.org



-- 
Elliotte Rusty Harold
elharo@ibiblio.org

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


Re: Maven feature request

Posted by Scott Wilson <ho...@gmail.com>.
Thank you for replying Elliotte,
I hired someone on Fiverr to try to figure out a workaround for this. He
was not successful however he may have been close.  He added <
*classpathDependencyExcludes*> to the build path in the pom.xml. Can you
take a look at the attached pom and see if there's anything I can do to
make this work? He was using gson in this example.

Scott



On Fri, Jan 24, 2020 at 5:02 AM Elliotte Rusty Harold <el...@ibiblio.org>
wrote:

> That's a really interesting idea and I can see the use of it. I'm not
> sure it fits with how scopes work in Maven or classpaths in Java
> though. A scope generally defines which jars are and are not added to
> the classpaths of which goals/plugins/stages, not which parts of the
> source tree can see what. Perhaps this would work if your proposed
> main scope were added to compile and run but not test? However, I
> suspect the transitive dependencies would still be needed in the
> classpath or the tests will fail with runtime NoClassDefFoundErrors
> and the like.
>
> What you want sounds a little like strict_java_deps in bazel:
> https://blog.bazel.build/2017/06/28/sjd-unused_deps.html
>
> On Thu, Jan 23, 2020 at 2:17 AM Scott Wilson <ho...@gmail.com> wrote:
> >
> > *Hi Robert and devs*
> >
> >
> > *I have been using maven for a few years and I LOVE it!*
> >
> >
> > *I have a feature request.*
> >
> >
> > *(1) When adding a dependency to pom.xml the default scope is everywhere*
> >
> > *ie src/main/java/....*
> >
> > *and src/tst/java/...*
> >
> >
> > *(2) When adding <test> as the scope then the dependency can ONLY be used
> > under src/tst/java...*
> >
> > *If referencing the dependency in src/main/java/... then it will not
> > compile*
> >
> >
> > *(3) My feature request:*
> >
> > *I want the exact opposite. I'd like a new scope called <main>*
> >
> > *If the scope is <main> then the dependency can ONLY be used under
> > src/main/java/...*
> >
> > *If referencing the dependency in tst/main/java/.... then it will not
> > compile*
> >
> >
> > *I read up on scopes
> > (**
> https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope
> > <
> https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope
> >)
> > *and
> > AFAIK this is not currently supported, but I have a specific reason for
> > wanting this.
> >
> >
> > *I'd really appreciate if someone can add that for me and let me know
> when
> > it's done.*
> >
> > *Please let me know if you have any questions.*
> >
> >
> > *Regards*
> >
> > *Scott Wilson*
> >
> > *http://linkedin.com/in/hockeyeh <http://linkedin.com/in/hockeyeh>*
>
>
>
> --
> Elliotte Rusty Harold
> elharo@ibiblio.org
>

Re: Maven feature request

Posted by Elliotte Rusty Harold <el...@ibiblio.org>.
That's a really interesting idea and I can see the use of it. I'm not
sure it fits with how scopes work in Maven or classpaths in Java
though. A scope generally defines which jars are and are not added to
the classpaths of which goals/plugins/stages, not which parts of the
source tree can see what. Perhaps this would work if your proposed
main scope were added to compile and run but not test? However, I
suspect the transitive dependencies would still be needed in the
classpath or the tests will fail with runtime NoClassDefFoundErrors
and the like.

What you want sounds a little like strict_java_deps in bazel:
https://blog.bazel.build/2017/06/28/sjd-unused_deps.html

On Thu, Jan 23, 2020 at 2:17 AM Scott Wilson <ho...@gmail.com> wrote:
>
> *Hi Robert and devs*
>
>
> *I have been using maven for a few years and I LOVE it!*
>
>
> *I have a feature request.*
>
>
> *(1) When adding a dependency to pom.xml the default scope is everywhere*
>
> *ie src/main/java/....*
>
> *and src/tst/java/...*
>
>
> *(2) When adding <test> as the scope then the dependency can ONLY be used
> under src/tst/java...*
>
> *If referencing the dependency in src/main/java/... then it will not
> compile*
>
>
> *(3) My feature request:*
>
> *I want the exact opposite. I'd like a new scope called <main>*
>
> *If the scope is <main> then the dependency can ONLY be used under
> src/main/java/...*
>
> *If referencing the dependency in tst/main/java/.... then it will not
> compile*
>
>
> *I read up on scopes
> (**https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope
> <https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope>)
> *and
> AFAIK this is not currently supported, but I have a specific reason for
> wanting this.
>
>
> *I'd really appreciate if someone can add that for me and let me know when
> it's done.*
>
> *Please let me know if you have any questions.*
>
>
> *Regards*
>
> *Scott Wilson*
>
> *http://linkedin.com/in/hockeyeh <http://linkedin.com/in/hockeyeh>*



-- 
Elliotte Rusty Harold
elharo@ibiblio.org

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


Re: Maven feature request

Posted by Alexander Bubenchikov <al...@jetbrains.com.INVALID>.
How do you want to run tests? If the dependency is not in classpath of
running tests, but in classpath of main sources, then you just get an
NoClassDefFoundError, isn't it?

For me it looks like you need to put tests into another module,  make it
depend on main module and declare your third-party-dependency as provided.
(And provide it somehow, ofc)

On Thu, Jan 23, 2020 at 10:20 AM Paul Hammant <pa...@hammant.org.invalid>
wrote:

> I'm interested in your need for this. Like, why do you need this?
>
> On Thu, Jan 23, 2020 at 7:17 AM Scott Wilson <ho...@gmail.com> wrote:
>
> > *Hi Robert and devs*
> >
> >
> > *I have been using maven for a few years and I LOVE it!*
> >
> >
> > *I have a feature request.*
> >
> >
> > *(1) When adding a dependency to pom.xml the default scope is everywhere*
> >
> > *ie src/main/java/....*
> >
> > *and src/tst/java/...*
> >
> >
> > *(2) When adding <test> as the scope then the dependency can ONLY be used
> > under src/tst/java...*
> >
> > *If referencing the dependency in src/main/java/... then it will not
> > compile*
> >
> >
> > *(3) My feature request:*
> >
> > *I want the exact opposite. I'd like a new scope called <main>*
> >
> > *If the scope is <main> then the dependency can ONLY be used under
> > src/main/java/...*
> >
> > *If referencing the dependency in tst/main/java/.... then it will not
> > compile*
> >
> >
> > *I read up on scopes
> > (**
> >
> https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope
> > <
> >
> https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope
> > >)
> > *and
> > AFAIK this is not currently supported, but I have a specific reason for
> > wanting this.
> >
> >
> > *I'd really appreciate if someone can add that for me and let me know
> when
> > it's done.*
> >
> > *Please let me know if you have any questions.*
> >
> >
> > *Regards*
> >
> > *Scott Wilson*
> >
> > *http://linkedin.com/in/hockeyeh <http://linkedin.com/in/hockeyeh>*
> >
>


-- 
Alexander Bubenchikov
Software developer
JetBrains
http://www.jetbrains.com
The Drive to Develop

Re: Maven feature request

Posted by Paul Hammant <pa...@hammant.org.INVALID>.
I'm interested in your need for this. Like, why do you need this?

On Thu, Jan 23, 2020 at 7:17 AM Scott Wilson <ho...@gmail.com> wrote:

> *Hi Robert and devs*
>
>
> *I have been using maven for a few years and I LOVE it!*
>
>
> *I have a feature request.*
>
>
> *(1) When adding a dependency to pom.xml the default scope is everywhere*
>
> *ie src/main/java/....*
>
> *and src/tst/java/...*
>
>
> *(2) When adding <test> as the scope then the dependency can ONLY be used
> under src/tst/java...*
>
> *If referencing the dependency in src/main/java/... then it will not
> compile*
>
>
> *(3) My feature request:*
>
> *I want the exact opposite. I'd like a new scope called <main>*
>
> *If the scope is <main> then the dependency can ONLY be used under
> src/main/java/...*
>
> *If referencing the dependency in tst/main/java/.... then it will not
> compile*
>
>
> *I read up on scopes
> (**
> https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope
> <
> https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope
> >)
> *and
> AFAIK this is not currently supported, but I have a specific reason for
> wanting this.
>
>
> *I'd really appreciate if someone can add that for me and let me know when
> it's done.*
>
> *Please let me know if you have any questions.*
>
>
> *Regards*
>
> *Scott Wilson*
>
> *http://linkedin.com/in/hockeyeh <http://linkedin.com/in/hockeyeh>*
>