Maven: Resolve dependencies using container dependencies first
I have a plugin project
which is added to other container projects
as a dependency.
Now, this plugin project uses many frequent dependencies like spring-security, commons-lang, etc.
Usually, the container projects contain their own versions of such frequent dependencies. So, when we add our plugin dependency there are conflicts and the dependencies are resolved based on regular maven dependency resolver
and depending on scopes
and optional
tags provided in the plugin project dependencies.
Is there a way where all the dependencies are resolved using the version in parent dependencies first and iff they are not available then use the version specified in plugin dependency.
Note: optional and scope runtime have a problem that these dependencies are provided by the container and thus beats the aim to provide a hassle-free single dependency to add plugin dependency.
java maven dependencies dependency-management
|
show 1 more comment
I have a plugin project
which is added to other container projects
as a dependency.
Now, this plugin project uses many frequent dependencies like spring-security, commons-lang, etc.
Usually, the container projects contain their own versions of such frequent dependencies. So, when we add our plugin dependency there are conflicts and the dependencies are resolved based on regular maven dependency resolver
and depending on scopes
and optional
tags provided in the plugin project dependencies.
Is there a way where all the dependencies are resolved using the version in parent dependencies first and iff they are not available then use the version specified in plugin dependency.
Note: optional and scope runtime have a problem that these dependencies are provided by the container and thus beats the aim to provide a hassle-free single dependency to add plugin dependency.
java maven dependencies dependency-management
As I understand, you build the plugin once and add it to container projects? So the container projects (poms) are plugin-specific? Or is it the other way round, you build the plugin for each container using its own pom?
– aschoerk
Nov 26 '18 at 7:51
build the plugin once and add it to container projects
– Aditya Gupta
Nov 26 '18 at 8:22
Why does the scope: provided not work for you. You need to adapt each container anyway, if you need additional artifacts for a specific module. Using scope provided in the plugin-project you can add what is necessary, if necessary and in the version necessary.
– aschoerk
Nov 26 '18 at 11:37
Right now I am using scope-provided. Problem with that approach is that the container/projects have to provide these(around 20 in my case) jars explicitly in their projects.
– Aditya Gupta
Nov 26 '18 at 11:56
Are you already using <properties> to define versions? In that case, at least you can override the versions of the components shared with the container by the container project.
– aschoerk
Nov 26 '18 at 15:22
|
show 1 more comment
I have a plugin project
which is added to other container projects
as a dependency.
Now, this plugin project uses many frequent dependencies like spring-security, commons-lang, etc.
Usually, the container projects contain their own versions of such frequent dependencies. So, when we add our plugin dependency there are conflicts and the dependencies are resolved based on regular maven dependency resolver
and depending on scopes
and optional
tags provided in the plugin project dependencies.
Is there a way where all the dependencies are resolved using the version in parent dependencies first and iff they are not available then use the version specified in plugin dependency.
Note: optional and scope runtime have a problem that these dependencies are provided by the container and thus beats the aim to provide a hassle-free single dependency to add plugin dependency.
java maven dependencies dependency-management
I have a plugin project
which is added to other container projects
as a dependency.
Now, this plugin project uses many frequent dependencies like spring-security, commons-lang, etc.
Usually, the container projects contain their own versions of such frequent dependencies. So, when we add our plugin dependency there are conflicts and the dependencies are resolved based on regular maven dependency resolver
and depending on scopes
and optional
tags provided in the plugin project dependencies.
Is there a way where all the dependencies are resolved using the version in parent dependencies first and iff they are not available then use the version specified in plugin dependency.
Note: optional and scope runtime have a problem that these dependencies are provided by the container and thus beats the aim to provide a hassle-free single dependency to add plugin dependency.
java maven dependencies dependency-management
java maven dependencies dependency-management
asked Nov 26 '18 at 7:25
Aditya GuptaAditya Gupta
8811922
8811922
As I understand, you build the plugin once and add it to container projects? So the container projects (poms) are plugin-specific? Or is it the other way round, you build the plugin for each container using its own pom?
– aschoerk
Nov 26 '18 at 7:51
build the plugin once and add it to container projects
– Aditya Gupta
Nov 26 '18 at 8:22
Why does the scope: provided not work for you. You need to adapt each container anyway, if you need additional artifacts for a specific module. Using scope provided in the plugin-project you can add what is necessary, if necessary and in the version necessary.
– aschoerk
Nov 26 '18 at 11:37
Right now I am using scope-provided. Problem with that approach is that the container/projects have to provide these(around 20 in my case) jars explicitly in their projects.
– Aditya Gupta
Nov 26 '18 at 11:56
Are you already using <properties> to define versions? In that case, at least you can override the versions of the components shared with the container by the container project.
– aschoerk
Nov 26 '18 at 15:22
|
show 1 more comment
As I understand, you build the plugin once and add it to container projects? So the container projects (poms) are plugin-specific? Or is it the other way round, you build the plugin for each container using its own pom?
– aschoerk
Nov 26 '18 at 7:51
build the plugin once and add it to container projects
– Aditya Gupta
Nov 26 '18 at 8:22
Why does the scope: provided not work for you. You need to adapt each container anyway, if you need additional artifacts for a specific module. Using scope provided in the plugin-project you can add what is necessary, if necessary and in the version necessary.
– aschoerk
Nov 26 '18 at 11:37
Right now I am using scope-provided. Problem with that approach is that the container/projects have to provide these(around 20 in my case) jars explicitly in their projects.
– Aditya Gupta
Nov 26 '18 at 11:56
Are you already using <properties> to define versions? In that case, at least you can override the versions of the components shared with the container by the container project.
– aschoerk
Nov 26 '18 at 15:22
As I understand, you build the plugin once and add it to container projects? So the container projects (poms) are plugin-specific? Or is it the other way round, you build the plugin for each container using its own pom?
– aschoerk
Nov 26 '18 at 7:51
As I understand, you build the plugin once and add it to container projects? So the container projects (poms) are plugin-specific? Or is it the other way round, you build the plugin for each container using its own pom?
– aschoerk
Nov 26 '18 at 7:51
build the plugin once and add it to container projects
– Aditya Gupta
Nov 26 '18 at 8:22
build the plugin once and add it to container projects
– Aditya Gupta
Nov 26 '18 at 8:22
Why does the scope: provided not work for you. You need to adapt each container anyway, if you need additional artifacts for a specific module. Using scope provided in the plugin-project you can add what is necessary, if necessary and in the version necessary.
– aschoerk
Nov 26 '18 at 11:37
Why does the scope: provided not work for you. You need to adapt each container anyway, if you need additional artifacts for a specific module. Using scope provided in the plugin-project you can add what is necessary, if necessary and in the version necessary.
– aschoerk
Nov 26 '18 at 11:37
Right now I am using scope-provided. Problem with that approach is that the container/projects have to provide these(around 20 in my case) jars explicitly in their projects.
– Aditya Gupta
Nov 26 '18 at 11:56
Right now I am using scope-provided. Problem with that approach is that the container/projects have to provide these(around 20 in my case) jars explicitly in their projects.
– Aditya Gupta
Nov 26 '18 at 11:56
Are you already using <properties> to define versions? In that case, at least you can override the versions of the components shared with the container by the container project.
– aschoerk
Nov 26 '18 at 15:22
Are you already using <properties> to define versions? In that case, at least you can override the versions of the components shared with the container by the container project.
– aschoerk
Nov 26 '18 at 15:22
|
show 1 more comment
3 Answers
3
active
oldest
votes
In your plugins pom define the version of a dependency as range of the versions you know the plugin to be able to use. If a container-dependency overlaps this will be used. If no overlapping version, of the dependency both container and plugin need, can be found, an error will be produced, since the negotiation failed.
Use no special scope for the dependencies, since you want them to be included if necessary into the container,
See:
https://maven.apache.org/enforcer/enforcer-rules/versionRanges.html
And:
https://books.sonatype.com/mvnref-book/reference/pom-relationships-sect-project-dependencies.html#pom-relationships-sect-version-ranges
So, if I mention that I have a dependency of junit of version>1.4 and the parent does not a dependency of this jar. Will it still give error or resolve by using the latest junit available?
– Aditya Gupta
Nov 27 '18 at 6:58
If you don't use the scope provided, it will use the youngest dependency you defined in the plugin-pom. But be aware of snapshot in your maven-repository. This is best used for dependencies on artifacts you don't develop yourself, or you need to filter out snapshots explicitly.
– aschoerk
Nov 27 '18 at 7:16
Just finished testing this. Works well.
– Aditya Gupta
Nov 27 '18 at 9:08
add a comment |
Assuming that your container and plugin projects use the same parent pom you could utilize the <dependencyManagement>
section in the parent to define the common artifacts. This allows you to omit the version in the plugins <dependencies>
section.
parent:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>group-a</groupId>
<artifactId>artifact-a</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</dependencyManagement>
plugin/module:
<dependencies>
<dependency>
<groupId>group-a</groupId>
<artifactId>artifact-a</artifactId>
</dependency>
</dependencies>
See https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html for further details.
That's a very nice approach and pretty much how we manage our product project. Unfortunately, my plugin project is not a part of the parent project. My intention is to have all dependencies in plugin project as a backup. So only if a dependency version is not available in parent/container project then only dependency version is picked up from my plugin project. I hope that makes sense.
– Aditya Gupta
Nov 26 '18 at 11:36
I'm not sure if I understand correctly. So you can use a shared parent with the container project? If that is the case you could use the approach pointed out and specify the versions only of the artifacts not part of the dependencyManagement section of the parent in your plugin pom.xml.
– DrHopfen
Nov 26 '18 at 12:23
This plugin project is developed separately. So its not a part of parent project hierarchy and does not include the parent pom.
– Aditya Gupta
Nov 26 '18 at 12:29
add a comment |
you can exclude it when you build a plugin project and add a dependency to maven.
This is an example. Dependency and main project have conflicted due to logging library. Below is to exclude log4j in dependency project.
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>${zk.version}</version>
<exclusions>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
</dependency>
P/S: Added from my comments:
I have also developed a system which has a similar architecture with yours. I separate this system into 3 main parts: 1. Commons which contains common code and required maven dependencies, 2. The main project, 3. plugin project. You can refer this.
My plugin project contains 15-20 such dependencies. Excluding them, one by one would explode their pom.xml.
– Aditya Gupta
Nov 26 '18 at 8:20
I have also developed a system which has a similar architecture with yours. I separate this system into 3 main parts: 1. Commons which contains common code and required maven dependencies, 2. Main project, 3. plugin project. You can refer this.
– htpvl
Nov 26 '18 at 8:38
So, my container projects will have to exclude the 15 dependencies while adding plugin dependency. I know about this solution. I am looking for a solution(if possible) where the container does not have to exclude dependencies.
– Aditya Gupta
Nov 26 '18 at 8:44
Check out this link, my solution is the second one. dzone.com/articles/solving-dependency-conflicts-in-maven
– htpvl
Nov 26 '18 at 8:46
I have been through this link. It covers how you can catch dependency conflicts and not how the conflicts could be always resolved using container versions.
– Aditya Gupta
Nov 26 '18 at 9:05
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53476415%2fmaven-resolve-dependencies-using-container-dependencies-first%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
In your plugins pom define the version of a dependency as range of the versions you know the plugin to be able to use. If a container-dependency overlaps this will be used. If no overlapping version, of the dependency both container and plugin need, can be found, an error will be produced, since the negotiation failed.
Use no special scope for the dependencies, since you want them to be included if necessary into the container,
See:
https://maven.apache.org/enforcer/enforcer-rules/versionRanges.html
And:
https://books.sonatype.com/mvnref-book/reference/pom-relationships-sect-project-dependencies.html#pom-relationships-sect-version-ranges
So, if I mention that I have a dependency of junit of version>1.4 and the parent does not a dependency of this jar. Will it still give error or resolve by using the latest junit available?
– Aditya Gupta
Nov 27 '18 at 6:58
If you don't use the scope provided, it will use the youngest dependency you defined in the plugin-pom. But be aware of snapshot in your maven-repository. This is best used for dependencies on artifacts you don't develop yourself, or you need to filter out snapshots explicitly.
– aschoerk
Nov 27 '18 at 7:16
Just finished testing this. Works well.
– Aditya Gupta
Nov 27 '18 at 9:08
add a comment |
In your plugins pom define the version of a dependency as range of the versions you know the plugin to be able to use. If a container-dependency overlaps this will be used. If no overlapping version, of the dependency both container and plugin need, can be found, an error will be produced, since the negotiation failed.
Use no special scope for the dependencies, since you want them to be included if necessary into the container,
See:
https://maven.apache.org/enforcer/enforcer-rules/versionRanges.html
And:
https://books.sonatype.com/mvnref-book/reference/pom-relationships-sect-project-dependencies.html#pom-relationships-sect-version-ranges
So, if I mention that I have a dependency of junit of version>1.4 and the parent does not a dependency of this jar. Will it still give error or resolve by using the latest junit available?
– Aditya Gupta
Nov 27 '18 at 6:58
If you don't use the scope provided, it will use the youngest dependency you defined in the plugin-pom. But be aware of snapshot in your maven-repository. This is best used for dependencies on artifacts you don't develop yourself, or you need to filter out snapshots explicitly.
– aschoerk
Nov 27 '18 at 7:16
Just finished testing this. Works well.
– Aditya Gupta
Nov 27 '18 at 9:08
add a comment |
In your plugins pom define the version of a dependency as range of the versions you know the plugin to be able to use. If a container-dependency overlaps this will be used. If no overlapping version, of the dependency both container and plugin need, can be found, an error will be produced, since the negotiation failed.
Use no special scope for the dependencies, since you want them to be included if necessary into the container,
See:
https://maven.apache.org/enforcer/enforcer-rules/versionRanges.html
And:
https://books.sonatype.com/mvnref-book/reference/pom-relationships-sect-project-dependencies.html#pom-relationships-sect-version-ranges
In your plugins pom define the version of a dependency as range of the versions you know the plugin to be able to use. If a container-dependency overlaps this will be used. If no overlapping version, of the dependency both container and plugin need, can be found, an error will be produced, since the negotiation failed.
Use no special scope for the dependencies, since you want them to be included if necessary into the container,
See:
https://maven.apache.org/enforcer/enforcer-rules/versionRanges.html
And:
https://books.sonatype.com/mvnref-book/reference/pom-relationships-sect-project-dependencies.html#pom-relationships-sect-version-ranges
edited Nov 27 '18 at 12:20
answered Nov 26 '18 at 19:44
aschoerkaschoerk
1,3761524
1,3761524
So, if I mention that I have a dependency of junit of version>1.4 and the parent does not a dependency of this jar. Will it still give error or resolve by using the latest junit available?
– Aditya Gupta
Nov 27 '18 at 6:58
If you don't use the scope provided, it will use the youngest dependency you defined in the plugin-pom. But be aware of snapshot in your maven-repository. This is best used for dependencies on artifacts you don't develop yourself, or you need to filter out snapshots explicitly.
– aschoerk
Nov 27 '18 at 7:16
Just finished testing this. Works well.
– Aditya Gupta
Nov 27 '18 at 9:08
add a comment |
So, if I mention that I have a dependency of junit of version>1.4 and the parent does not a dependency of this jar. Will it still give error or resolve by using the latest junit available?
– Aditya Gupta
Nov 27 '18 at 6:58
If you don't use the scope provided, it will use the youngest dependency you defined in the plugin-pom. But be aware of snapshot in your maven-repository. This is best used for dependencies on artifacts you don't develop yourself, or you need to filter out snapshots explicitly.
– aschoerk
Nov 27 '18 at 7:16
Just finished testing this. Works well.
– Aditya Gupta
Nov 27 '18 at 9:08
So, if I mention that I have a dependency of junit of version>1.4 and the parent does not a dependency of this jar. Will it still give error or resolve by using the latest junit available?
– Aditya Gupta
Nov 27 '18 at 6:58
So, if I mention that I have a dependency of junit of version>1.4 and the parent does not a dependency of this jar. Will it still give error or resolve by using the latest junit available?
– Aditya Gupta
Nov 27 '18 at 6:58
If you don't use the scope provided, it will use the youngest dependency you defined in the plugin-pom. But be aware of snapshot in your maven-repository. This is best used for dependencies on artifacts you don't develop yourself, or you need to filter out snapshots explicitly.
– aschoerk
Nov 27 '18 at 7:16
If you don't use the scope provided, it will use the youngest dependency you defined in the plugin-pom. But be aware of snapshot in your maven-repository. This is best used for dependencies on artifacts you don't develop yourself, or you need to filter out snapshots explicitly.
– aschoerk
Nov 27 '18 at 7:16
Just finished testing this. Works well.
– Aditya Gupta
Nov 27 '18 at 9:08
Just finished testing this. Works well.
– Aditya Gupta
Nov 27 '18 at 9:08
add a comment |
Assuming that your container and plugin projects use the same parent pom you could utilize the <dependencyManagement>
section in the parent to define the common artifacts. This allows you to omit the version in the plugins <dependencies>
section.
parent:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>group-a</groupId>
<artifactId>artifact-a</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</dependencyManagement>
plugin/module:
<dependencies>
<dependency>
<groupId>group-a</groupId>
<artifactId>artifact-a</artifactId>
</dependency>
</dependencies>
See https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html for further details.
That's a very nice approach and pretty much how we manage our product project. Unfortunately, my plugin project is not a part of the parent project. My intention is to have all dependencies in plugin project as a backup. So only if a dependency version is not available in parent/container project then only dependency version is picked up from my plugin project. I hope that makes sense.
– Aditya Gupta
Nov 26 '18 at 11:36
I'm not sure if I understand correctly. So you can use a shared parent with the container project? If that is the case you could use the approach pointed out and specify the versions only of the artifacts not part of the dependencyManagement section of the parent in your plugin pom.xml.
– DrHopfen
Nov 26 '18 at 12:23
This plugin project is developed separately. So its not a part of parent project hierarchy and does not include the parent pom.
– Aditya Gupta
Nov 26 '18 at 12:29
add a comment |
Assuming that your container and plugin projects use the same parent pom you could utilize the <dependencyManagement>
section in the parent to define the common artifacts. This allows you to omit the version in the plugins <dependencies>
section.
parent:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>group-a</groupId>
<artifactId>artifact-a</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</dependencyManagement>
plugin/module:
<dependencies>
<dependency>
<groupId>group-a</groupId>
<artifactId>artifact-a</artifactId>
</dependency>
</dependencies>
See https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html for further details.
That's a very nice approach and pretty much how we manage our product project. Unfortunately, my plugin project is not a part of the parent project. My intention is to have all dependencies in plugin project as a backup. So only if a dependency version is not available in parent/container project then only dependency version is picked up from my plugin project. I hope that makes sense.
– Aditya Gupta
Nov 26 '18 at 11:36
I'm not sure if I understand correctly. So you can use a shared parent with the container project? If that is the case you could use the approach pointed out and specify the versions only of the artifacts not part of the dependencyManagement section of the parent in your plugin pom.xml.
– DrHopfen
Nov 26 '18 at 12:23
This plugin project is developed separately. So its not a part of parent project hierarchy and does not include the parent pom.
– Aditya Gupta
Nov 26 '18 at 12:29
add a comment |
Assuming that your container and plugin projects use the same parent pom you could utilize the <dependencyManagement>
section in the parent to define the common artifacts. This allows you to omit the version in the plugins <dependencies>
section.
parent:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>group-a</groupId>
<artifactId>artifact-a</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</dependencyManagement>
plugin/module:
<dependencies>
<dependency>
<groupId>group-a</groupId>
<artifactId>artifact-a</artifactId>
</dependency>
</dependencies>
See https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html for further details.
Assuming that your container and plugin projects use the same parent pom you could utilize the <dependencyManagement>
section in the parent to define the common artifacts. This allows you to omit the version in the plugins <dependencies>
section.
parent:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>group-a</groupId>
<artifactId>artifact-a</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</dependencyManagement>
plugin/module:
<dependencies>
<dependency>
<groupId>group-a</groupId>
<artifactId>artifact-a</artifactId>
</dependency>
</dependencies>
See https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html for further details.
answered Nov 26 '18 at 11:21
DrHopfenDrHopfen
455210
455210
That's a very nice approach and pretty much how we manage our product project. Unfortunately, my plugin project is not a part of the parent project. My intention is to have all dependencies in plugin project as a backup. So only if a dependency version is not available in parent/container project then only dependency version is picked up from my plugin project. I hope that makes sense.
– Aditya Gupta
Nov 26 '18 at 11:36
I'm not sure if I understand correctly. So you can use a shared parent with the container project? If that is the case you could use the approach pointed out and specify the versions only of the artifacts not part of the dependencyManagement section of the parent in your plugin pom.xml.
– DrHopfen
Nov 26 '18 at 12:23
This plugin project is developed separately. So its not a part of parent project hierarchy and does not include the parent pom.
– Aditya Gupta
Nov 26 '18 at 12:29
add a comment |
That's a very nice approach and pretty much how we manage our product project. Unfortunately, my plugin project is not a part of the parent project. My intention is to have all dependencies in plugin project as a backup. So only if a dependency version is not available in parent/container project then only dependency version is picked up from my plugin project. I hope that makes sense.
– Aditya Gupta
Nov 26 '18 at 11:36
I'm not sure if I understand correctly. So you can use a shared parent with the container project? If that is the case you could use the approach pointed out and specify the versions only of the artifacts not part of the dependencyManagement section of the parent in your plugin pom.xml.
– DrHopfen
Nov 26 '18 at 12:23
This plugin project is developed separately. So its not a part of parent project hierarchy and does not include the parent pom.
– Aditya Gupta
Nov 26 '18 at 12:29
That's a very nice approach and pretty much how we manage our product project. Unfortunately, my plugin project is not a part of the parent project. My intention is to have all dependencies in plugin project as a backup. So only if a dependency version is not available in parent/container project then only dependency version is picked up from my plugin project. I hope that makes sense.
– Aditya Gupta
Nov 26 '18 at 11:36
That's a very nice approach and pretty much how we manage our product project. Unfortunately, my plugin project is not a part of the parent project. My intention is to have all dependencies in plugin project as a backup. So only if a dependency version is not available in parent/container project then only dependency version is picked up from my plugin project. I hope that makes sense.
– Aditya Gupta
Nov 26 '18 at 11:36
I'm not sure if I understand correctly. So you can use a shared parent with the container project? If that is the case you could use the approach pointed out and specify the versions only of the artifacts not part of the dependencyManagement section of the parent in your plugin pom.xml.
– DrHopfen
Nov 26 '18 at 12:23
I'm not sure if I understand correctly. So you can use a shared parent with the container project? If that is the case you could use the approach pointed out and specify the versions only of the artifacts not part of the dependencyManagement section of the parent in your plugin pom.xml.
– DrHopfen
Nov 26 '18 at 12:23
This plugin project is developed separately. So its not a part of parent project hierarchy and does not include the parent pom.
– Aditya Gupta
Nov 26 '18 at 12:29
This plugin project is developed separately. So its not a part of parent project hierarchy and does not include the parent pom.
– Aditya Gupta
Nov 26 '18 at 12:29
add a comment |
you can exclude it when you build a plugin project and add a dependency to maven.
This is an example. Dependency and main project have conflicted due to logging library. Below is to exclude log4j in dependency project.
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>${zk.version}</version>
<exclusions>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
</dependency>
P/S: Added from my comments:
I have also developed a system which has a similar architecture with yours. I separate this system into 3 main parts: 1. Commons which contains common code and required maven dependencies, 2. The main project, 3. plugin project. You can refer this.
My plugin project contains 15-20 such dependencies. Excluding them, one by one would explode their pom.xml.
– Aditya Gupta
Nov 26 '18 at 8:20
I have also developed a system which has a similar architecture with yours. I separate this system into 3 main parts: 1. Commons which contains common code and required maven dependencies, 2. Main project, 3. plugin project. You can refer this.
– htpvl
Nov 26 '18 at 8:38
So, my container projects will have to exclude the 15 dependencies while adding plugin dependency. I know about this solution. I am looking for a solution(if possible) where the container does not have to exclude dependencies.
– Aditya Gupta
Nov 26 '18 at 8:44
Check out this link, my solution is the second one. dzone.com/articles/solving-dependency-conflicts-in-maven
– htpvl
Nov 26 '18 at 8:46
I have been through this link. It covers how you can catch dependency conflicts and not how the conflicts could be always resolved using container versions.
– Aditya Gupta
Nov 26 '18 at 9:05
add a comment |
you can exclude it when you build a plugin project and add a dependency to maven.
This is an example. Dependency and main project have conflicted due to logging library. Below is to exclude log4j in dependency project.
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>${zk.version}</version>
<exclusions>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
</dependency>
P/S: Added from my comments:
I have also developed a system which has a similar architecture with yours. I separate this system into 3 main parts: 1. Commons which contains common code and required maven dependencies, 2. The main project, 3. plugin project. You can refer this.
My plugin project contains 15-20 such dependencies. Excluding them, one by one would explode their pom.xml.
– Aditya Gupta
Nov 26 '18 at 8:20
I have also developed a system which has a similar architecture with yours. I separate this system into 3 main parts: 1. Commons which contains common code and required maven dependencies, 2. Main project, 3. plugin project. You can refer this.
– htpvl
Nov 26 '18 at 8:38
So, my container projects will have to exclude the 15 dependencies while adding plugin dependency. I know about this solution. I am looking for a solution(if possible) where the container does not have to exclude dependencies.
– Aditya Gupta
Nov 26 '18 at 8:44
Check out this link, my solution is the second one. dzone.com/articles/solving-dependency-conflicts-in-maven
– htpvl
Nov 26 '18 at 8:46
I have been through this link. It covers how you can catch dependency conflicts and not how the conflicts could be always resolved using container versions.
– Aditya Gupta
Nov 26 '18 at 9:05
add a comment |
you can exclude it when you build a plugin project and add a dependency to maven.
This is an example. Dependency and main project have conflicted due to logging library. Below is to exclude log4j in dependency project.
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>${zk.version}</version>
<exclusions>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
</dependency>
P/S: Added from my comments:
I have also developed a system which has a similar architecture with yours. I separate this system into 3 main parts: 1. Commons which contains common code and required maven dependencies, 2. The main project, 3. plugin project. You can refer this.
you can exclude it when you build a plugin project and add a dependency to maven.
This is an example. Dependency and main project have conflicted due to logging library. Below is to exclude log4j in dependency project.
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>${zk.version}</version>
<exclusions>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
</dependency>
P/S: Added from my comments:
I have also developed a system which has a similar architecture with yours. I separate this system into 3 main parts: 1. Commons which contains common code and required maven dependencies, 2. The main project, 3. plugin project. You can refer this.
edited Nov 26 '18 at 8:39
answered Nov 26 '18 at 7:45
htpvlhtpvl
647310
647310
My plugin project contains 15-20 such dependencies. Excluding them, one by one would explode their pom.xml.
– Aditya Gupta
Nov 26 '18 at 8:20
I have also developed a system which has a similar architecture with yours. I separate this system into 3 main parts: 1. Commons which contains common code and required maven dependencies, 2. Main project, 3. plugin project. You can refer this.
– htpvl
Nov 26 '18 at 8:38
So, my container projects will have to exclude the 15 dependencies while adding plugin dependency. I know about this solution. I am looking for a solution(if possible) where the container does not have to exclude dependencies.
– Aditya Gupta
Nov 26 '18 at 8:44
Check out this link, my solution is the second one. dzone.com/articles/solving-dependency-conflicts-in-maven
– htpvl
Nov 26 '18 at 8:46
I have been through this link. It covers how you can catch dependency conflicts and not how the conflicts could be always resolved using container versions.
– Aditya Gupta
Nov 26 '18 at 9:05
add a comment |
My plugin project contains 15-20 such dependencies. Excluding them, one by one would explode their pom.xml.
– Aditya Gupta
Nov 26 '18 at 8:20
I have also developed a system which has a similar architecture with yours. I separate this system into 3 main parts: 1. Commons which contains common code and required maven dependencies, 2. Main project, 3. plugin project. You can refer this.
– htpvl
Nov 26 '18 at 8:38
So, my container projects will have to exclude the 15 dependencies while adding plugin dependency. I know about this solution. I am looking for a solution(if possible) where the container does not have to exclude dependencies.
– Aditya Gupta
Nov 26 '18 at 8:44
Check out this link, my solution is the second one. dzone.com/articles/solving-dependency-conflicts-in-maven
– htpvl
Nov 26 '18 at 8:46
I have been through this link. It covers how you can catch dependency conflicts and not how the conflicts could be always resolved using container versions.
– Aditya Gupta
Nov 26 '18 at 9:05
My plugin project contains 15-20 such dependencies. Excluding them, one by one would explode their pom.xml.
– Aditya Gupta
Nov 26 '18 at 8:20
My plugin project contains 15-20 such dependencies. Excluding them, one by one would explode their pom.xml.
– Aditya Gupta
Nov 26 '18 at 8:20
I have also developed a system which has a similar architecture with yours. I separate this system into 3 main parts: 1. Commons which contains common code and required maven dependencies, 2. Main project, 3. plugin project. You can refer this.
– htpvl
Nov 26 '18 at 8:38
I have also developed a system which has a similar architecture with yours. I separate this system into 3 main parts: 1. Commons which contains common code and required maven dependencies, 2. Main project, 3. plugin project. You can refer this.
– htpvl
Nov 26 '18 at 8:38
So, my container projects will have to exclude the 15 dependencies while adding plugin dependency. I know about this solution. I am looking for a solution(if possible) where the container does not have to exclude dependencies.
– Aditya Gupta
Nov 26 '18 at 8:44
So, my container projects will have to exclude the 15 dependencies while adding plugin dependency. I know about this solution. I am looking for a solution(if possible) where the container does not have to exclude dependencies.
– Aditya Gupta
Nov 26 '18 at 8:44
Check out this link, my solution is the second one. dzone.com/articles/solving-dependency-conflicts-in-maven
– htpvl
Nov 26 '18 at 8:46
Check out this link, my solution is the second one. dzone.com/articles/solving-dependency-conflicts-in-maven
– htpvl
Nov 26 '18 at 8:46
I have been through this link. It covers how you can catch dependency conflicts and not how the conflicts could be always resolved using container versions.
– Aditya Gupta
Nov 26 '18 at 9:05
I have been through this link. It covers how you can catch dependency conflicts and not how the conflicts could be always resolved using container versions.
– Aditya Gupta
Nov 26 '18 at 9:05
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53476415%2fmaven-resolve-dependencies-using-container-dependencies-first%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
As I understand, you build the plugin once and add it to container projects? So the container projects (poms) are plugin-specific? Or is it the other way round, you build the plugin for each container using its own pom?
– aschoerk
Nov 26 '18 at 7:51
build the plugin once and add it to container projects
– Aditya Gupta
Nov 26 '18 at 8:22
Why does the scope: provided not work for you. You need to adapt each container anyway, if you need additional artifacts for a specific module. Using scope provided in the plugin-project you can add what is necessary, if necessary and in the version necessary.
– aschoerk
Nov 26 '18 at 11:37
Right now I am using scope-provided. Problem with that approach is that the container/projects have to provide these(around 20 in my case) jars explicitly in their projects.
– Aditya Gupta
Nov 26 '18 at 11:56
Are you already using <properties> to define versions? In that case, at least you can override the versions of the components shared with the container by the container project.
– aschoerk
Nov 26 '18 at 15:22