0

If I have a file that is in

package com.my.stuff.tests.stuffone;

Is there anyway to make a pom dependency apply to that one package only and not to the other

        <dependency>
            <groupId>org.some.library</groupId>
            <artifactId>some-artifact</artifactId>
            <version>1</version>
            // apply to com.my.stuff.tests.stuffone;
        </dependency>

        <dependency>
            <groupId>org.some.library</groupId>
            <artifactId>some-artifact</artifactId>
            <version>2</version>
            // apply to all other package
        </dependency>
user10714010
  • 865
  • 2
  • 13
  • 20
  • you'd probably need to use shading https://maven.apache.org/plugins/maven-shade-plugin/ to create your own non-conflicting version. – Darren Forsythe Feb 15 '19 at 19:38
  • 3
    Possible duplicate of [Multiple versions of the same dependency in Maven](https://stackoverflow.com/questions/24962607/multiple-versions-of-the-same-dependency-in-maven) – Roland Weisleder Feb 15 '19 at 19:46

1 Answers1

1

Nope - packages in java are simply organizational structures for code, they don't have any other properties.

Once a Jar (dependency) is on the classpath, it's available to the class loader and all other classes under the same class loader (e.g. all other packages).

hovanessyan
  • 30,580
  • 6
  • 55
  • 83