How to transfer dependencies?

I use the gradle init to build a java application.
It has a project named app

build.gradle:

dependencies {
    implementation 'org.apache.commons:commons-text'
    implementation project(':utilities')
}

Now, I want to build a new project named app2, dependencies app

dependencies {
    implementation project(':app')
}

I write a HelloWorld in app2, it can’t use the WordUtils.capitalize which is in app dependencies org.apache.commons:commons-text.

How to transfer the app dependencies to app2?

Thank you

Transfer which dependencies, where to?

Sorry, before your reply I have not finish my question.
Now it’s finish.
Hope your reply.
thx.

Simple truth is, you shouldn’t.
implementation dependencies do not leak into the class path of consumers, because then probability of up-to-dateness or cache hits is higher and compilation is faster as the compile class path is smaller.

For dependencies that are part of your API (parameter types, return types, superclasses, implemented interfaces, …) you should declare them as api dependencies instead, then they are also part of the compile class path of consumers.

But dependencies you only use in private methods, package private methods, package private classes, and so on should stay implementation dependencies and if you need it in a consumer like app2 you should also declare it there separately. This is better for reliablitly, better for performance and also clearer when someone looks at the build as the project clearly defines what it uses.

Thank you your detailed answer.
Maybe it’s some difficult to me , I use this sample to discuss maybe simple.

project app:

package demo2.app;

import demo2.list.LinkedList;

import static demo2.utilities.StringUtils.join;
import static demo2.utilities.StringUtils.split;
import static demo2.app.MessageUtils.getMessage;

import org.apache.commons.text.WordUtils;

public class App {
    public static void main(String[] args) {
        LinkedList tokens;
        tokens = split(getMessage());
        String result = join(tokens);
        System.out.println(WordUtils.capitalize(result));
    }

}

build.gradle:

plugins {
    id 'demo2.java-application-conventions'
}

dependencies {
    implementation 'org.apache.commons:commons-text'
    implementation project(':utilities')

}

application {
    // Define the main class for the application.
    mainClass = 'demo2.app.App'
}

project app2:
build.gradle:

plugins {
    id 'java'
    id 'demo2.java-library-conventions'

}

dependencies {
    api project(':app')
}

I copy the app App.java to app2.
it will show can’t find the dependencies.
How to fix it?

I know a concept: gradle not recommended Transfer dependencies.
app dependence apache lib,
if app2 want to use apache lib, it had better directly dependence apache lib rather then dependence app.
so , it should be write the app2 build.gradle

dependencies {
    api project(':app')
    implementation 'org.apache.commons:commons-text'
}

is it right?

Almost, as app2 does not use app classes in its api, it should be an implementation dependency.
But you understood correctly now regarding commons-text, yes.

thank you, I understand it.