Gradle download sources failed - java

I'm using Gradle build tool and I can't get the source code and docs for spark-core.
I've already searched and applied:
idea {
project {
jdkName = '1.8'
languageLevel = '1.8'
}
module {
downloadJavadoc = true
downloadSources = true
}
}
But it still doesn't work for me. I suppose I'm missing something like rebuild the whole project or download just these pieces.
I applied ./gradlew cleanIdea idea as well.
When I try to click with pressed command on SparkConf.class I press Download Sources I get Sources not found for: org.apache.spark:spark-core_2.12:2.4.5
And the result from the run tab:
21:11:29: Executing task 'DownloadSources'...
:DownloadSources FAILED
BUILD FAILED
Total time: 0.124 secs
FAILURE: Build failed with an exception.
* Where:
Initialization script '/private/var/folders/06/97bzw1l51r59l65thfzs7hd80000gn/T/ijmiscinit1.gradle' line: 14
* What went wrong:
Execution failed for task ':DownloadSources'.
> Could not resolve all dependencies for configuration ':downloadSourcesFrom_MavenRepo_91653a2f-0439-4794-b77a-3812f9926728'.
> java.lang.NullPointerException (no error message)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
21:11:29: Task execution finished 'DownloadSources'.
Here is 2 pretty long task outputs:
DownloadSources --info: https://pastebin.com/D07JmGXT
DownloadSources --stacktrace: https://pastebin.com/6ceKhwrk
Idea.log https://pastebin.com/EQcDxPwb
Latest public Intellij build: 2020.1.1 installed via Toolbox
Latest MacOS: 10.15.4
Java 1.8 jdk-8u251-macosx-x64.dmg, downloaded from oracle.com
Could you please help me to realize what should I do to fix it?

The problem belongs to Scala plugin.
If you face this issue, it doesn't matter on build tool you are using Maven or Gradle probably installation of the Scala plugin solves your problem.
My Intellij report: https://intellij-support.jetbrains.com/hc/en-us/requests/2686145
Well-known bug: https://youtrack.jetbrains.com/issue/IDEA-127193

Related

getting this error with running ./gradlew genSources command

I'm trying to execute the gradlew genSources command here, but it says I'm using an outdated version of java, and that I at least must have Java version 17.
PS D:\Coding Stuff\Java Projekte\Minecraft Mods\fabric-example-mod-1.19> ./gradlew genSources
FAILURE: Build failed with an exception.
* Where:
Build file 'D:\Coding Stuff\Java Projekte\Minecraft Mods\fabric-example-mod-1.19\build.gradle' line: 2
* What went wrong:
An exception occurred applying plugin request [id: 'fabric-loom', version: '1.0-SNAPSHOT']
> Failed to apply plugin 'fabric-loom'.
> You are using an outdated version of Java (8). Java 17 or higher is required.
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 621ms
I went to File > Project Structure > Project and the SDK property is clearly set to openjdk-19, the language level property is set to SDK default(19). I went to Settings > Build, Execution, Deployment > Build Tools > Gradle, which tells me that the Gradle JVM property is set to Project SDK openjdk-19.
using a Windows 10 machine
Well, you must use Java 17, because Minecraft 1.19 uses this Java version :)
Since minecraft 1.19 was architectured around jdk-17, some methods end up breaking when running it on jdk-19, meaning the game won't even start.
if you set it to run with jdk-17, it should work fine

how do i solve my unique java error: invalid source release: 1.- [duplicate]

This question already has answers here:
Error:java: invalid source release: 8 in Intellij. What does it mean?
(18 answers)
Closed 2 years ago.
I know there are lots of similar questions to this one, but they don't cover my situation: "1.-", where the - isn't a placeholder or a negative number but is exactly what the error log states.
10:01:41: Executing task 'build'...
Starting Gradle Daemon...
Gradle Daemon started in 4 s 748 ms
> Configure project :
Java: 14.0.1 JVM: 14.0.1+7(Oracle Corporation) Arch: amd64
New Dep: net.minecraftforge:forge:1.16.4-35.1.37_mapped_snapshot_20201028-1.16.3
> Task :compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> error: invalid source release: 1.-
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/4.10.3/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 33s
1 actionable task: 1 executed
10:02:18: Task execution finished 'build'.
I tried several solutions to questions containing exact numbers describing what source release is invalid, but none of them worked. It also worked fine yesterday and stopped working after I restarted IntelliJ.
It turned out that while closing intellij intellij rewrote sowmething in my build.gradle:
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' + '' // Need this here so eclipse task generates correctly.
should be it
but it was :
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.-' +
'' // Need this here so eclipse task generates correctly.

Cannot build gradle project: invalid type code: B3 using Java 11

I'm using Java 11 for the project. Gradle version is 5.5. IntelijIDEA 2019.1.3
So, when I'm building the project, I get the error:
Cause: invalid type code: B3
Stacktrace shows me:
org.gradle.internal.exceptions.LocationAwareException: Build file 'D:\project\scripts\build.gradle' line: 21
A problem occurred evaluating project ':scripts'.
at org.gradle.initialization.exception.DefaultExceptionAnalyser.transform(DefaultExceptionAnalyser.java:99)
at org.gradle.initialization.exception.DefaultExceptionAnalyser.collectFailures(DefaultExceptionAnalyser.java:55)
at org.gradle.initialization.exception.MultipleBuildFailuresExceptionAnalyser.transform(MultipleBuildFailuresExceptionAnalyser.java:47)
at org.gradle.initialization.exception.StackTraceSanitizingExceptionAnalyser.transform(StackTraceSanitizingExceptionAnalyser.java:29)
And the command gradle task dev update tells me:
* What went wrong:
A problem occurred evaluating project ':scripts'.
> Could not find method leftShift() for arguments [build_44ncodnspa3jbc57fnmmpuh13$_run_closure1#4c5511e6] on task ':scripts:dev' of type org.gradle.api.DefaultTask.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED
In build.gradle file code that gives me the error is:
task("dev") << {
println "executing dev"
liquibase {
activities {
main {
changeLogFile changeLog
classpath "$projectDir/src/main/resources/"
url 'jdbc:postgresql://localhost:5432/project'
username 'testName'
password 'testPassword'
liquibaseSchemaName 'liquibase'
}
}
}
}
I used solution with unticking the flag Settings -> Experimental -> Only sync the active variant.
But can I solve the issue via code and without changing IntelijIDEA settings?
Because syncing the project is important thing as process of optimization. Especially, if it's large project.
After analyzing and finding updated syntax, I changed a bit to:
task("dev") {
doLast {
println "executing dev"
liquibase {
activities {
main {
changeLogFile changeLog
classpath "$projectDir/src/main/resources/"
url 'jdbc:postgresql://localhost:5432/project'
username 'testName'
password 'testPassword'
liquibaseSchemaName 'liquibase'
}
}
}
}
}
Eventually, updated code helped me to solve the issue without using settings of IntelijIDEA.
And gradle task dev update works successfully.

Make "gradle javadoc" task work with Java 9

I have a multi-module Gradle Java project using source/target = 1.9/1.9. There are two modules, my.base and my.dependsOnBase. The my.base module has no other dependencies:
module my.base {
exports my.base.foo;
exports my.base.bar;
}
The my.dependsOnBase module has only a single dependency, which is my.base:
module my.dependsOnBase {
requires my.base;
exports my.dependsOnBase.baz;
}
When I run $ gradle javadoc it works fine on my.base. But when it gets to my.dependsOnBase I get the following error output:
/path/to/my $ gradle javadoc
> Task :dependsOnBase:javadoc FAILED
/path/to/my/dependsOnBase/src/main/java/module-info.java:26: error: module not found: my.base
requires my.base;
^
1 error
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':dependsOnBase:javadoc'.
> Javadoc generation failed. Generated Javadoc options file (useful for troubleshooting): '/path/to/my/dependsOnBase/build/tmp/javadoc/javadoc.options'
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 2s
7 actionable tasks: 3 executed, 4 up-to-date
Earlier in the project I was able to get Java compilation, which suffered a similar problem, working using:
compileJava {
inputs.property("moduleName", moduleName)
doFirst {
options.compilerArgs = [
'--module-path', classpath.asPath,
]
classpath = files()
}
}
But those properties aren't directly applicable to the Gradle javadoc task.
How can I get my Javadoc working?
This worked for me
javadoc {
inputs.property("moduleName", moduleName)
doFirst {
options.addStringOption('-module-path', classpath.asPath)
}
}
I tried this on Gradle 7.1 and couldn't get it working, but after a little tinkering found adding this snippet made things work:
tasks.withType(Javadoc) {
doFirst {
options.modulePath = [] + classpath.files
options.classpath = []
}
}
The [] + ... seems to be a necessary workaround to make a list from the org.gradle.api.internal.file.UnionFileCollection returned by Gradle. Alternatively you could use new ArrayList(classpath.files) to achieve the same.

Gradle build with Ajc fails due to Temporary file creation

My project has an interesting issue with Gradle. When running "gradle build" from inside Intellij 13 (windows or linux), I get the following error message:
10:05:48 PM: Executing external task 'build'...
:processResources UP-TO-DATE
:compileAspect FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileAspect'.
> Error creating temporary file
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 7.434 secs
Access is denied
10:05:56 PM: External task execution finished 'build'.
From here, I ran a full debug located here: Pastebin
Which shows it failing in the AjcTask.java file at the below line:
1993 tmpFile = File.createTempFile("argfile", "", userDir);
Might be related to GRADLE-1400 which is for and older version but unresolved. On linux, if I cd to the project directory, I can run "gradle build" without trouble after that first time, then I can run it from Intellij as well without an issue.
Maybe the environment vars getting nuke somehow?
It looks like GRADLE-2532.
user.dir property defaults to C:\Program Files (x86)\JetBrains\IntelliJ IDEA 13.1.1\jre\jre\bin in your case which causes Access Denied error.
In IDEA 13.1.2 and previous versions enabling Use customizable gradle wrapper option should help. This will set user.dir to the project root directory.
In IDEA 13.1.3 and later versions there are different workarounds available, check this comment.

Categories

Resources