Grade Build Task Failed

I am current working on a project from hyperskill.org using IntelliJ IDEA, this project uses jcommander -1.78 for parsing command-line arguments. When i use the command “gradle build” it outputs a bunch of error based on the jcommander-1.78

Output:

11:09:36 AM: Executing task ‘build’…

Task :wrapper

BUILD SUCCESSFUL in 1m 17s
1 actionable task: 1 executed

Task :Encryption-Decryption-task:compileKotlin

Task :Encryption-Decryption-task:compileJava
C:\Users\ADMIN\IdeaProjects\Encryption-Decryption\Encryption-Decryption\task\src\argparsepack\AlgorithmValidate.java:2: error: package com.beust.jcommander does not exist
import com.beust.jcommander.IParameterValidator;
^
C:\Users\ADMIN\IdeaProjects\Encryption-Decryption\Encryption-Decryption\task\src\argparsepack\AlgorithmValidate.java:3: error: package com.beust.jcommander does not exist
import com.beust.jcommander.ParameterException;
^
C:\Users\ADMIN\IdeaProjects\Encryption-Decryption\Encryption-Decryption\task\src\argparsepack\AlgorithmValidate.java:7: error: cannot find symbol
public class AlgorithmValidate implements IParameterValidator{
^
symbol: class IParameterValidator
C:\Users\ADMIN\IdeaProjects\Encryption-Decryption\Encryption-Decryption\task\src\argparsepack\AlgorithmValidate.java:9: error: cannot find symbol
public void validate(String s, String s1) throws ParameterException {
^
symbol: class ParameterException
location: class AlgorithmValidate
C:\Users\ADMIN\IdeaProjects\Encryption-Decryption\Encryption-Decryption\task\src\argparsepack\FileConverter.java:3: error: package com.beust.jcommander does not exist
import com.beust.jcommander.IStringConverter;
^
C:\Users\ADMIN\IdeaProjects\Encryption-Decryption\Encryption-Decryption\task\src\argparsepack\FileConverter.java:7: error: cannot find symbol
public class FileConverter implements IStringConverter {
^
symbol: class IStringConverter
C:\Users\ADMIN\IdeaProjects\Encryption-Decryption\Encryption-Decryption\task\src\argparsepack\FileValidation.java:3: error: package com.beust.jcommander does not exist
import com.beust.jcommander.IParameterValidator;
^
C:\Users\ADMIN\IdeaProjects\Encryption-Decryption\Encryption-Decryption\task\src\argparsepack\FileValidation.java:4: error: package com.beust.jcommander does not exist
import com.beust.jcommander.ParameterException;
^
C:\Users\ADMIN\IdeaProjects\Encryption-Decryption\Encryption-Decryption\task\src\argparsepack\FileValidation.java:7: error: cannot find symbol
public class FileValidation implements IParameterValidator {
^
symbol: class IParameterValidator
C:\Users\ADMIN\IdeaProjects\Encryption-Decryption\Encryption-Decryption\task\src\argparsepack\FileValidation.java:10: error: cannot find symbol
public void validate(String s, String s1) throws ParameterException {
^
symbol: class ParameterException
location: class FileValidation
C:\Users\ADMIN\IdeaProjects\Encryption-Decryption\Encryption-Decryption\task\src\argparsepack\MainArgs.java:3: error: package com.beust.jcommander does not exist
import com.beust.jcommander.Parameter;
^
C:\Users\ADMIN\IdeaProjects\Encryption-Decryption\Encryption-Decryption\task\src\argparsepack\PositiveInt.java:2: error: package com.beust.jcommander does not exist
import com.beust.jcommander.IParameterValidator;
^
C:\Users\ADMIN\IdeaProjects\Encryption-Decryption\Encryption-Decryption\task\src\argparsepack\PositiveInt.java:3: error: package com.beust.jcommander does not exist
import com.beust.jcommander.ParameterException;
^
C:\Users\ADMIN\IdeaProjects\Encryption-Decryption\Encryption-Decryption\task\src\argparsepack\PositiveInt.java:5: error: cannot find symbol
public class PositiveInt implements IParameterValidator{
^
symbol: class IParameterValidator
C:\Users\ADMIN\IdeaProjects\Encryption-Decryption\Encryption-Decryption\task\src\argparsepack\PositiveInt.java:7: error: cannot find symbol
public void validate(String name, String value) throws ParameterException {
^
symbol: class ParameterException
location: class PositiveInt
C:\Users\ADMIN\IdeaProjects\Encryption-Decryption\Encryption-Decryption\task\src\encryptdecrypt\Main.java:4: error: package com.beust.jcommander does not exist
import com.beust.jcommander.JCommander;
^
C:\Users\ADMIN\IdeaProjects\Encryption-Decryption\Encryption-Decryption\task\src\argparsepack\MainArgs.java:33: error: cannot find symbol
@Parameter(names = {"-mode"}, description = “encryption or decryption”)
^
symbol: class Parameter
location: class MainArgs
C:\Users\ADMIN\IdeaProjects\Encryption-Decryption\Encryption-Decryption\task\src\argparsepack\MainArgs.java:36: error: cannot find symbol
@Parameter(names = {"-key"}, description = “key”, validateWith = PositiveInt.class)
^
symbol: class Parameter
location: class MainArgs
C:\Users\ADMIN\IdeaProjects\Encryption-Decryption\Encryption-Decryption\task\src\argparsepack\MainArgs.java:39: error: cannot find symbol
@Parameter(names = {"-alg"}, description = “algorithm”, validateWith = AlgorithmValidate.class)
^
symbol: class Parameter
location: class MainArgs
C:\Users\ADMIN\IdeaProjects\Encryption-Decryption\Encryption-Decryption\task\src\argparsepack\MainArgs.java:42: error: cannot find symbol
@Parameter(names = {"-data"}, description = “data to encrypt or decrypt”)
^
symbol: class Parameter
location: class MainArgs
C:\Users\ADMIN\IdeaProjects\Encryption-Decryption\Encryption-Decryption\task\src\argparsepack\MainArgs.java:45: error: cannot find symbol
@Parameter(names = {"-in"}, converter = FileConverter.class, description = “data file”, validateWith = FileValidation.class)
^
symbol: class Parameter
location: class MainArgs
C:\Users\ADMIN\IdeaProjects\Encryption-Decryption\Encryption-Decryption\task\src\argparsepack\MainArgs.java:48: error: cannot find symbol
@Parameter(names = {"-out"}, description = “output file”)
^
symbol: class Parameter
location: class MainArgs
C:\Users\ADMIN\IdeaProjects\Encryption-Decryption\Encryption-Decryption\task\src\argparsepack\AlgorithmValidate.java:8: error: method does not override or implement a method from a supertype
@Override
^
C:\Users\ADMIN\IdeaProjects\Encryption-Decryption\Encryption-Decryption\task\src\argparsepack\AlgorithmValidate.java:13: error: cannot find symbol
throw new ParameterException(s1 + " invalid algorithm name");
^
symbol: class ParameterException
location: class AlgorithmValidate
C:\Users\ADMIN\IdeaProjects\Encryption-Decryption\Encryption-Decryption\task\src\argparsepack\FileConverter.java:8: error: method does not override or implement a method from a supertype
@Override
^
C:\Users\ADMIN\IdeaProjects\Encryption-Decryption\Encryption-Decryption\task\src\argparsepack\FileValidation.java:9: error: method does not override or implement a method from a supertype
@Override
^
C:\Users\ADMIN\IdeaProjects\Encryption-Decryption\Encryption-Decryption\task\src\argparsepack\FileValidation.java:12: error: cannot find symbol
throw new ParameterException(s1 + “file not found”);
^
symbol: class ParameterException
location: class FileValidation
C:\Users\ADMIN\IdeaProjects\Encryption-Decryption\Encryption-Decryption\task\src\argparsepack\PositiveInt.java:6: error: method does not override or implement a method from a supertype
@Override
^
C:\Users\ADMIN\IdeaProjects\Encryption-Decryption\Encryption-Decryption\task\src\argparsepack\PositiveInt.java:10: error: cannot find symbol
throw new ParameterException(name + " must be greater than or equal to 0");
^
symbol: class ParameterException
location: class PositiveInt
C:\Users\ADMIN\IdeaProjects\Encryption-Decryption\Encryption-Decryption\task\src\encryptdecrypt\Main.java:18: error: cannot find symbol
JCommander.newBuilder()
^
symbol: variable JCommander
location: class Main
30 errors

Task :Encryption-Decryption-task:compileJava FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:Encryption-Decryption-task:compileJava’.

Compilation failed; see the compiler error output for details.

  • 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 5s
2 actionable tasks: 2 executed
11:11:13 AM: Task execution finished ‘build’.

IntelliJ auto generated build.gradle file

buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath “org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.21”
}
}

subprojects {
apply plugin: ‘application’
apply plugin: ‘java’
apply plugin: “kotlin”
apply plugin: ‘idea’

sourceCompatibility = 11

repositories {
    mavenCentral()
    maven { url "https://jitpack.io" }
}

dependencies {
    compile files('lib/jcommander-1.78.jar')
    testCompile group: 'junit', name: 'junit', version: '4.12'
    implementation 'com.github.stefanbirkner:system-rules:1.19.0'
    compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
    testImplementation 'com.github.hyperskill:hs-test:v7.0.1'
}

sourceSets {
    main.java.srcDir 'src'
    test.java.srcDir 'test'
}

test {
    systemProperty "file.encoding", "utf-8"
    outputs.upToDateWhen { false }
    afterTest { TestDescriptor test, TestResult result ->
        if (result.resultType == TestResult.ResultType.FAILURE) {
            def message = result.exception?.message ?: "Wrong answer"
            def lines = message.readLines()
            println "#educational_plugin FAILED + " + lines[0]
            lines[1..-1].forEach { line ->
                println "#educational_plugin" + line
            }
        }
    }
}

compileJava.options.encoding = 'UTF-8'
tasks.withType(JavaCompile) {
    options.encoding = 'UTF-8'
}

}

wrapper {
gradleVersion = ‘5.3.1’
}

I added compile files(‘lib/jcommander-1.78.jar’) because the other forum said it was the solution to add the dependency to build.gradle and still outputs the same error

Adding a file dependency doesn’t make a lot of sense here as you would just have manually download the dependency and put it in that location. Rather, declare the dependency like the others and it will be resolved from the declared repositories.

compile "com.beust:jcommander:1.78"

There might be other issues, but that should at least get the proper classes on the compile classpath.

1 Like

Thanks man, it is now working, sorry for the nonsense question I just started using gradle yesterday :sweat_smile: