2

I'm trying to implement a synchronization with Google Calendar for a group project in Java.

In order to set up the Google Calendar API in our project, I followed Google's documentation here. Everything so far has worked apart from the the third and last task where I have to compile the sample code. When I try to run the command

gradle -q run

I get the message

Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /home/xxxx/xxxx/xxxx/OurProject/src/main/java/util/Assertion.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
100 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for 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 0s

I've never worked with either gradle (we're using Maven for our project) and have no idea on what to do to be honest. I'm running this btw:

------------------------------------------------------------
Gradle 4.5
------------------------------------------------------------

Build time:   2018-01-24 17:04:52 UTC
Revision:     77d0ec90636f43669dc794ca17ef80dd65457bec

Groovy:       2.4.12
Ant:          Apache Ant(TM) version 1.9.9 compiled on February 2 2017
JVM:          1.8.0_151 (Oracle Corporation 25.151-b12)
OS:           Linux 4.13.0-25-generic amd64

edit:

The gradle.build as provided by Google:

apply plugin: 'java'
apply plugin: 'application'

mainClassName = 'Quickstart'
sourceCompatibility = 1.8
targetCompatibility = 1.8
version = '1.0'

repositories {
    mavenCentral()
}

dependencies {
    compile 'com.google.api-client:google-api-client:1.23.0'
    compile 'com.google.oauth-client:google-oauth-client-jetty:1.23.0'
    compile 'com.google.apis:google-api-services-calendar:v3-rev287-1.23.0'


}

edit2: Here's a sample for one of the 100 errors:

error: cannot find symbol @Named

For this class:

import javax.enterprise.context.RequestScoped;
import java.awt.event.*;
import java.io.Serializable;
import java.awt.*;
import java.sql.Array;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.faces.view.ViewScoped;
import javax.inject.Inject;
import javax.inject.Named;
import javax.swing.*;
import javax.swing.text.html.HTML;

import java.io.Serializable;
import java.util.Map;


@Named
@RequestScoped
public class ModulBean extends AbstractBean implements Serializable {

    //variables

    public Modul getModul() {
        return modul;
    }

    @Inject
    public ModulBean(Session theSession, ModulDAO modulDao, UserDAO userDAO) {
        super(theSession);
        this.modulDao = modulDao;
        this.userDAO = userDAO;
    }

    @PostConstruct
    public void init() {
        modul = new Modul();
        allModuls = modulDao.getAllModuls();
        allUsers = userDAO.getAllUsers();
    }

    public List<Modul> getAllModuls() {
        return allModuls;
    }

    public void deleteLV(final Modul theModul) {
        System.out.println("gelöscht" + theModul);
        modulDao.remove(theModul);
        init();
    }

    public void editLV(final Modul theModul) {

    }

    public void createLV() {
        //creates an LV
        }
    }

}
Readler
  • 149
  • 1
  • 10
  • 1
    Show your gradle.build – tomrlh Jan 31 '18 at 12:28
  • 1
    But the error is not with Gradle, it gives you an error at compilation time, so it's in your code. Try to solve this warning about [unsafe operations] (https://stackoverflow.com/questions/197986/what-causes-javac-to-issue-the-uses-unchecked-or-unsafe-operations-warning). – tomrlh Jan 31 '18 at 12:36
  • I've added it to the op. – Readler Jan 31 '18 at 12:36
  • Gradle gave me the files where the errors appeared and all of them are the same: the files either don't exist (which they do, but apparently Gradle can't find them) or the symbols cannot be found (although they do compile in IntelliJ and can be built in Maven). – Readler Jan 31 '18 at 12:45
  • 1
    This is the complete error log? – tomrlh Jan 31 '18 at 12:46
  • More or less, yes. The complete one includes all 100 instances where the symbol couldn't be found, the file couldn't be found and so forth. – Readler Jan 31 '18 at 13:27

1 Answers1

1

You can get a more detailed errorlog with it.

tasks.withType(JavaCompile) {
    options.compilerArgs << '-Xlint:unchecked'
    options.deprecation = true
}

And add these lines to your Gradle dependencies:

compile group: 'javax.faces', name: 'javax.faces-api', version: '2.1'
compile group: 'javax.inject', name: 'javax.inject', version: '1'
compile group: 'javax.persistence', name: 'persistence-api', version: '1.0.2'
compile group: 'javax.ejb', name: 'ejb-api', version: '3.0'
compile group: 'javax.enterprise', name: 'cdi-api', version: '2.0'
compile group: 'org.primefaces', name: 'primefaces', version: '6.1'
compile group: 'javax.servlet', name: 'javax.servlet-api', version: '4.0.0'
compile group: 'org.apache.commons', name: 'commons-io', version: '1.3.2'
compile group: 'javax.mail', name: 'javax.mail-api', version: '1.6.0'
compile group: 'javax.faces', name: 'jsf-api', version: '2.1'
tomrlh
  • 1,006
  • 1
  • 18
  • 39
  • 1
    That's the log I got with your snipped added to it plus a sample error: `/sampleBean.java:76: error: cannot find symbol @Named 100 errors 15 warnings FAILURE: Build failed with an exception. * What went wrong: Execution failed for 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 0s` – Readler Jan 31 '18 at 13:25
  • 1
    sampleBean.java is a class of your domain? if yes, edit your question adding the whole class to it. – tomrlh Jan 31 '18 at 13:28
  • 1
    Add the import list too :) – tomrlh Jan 31 '18 at 13:47
  • Sorry! It should be there now! :) Thank you for your patience btw! – Readler Jan 31 '18 at 13:52
  • 1
    Add a name to @Named (`@Named("modulBean")` and check if it gives a different error. Your'e using Spring, right? – tomrlh Jan 31 '18 at 14:01
  • 1
    Nope, I'm getting the same error. I've never heard of Spring, so I doubt that I'm using it. – Readler Jan 31 '18 at 14:10
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/164273/discussion-between-thiago-medeiros-and-readler). – tomrlh Jan 31 '18 at 14:14