Gradle The string works fine in Intellij, but EXACTLY the same build script fails with 100+ errors on the command line

Starting gradle builds inside IntelliJ IDEA works fine. If, although I run it from the command line, it does not give an error for each individual src character.

"Execution failed for task": compileJava. "

I assume that he cannot find a compiler that is odd, because running javac from the same command line shows that he is alive and kicking.

This is one of those moments when I'm really at a standstill. This is mistake? Does IDEA insert something to stop you using the command line with the same build script? Of course, everything that IDEA does is anyway coming to the command line?

Any help is greatly appreciated.

EDIT:

A command line error includes hundreds of this type:

/ *** .java: 89:

closed literal character '±', '§', '~', '' ',' \ '', ^

/ *** .java: 94:

illegal launch of type for (int x = 0; x <forbidden.length; x ++) {^

/ *** .java: 94:

')' is expected for (int x = 0; x <forbidden.length; x ++) {^

Literally every line in the class file causes an error. As I said, compiling using the IDEA built-in build process is great as it uses the Jet gradle plugin. Also, on the command line, a clean gradle task also works fine.

+4
source share
2 answers

It may not be related, but I had similar problems in Intellij today, when the Gradle command line failed with many compilation failures, but Intellij did not detect any problems. This happened after a significant refactoring of the project module names. Naturally, I suppose the IDE was wrong, as this is a more complicated thing than the command line. I found in two separate instances I needed slightly different approaches!

Solution 1

The solution for me was in intellij Build → “Restructuring Project” , followed by the “Update all Gradle projects” button, which is the blue circular arrow button at the top of the Gradle tool window ( View → “Windows Tool” → Gradle )

Decision 2

In another instance, I also had to remove all intellij internal libraries first, using Ctrl-Alt-Shift-S to open the Strucutre project window. Then, under the libraries, they are all deleted. Then I followed this up with "Update All Gradle Projects" as above

I'm not quite sure what the Gradle refresh button does. In the end, both phases, due to and decision, require an additional level of complexity imposed by the IDE. Rule: always trust the command line and hit your environment when it does not make sense.

+3
source

I had this problem with subsequent

. ├── build.gradle ├── hello-world ├── plugin │  └── hello-world └── settings.gradle 3 directories, 2 files 

build.gradle

 rootProject.name = "root-hello-world" 

settings.gradle

 include ':hello-world' include ':plugin:hello-world' 

intellij confuses with some motive :plugin:hello-world with :hello-world , in my case for solving it :

  • rename hello-world module folder
  • close intellij project
  • delete project folder

     rm -r `find . -type d -name "build"` rm `find -name "*.iml"` rmdir `find . -type d -empty` rm -r .gradle/ .idea/ 
  • import project again

Not sure if something like project.name = plugin-hello-world is set in the submodule

Obs: as the gradle command line says, the assembly always works even when it fails in intellij

0
source

Source: https://habr.com/ru/post/1486120/


All Articles