Ant and Gradle compiling difference


(bruceli97) #1
try{
            SAXBuilder builder = new SAXBuilder("org.ccil.cowan.tagsoup.Parser");
            InputStream inputStream = new StringInputStream(badEntry);
            Document doc = builder.build(inputStream);
            Element feed = doc.getRootElement();
            for(Element entry: getNamedElements(feed, "entry")){
                for(Element categoryElement: getNamedElements(entry, "category")){
                    Attribute term = categoryElement.getAttribute("term");
                    if(term != null){
                        Category category = new Category(null, term.getValue());
                        categoryList.add(category);
                    }
                }
            }
        } catch(JDOMException e){
            throw new DefaultShawRuntimeException(e);
        }

There is no compiling problem when I use ant. However, when I use gradle to compile, I got below error message. Anybody got idea for that?

ProcessCommand.java:85: unreported exception java.io.IOException; must be caught or declared to be thrown

Document doc = builder.build(inputStream);

^ Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 1 error

FAILURE: Build failed with an exception.


(bruceli97) #2

BTW, I use old tech: JDOM for history reason.


(carl.quinn) #3

The latest version 1.1.2 of JDOM’s SAXBuilder.build has an IOException in its signature

public Document build(java.io.InputStream in) throws JDOMException, java.io.IOException

Maybe your Ant build was getting an older version of the library?


(bruceli97) #4

could be. I will check again. Anyway, thanks.