Dependency Graph in Spring Tool suite4 using Maven - spring

I am working on resolving duplicate dependency issue. While solving I come to know that using dependency graph it will be easy. But I am not getting how to print a dependency Graph in STS4.
I have tried this command which I found in Maven Documentation
mvn dependency:tree -Dverbose -Dincludes=commons-collections
which is resulting :
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # attache-ui-web ---
[WARNING] Invalid POM for com.apple.ist.msol.attache:attache-api-entity:jar:3.0.0-SNAPSHOT, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] Invalid POM for com.apple.ist.msol.attache:attache-api-entity:jar:3.0.0-SNAPSHOT, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10.972 s
[INFO] Finished at: 2019-09-17T09:30:23+05:30
[INFO] ------------------------------------------------------------------------
Can someone explain what does this result exactly mean and how to get dependency tree ?

When you open the pom.xml file in Eclipse/STS3/STS4, there is a tab to list all the dependencies as well as a tab for the dependency hierarchy. It shows you all the dependencies that you declared in your project as root nodes and their transitive dependencies as sub-nodes.

Related

Building Gluon Apps in Multi-Module Project

TL;DR: How does one build a Gluon app that's part of a larger multi-module project?
I have a multi-module Mave project (that is, my top-level POM has "<packaging>pom</packaging>"). The project contains a bunch of libraries and related sub-projects, one of which is a Gluon app that will be what my actual users install. (The rest of the project is all the cloud-hosted plumbing that the client app connects to.)
When I try to build the Gluon app, per the Gluon documentation, I am getting the following error:
mvn gluonfx:build
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] app [pom]
[INFO] app-common [jar]
[INFO] app-server [jar]
[INFO] app-client [jar]
[INFO] app-test [jar]
[INFO] app-utilities [jar]
[INFO] app-integration-lambda [jar]
[INFO] app-integration-jakarta [war]
[INFO] app-gluon [jar]
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for app 0.9:
[INFO]
[INFO] app ............................................ SKIPPED
[INFO] app-common ..................................... SKIPPED
[INFO] app-server ..................................... SKIPPED
[INFO] app-client ..................................... SKIPPED
[INFO] app-test ....................................... SKIPPED
[INFO] app-utilities .................................. SKIPPED
[INFO] app-integration-lambda ......................... SKIPPED
[INFO] app-integration-jakarta ........................ SKIPPED
[INFO] app-gluon ...................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.298 s
[INFO] Finished at: 2022-02-22T21:03:18+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] No plugin found for prefix 'gluonfx' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (C:\Users\Administrator\.m2\repository), central (https://repo.maven.apache.org/maven2)] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoPluginFoundForPrefixException
If I run Maven so that it only builds the Gluon application instead, like this:
mvn gluonfx:build --projects "app-gluon" --also-make
I get basically the same error. If I cd to app-gluon first, I get a different error (and I didn't expect this to work anyhow):
cd app-gluon
mvn gluonfx:build
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------< com.whatever:app-gluon >--------------------
[INFO] Building app-gluon 0.9
[INFO] --------------------------------[ jar ]---------------------------------
[WARNING] The POM for com.whatever:app-common:jar:0.9 is missing, no dependency information available
[WARNING] The POM for com.whatever:app-client:jar:0.9 is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.380 s
[INFO] Finished at: 2022-02-22T21:09:12+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project app-gluon: Could not resolve dependencies for project com.whatever:app-gluon:jar:0.9: The following artifacts could not be
resolved: com.whatever:app-common:jar:0.9, com.whatever:app-client:jar:0.9: com.whatever:app-common:jar:0.9 was not found in https://nexus.gluonhq.com/nexus/
content/repositories/releases during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of Gluon has elapsed or updates are forced -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
So my question is: how does one build a Gluon app that's part of a larger multi-module project?
If you have a multi module project, and your app module depends on other modules, you need to publish those modules to a repository, so the app module finds them, like any other third party dependency.
Typically, for local development, you can simply use mvn install from the root folder to deploy your project locally. Of course, for distribution, you should consider publishing them to a reachable repository.
Make sure all your modules are deployed to your ~/.m2 repository.
Then you can run from the root:
mvn gluonfx:build -f app-gluon
or enter in the app-gluon folder:
cd app-gluon
mvn gluonfx:build
And remember that every time you make any change to the other modules, you will need to publish them again before building the native image.
Also, since you can run your app on the JVM, before building the native image (which takes a couple of minutes), you can simply run and test:
mvn gluonfx:run
and if that works fine, do the native image build.

Downloading ear file from nexus using maven dependency plugin get goal

I am using the maven dependency plugin get goal to download an artefact from nexus. I can use it to download jar as per below
mvn org.apache.maven.plugins:maven-dependency-plugin:2.8:get -DrepoUrl=http://nexus.url/nexus/content/groups/public-all/ -Dartifact=groupId:artifactId:version:jar -Dtransitive=false -Ddestination=/my/path
To download a war I can use
mvn org.apache.maven.plugins:maven-dependency-plugin:2.8:get -DrepoUrl=http://nexus.url/nexus/content/groups/public-all/ -Dartifact=groupId:artifactId:version:war -Dtransitive=false -Ddestination=/my/path
I am however failing to download an ear using the following
mvn org.apache.maven.plugins:maven-dependency-plugin:2.8:get -DrepoUrl=http://nexus.url/nexus/content/groups/public-all/ -Dartifact=groupId:artifactId:version:ear -Dtransitive=false -Ddestination=/my/path
The output of the above command is as per below
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:get (default-cli) # standalone-pom ---
[INFO] Resolving groupId:artifactId:ear:version
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.797 s
[INFO] Finished at: 2017-10-20T13:31:02+02:00
[INFO] Final Memory: 7M/19M
[INFO] ------------------------------------------------------------------------
I have confirmed that the ear is indeed present in Nexus. The above command runs successfully but the ear is not actually downloaded.
What is wrong with the above command to download the ear? How can I download an ear file from Nexus using the mvn command?
Do note that I have replaced the actual groupId, artifactId and versions in the code above with their respective words.

Cannot perform 'mvn camel:run' on Camel Example Project

I am new to camel and I've been trying to run one of the examples found in camel called camel-example-twitter-websocket, which may be found here.
When I run mvn compile it works successfully
$ mvn compile
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Camel :: Example :: Twitter WebSocket 2.17-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-enforcer-plugin:1.4:enforce (enforce-maven) # camel-example-twitter-websocket ---
[INFO]
[INFO] --- maven-bundle-plugin:2.3.7:cleanVersions (versions) # camel-example-twitter-websocket ---
[INFO]
[INFO] --- maven-remote-resources-plugin:1.5:process (default) # camel-example-twitter-websocket ---
[INFO]
[INFO] --- maven-resources-plugin:2.7:resources (default-resources) # camel-example-twitter-websocket ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 4 resources
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-resources-plugin:2.7:resources (default) # camel-example-twitter-websocket ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 4 resources
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.5.1:compile (default-compile) # camel-example-twitter-websocket ---
[INFO] Nothing to compile - all classes are up to date
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.504 s
[INFO] Finished at: 2016-03-18T15:27:30-04:00
[INFO] Final Memory: 22M/437M
[INFO] ------------------------------------------------------------------------
But when I run the second step mvn camel:run it does not work and I get the following output
$ mvn camel:run
[INFO] Scanning for projects...
[WARNING] The POM for org.apache.camel:camel-maven-plugin:jar:2.17-20151107.033312-28 is invalid, transitive dependencies (if any) will not be av ailable, enable debug logging for more details
[WARNING] Failed to retrieve plugin descriptor for org.apache.camel:camel-maven-plugin:2.17-SNAPSHOT: Plugin org.apache.camel:camel-maven-plugin: 2.17-SNAPSHOT or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.camel:camel-maven-plugin:jar:2. 17-SNAPSHOT
[WARNING] The POM for org.eclipse.m2e:lifecycle-mapping:jar:1.0.0 is missing, no dependency information available
[WARNING] Failed to retrieve plugin descriptor for org.eclipse.m2e:lifecycle-mapping:1.0.0: Plugin org.eclipse.m2e:lifecycle-mapping:1.0.0 or one of its dependencies could not be resolved: Failure to find org.eclipse.m2e:lifecycle-mapping:jar:1.0.0 in https://repo.maven.apache.org/maven2 w as cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced
[WARNING] The POM for org.apache.maven.plugins:maven-surefire-plugin:jar:{maven-surefire-plugin-version} is missing, no dependency information av ailable
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-surefire-plugin:{maven-surefire-plugin-version}: Plugin org.apa che.maven.plugins:maven-surefire-plugin:{maven-surefire-plugin-version} or one of its dependencies could not be resolved: Failure to find org.apa che.maven.plugins:maven-surefire-plugin:jar:{maven-surefire-plugin-version} in https://repo.maven.apache.org/maven2 was cached in the local repos itory, resolution will not be reattempted until the update interval of central has elapsed or updates are forced
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-metadata.xml
Downloading: https://repository.apache.org/content/repositories/snapshots/org/apache/maven/plugins/maven-metadata.xml
Downloading: https://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadata.xml
Downloading: https://repository.apache.org/content/repositories/snapshots/org/codehaus/mojo/maven-metadata.xml
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-metadata.xml (13 KB at 36.9 KB/sec)
Downloaded: https://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadata.xml (20 KB at 57.4 KB/sec)
Downloaded: https://repository.apache.org/content/repositories/snapshots/org/apache/maven/plugins/maven-metadata.xml (9 KB at 9.7 KB/sec)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.140 s
[INFO] Finished at: 2016-03-18T15:28:29-04:00
[INFO] Final Memory: 27M/327M
[INFO] ------------------------------------------------------------------------
[ERROR] No plugin found for prefix 'camel' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] availabl e from the repositories [local (C:\Users\myNameHere\.m2\repository), apache.snapshots (https://repository.apache.org/content/repositories/snapshots/), central (https://repo.maven.apache.org/maven2)] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoPluginFoundForPrefixException
It looks like this is more of a Maven issue than it is a Camel issue. I put in the default .m2/settings.xml file (before I had a mirror configured for my companies Nexus repository. I thought that might be messing things up so I took it all out). Out of desperation I even tried adding in the plugin repository from here http://camel.apache.org/maven-2-snapshot-repository-in-pom.html but that did not work.
Read the readme file how to run the examples.
Some examples run using mvn camel:run and others using mvn exec:java and what else.
And you run from the master branch in the source code. Instead you should download a version of Camel such as the latest 2.16.2 and use that. It ships the examples in the examples directory: http://camel.apache.org/download
If you run from master branch in the source code. You need to rebuild Camel first, see building: http://camel.apache.org/building.html
I've tested myself, and putting the plugin 2.16 don't solve it neither.
But in readme, I found this :
We have described this in more details at the Camel twitter documentation:
http://camel.apache.org/twitter
You will need to compile this example first:
mvn compile
To run the example type
mvn exec:java
Then open a browser to see live twitter updates in the web page
http://localhost:9090
Worked for me, I hope it will work for you too. I'll investigate the problem with the plugin that doesn't seems to export the prefix latter.

org.codehaus.mojo:properties-maven-plugin:1.0-alpha-2 error

I have the following Maven project structure:
xyz
|
-props
| |
| - root.properties
|
-module_a
| |
| -pom.xml
|
-pom.xml
My root artifact defines a child module (module_a) and this is referencing the parent artifact.
In the root pom.xml I am reading a property file from the common props folder using the
org.codehaus.mojo:properties-maven-plugin:1.0-alpha-2 plugin.
When I issue the
mvn clean package
command I get the following putput:
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] my_artifact
[INFO] module_a
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building my_artifact 1.0.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) # my_artifact ---
[INFO]
[INFO] --- properties-maven-plugin:1.0-alpha-2:read-project-properties (default) # my_artifact ---
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building module_a 1.0.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) # module_a ---
[INFO]
[INFO] --- properties-maven-plugin:1.0-alpha-2:read-project-properties (default) # module_a ---
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] my_artifact ....................................... SUCCESS [0.234s]
[INFO] module_a .......................................... FAILURE [0.000s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.344s
[INFO] Finished at: Thu Aug 09 15:37:46 CEST 2012
[INFO] Final Memory: 2M/5M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:properties-maven-plugin:1.0-alpha-2:read-project-properties (default) on project module_a: Properties file not found: G:\java\xyz\module_a\props\root.properties -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :module_a
In the child module Maven tries to read the property file from an inexistetnt subfolder. Can anybody help me solve this?
Thank you
When maven evaluates the pom files and creates the effective poms ( aggregated with inheritance) some properties are excluded from being inherited. These are the ones starting with project.* and therefore also the project.basedir. Thats why you cannot define the property from where the property file is being loaded in the parent.
The reason for this behaviour is isolation. Every module should be isolated from everything but the maven repository. Even using the settings.xml profiles violates this invariant and you loose the portability of builds.
This invariant is not necessary in many cases so if you have many modules and you want to use one property file, what you can do is:
define a property e.g. "filters.dir" in your root pom to ${project.basedir}/src/main/filters
configure the plugin to load a property file from ${filters.dir}/my.properties
in any submodule you can now override filters.dir to ../src/main/filters
if you have many submodules you can define a wrong path "../src/main/filters" for filters.dir in the root and then you don't need to define the property in any submodule. To prevent the build from failing you need to set the plugin to ignore failures.
An alternative would be to write a maven extension by extending AbstractMavenLifecycleParticipant and load the property file there using the maven api to determine the root directory of your project.
I have face a similar issue.
I have a parent project pom.xml which has a build.properties file
the parent project has several modules.
When I created a new module, and wanted to build the whole parent project, I got:
[ERROR] Failed to execute goal org.codehaus.mojo:properties-maven-plugin:1.0-alpha-2:read-project-properties (default) on project attachment-services: Properties file not found: /home/raz/git/parent/attachment-services/build.properties -> [Help 1]
To fix this, I have added in the new module's pom.xml the following
<properties>
<build.properties.location>..</build.properties.location>
</properties>
and of course, this build.properties.location was already defined in the parent pom, like:
<properties>
<build.properties.location>${project.basedir</build.properties.location
</properties>

Maven dependency resolution and scope overriding

Disclaimer
(I originally asked the question in a very detailed manner over here. I've excerpted it here as the maven-users mailing list has gone quiet on this question.) (not just another newbie question)
Reference
My reference material is
http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Management; please let me know in this discussion if this is outdated or wrong.
Question
There is a section in that document that begins with "A second, and very important...". In what follows I'll refer to that section's projects A and B, and will excerpt from them.
In that section, you will see that project A has a <dependencyManagement> section that--among other things--defines an artifact, c, as having scope compile:
<!-- In A's pom.xml; condensed for brevity -->
<dependencyManagement>
<dependency>
<groupId>test</groupId>
<artifactId>c</artifactId>
<version>1.0</version>
<scope>compile</scope> <!-- look: compile scope -->
</dependency>
</dependencyManagement>
Then you will see a pom.xml for project B that (a) inherits from project A (thus inheriting its dependencyManagement section) and (b) establishes a dependency on artifact c, without having to specify its version. You will also notice that the dependency on artifact c overrides the scope of c to be runtime, not compile:
<!-- In B's pom.xml, whose parent is A's pom.xml (above); condensed for brevity -->
<dependencies>
<dependency>
<groupId>test</groupId>
<artifactId>c</artifactId>
<scope>runtime</scope> <!-- look: runtime scope -->
</dependency>
</dependencies>
Again, you'll note that there is no <version> element, but there is a <scope>runtime</scope> element.
My interpretation of this is that when all is said and done, B will depend on version 1.0 of artifact c in runtime scope, not compile scope.
Is that correct? My maven-ear-plugin bug rests on the fact that this is the expected behavior. It is not what happens when the maven-ear-plugin builds an .ear file.
Next, if that's correct, I would also expect that if artifact c had any transitive runtime dependencies they would be available in B's runtime classpath (as defined by the somewhat baffling table in http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope).
Is that correct?
Running mvn dependency:tree on the sample project posted in the bug link specified above,
[INFO] Building MEAR-143 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.3:tree (default-cli) # mear-143 ---
[INFO] ljnelson:mear-143:pom:1.0-SNAPSHOT
[INFO] \- junit:junit:jar:4.8.2:test
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building MEAR-143 Leaf 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.3:tree (default-cli) # mear-143-leaf ---
[INFO] ljnelson:mear-143-leaf:jar:1.0-SNAPSHOT
[INFO] \- junit:junit:jar:4.8.2:test
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building MEAR-143 Middle 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.3:tree (default-cli) # mear-143-middle ---
[INFO] ljnelson:mear-143-middle:jar:1.0-SNAPSHOT
[INFO] +- ljnelson:mear-143-leaf:jar:1.0-SNAPSHOT:runtime
[INFO] \- junit:junit:jar:4.8.2:test
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building MEAR-143 EAR 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.3:tree (default-cli) # mear-143-ear ---
[INFO] ljnelson:mear-143-ear:ear:1.0-SNAPSHOT
[INFO] +- ljnelson:mear-143-middle:jar:1.0-SNAPSHOT:runtime
[INFO] | \- ljnelson:mear-143-leaf:jar:1.0-SNAPSHOT:test (scope managed from ru
ntime)
[INFO] \- junit:junit:jar:4.8.2:test
The dependency scope of mear-143-leaf in mear-143-middle, where the dependency is explicitly defined is indeed runtime, overriding the test scope defined in the dependencyManagement section of parent pom, mear-143.
In mear-143-ear, mear-143-leaf gets included transitively. Here the test scope defined in dependencyManagement of mear-143 takes precedence over the inherited runtime scope.
This, I guess is in line with what is specified in the second bullet point in the section you have referred above. Quoting it here and highlighting in bold and italics the relevant parts:
b is defined in B's parent's dependency management section and since
dependency management takes precedence over dependency mediation for
transitive dependencies, version 1.0 will be selected should it be
referenced in a or c's pom. b will also have compile scope
The selected answer is good enough to clarify the key point that whether dependencyManagement takes precedence relies on whether the child dependency is declared explicitly or transitively.
As a plus, I just created a summary concerned with version & scope resolution to kill this problem totally:
Assuming that a dependency A is declared eight times in different ways, and each with a different version... which version will win last?
just remember the three rules in the picture:
explicit declaration > dependency-management declaration > implicit transitive declaration
1st declaration > 2nd declaration
child declaration > parent declaration
and you will figure out the priority sequence shown as red numbered list in the picture.

Resources