H
H
Humanothatone2019-09-02 12:24:02
Java
Humanothatone, 2019-09-02 12:24:02

What to configure in IDEA so that when changing the class name in the java file, the mainClassName in build.gradle automatically changes?

1. There is a file structure:
Boxy directory:

  • src
    • main
      • java
        code file

    build.gradle

2. Modules are imported from the build.gradle configuration file
3. There is a java code:
public class newLO {
  public static void main(String[] args){
    System.out.println("Hi!");
  }
}

4. It is necessary that when changing the class name in the java file, IDEA notices the change and suggests changing (DO refactor) the class name in the build.gradle configuration file:
apply plugin: 'java'
apply plugin: 'application'
mainClassName = "newF"

At the moment, only the filename changes, the value of mainClassName = "newF" remains the same.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ilya Serov, 2019-09-04
@JavaIlya

In theory, if you press shift + F6 and edit the class name, then everything will automatically change, but I only used maven and there seemed to be no problems.

U
useIT, 2020-07-23
@useIT

I have the same problem
and don't know how to solve it

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question