0

I'm having an issue with setting up my build.gradle in a standalone java app - and a very similar configuration works in one of my other projects. What am I missing here? I think this has to be a simple fix, but it eludes me at the moment.

My simple build.gradle:

apply plugin: 'java'
sourceCompatibility = 1.9
targetCompatibility = 1.9
apply plugin: 'eclipse'

repositories {
    mavenCentral()
}           

dependencies {
    // https://mvnrepository.com/artifact/org.apache.poi/poi
    compile group: 'org.apache.poi', name: 'poi', version: '4.1.0'
    // https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml
    compile group: 'org.apache.poi', name: 'poi-ooxml', version: '4.1.0'
}

The error message eclipse gives me (from the gradle process) when I refresh the gradle project:

CONFIGURE SUCCESSFUL in 0s
Could not resolve: org.apache.poi:poi:4.1.0
Could not resolve: org.apache.poi:poi-ooxml:4.1.0

How can I resolve this? I've read the gradle docs, and appeared to be following the process. Gradle documentation links showing my error are appreciated as well. Thank you.

K13
  • 124
  • 9
  • Did you try the solutions here - https://stackoverflow.com/questions/5878341/cannot-import-xssf-in-apache-poi – Reaz Murshed Aug 20 '19 at 00:42
  • @ReazMurshed - No. That person is having a different issue - caused by how apache organizes their classes. He didnt realize the dependency specified didnt include all of his desired classes. I'm already specifying all of the packages needed - the problem is gradle cant find them for some reason. – K13 Aug 20 '19 at 00:47
  • I'd imagine I'm just goofing up the format/order of the repositories and/or dependencies section. – K13 Aug 20 '19 at 00:49
  • umm ... I do not think so. However, I am not sure about the reason for the failing either. – Reaz Murshed Aug 20 '19 at 00:56
  • Don't you typically need a buildscript { } block to run the gradle script? –  Aug 20 '19 at 00:59
  • @ReazMurshed - That's okay :-) . I'm 100% sure I have the imports needed for the apache poi functionality I am using. I have this working in another project. I'm trying to break it out in a separate git repo - but the build.gradle is giving me trouble. I'm NOT having a compile issue - I'm just not writing the build.gradle correctly to pull the dependencies in the first place. – K13 Aug 20 '19 at 00:59
  • @PaulPearson - Do you? I thought that was to declare dependencies for the build script itself, not the app. – K13 Aug 20 '19 at 01:01
  • 1
    @K13 Ah, yes it could be but I've used it for most projects even without it being Spring Boot. Not sure, you could also try adding in some other repo's to see if they resolve them. jcenter() or mavenLocal() –  Aug 20 '19 at 01:03
  • 1
    Your original script worked for me with IntelliJ. Try running from command line and see what happens. –  Aug 20 '19 at 01:10
  • @PaulPearson what? HA. Maybe it's something wrong with my IDE. Good idea testing it on the command line. And I can confirm - it worked from the command line on my machine too! I wish I knew why it didnt work in Eclipse - but this solves my immediate issue. If you submit an answer with your suggestion to test via command line - I will mark it as accepted so you get the credit. – K13 Aug 20 '19 at 01:15
  • Does your local setup run behind a proxy? – Lukas Körfer Aug 20 '19 at 08:13
  • @LukasKorfer - No, it doesn't. It's a relatively standard IDE setup on a personal laptop. That workspace even has multiple projects that work fine. I think the IDE just is in a bad state. I'll have to restart the OS and see if that makes a diff. – K13 Aug 20 '19 at 12:10

2 Answers2

1

To resolve the dependencies try running from the command line. From there you can work to solve the IDE issue.

0

As mentioned in the comments on the original post - @PaulPearson discovered it worked on his machine, and when I ran the gradle refresh outside of Eclipse (with gradle build via command line) it worked fine.

It must be an eclipse IDE specific issue - not an issue with the build.gradle. My acute issue is resolved. Thanks all.

K13
  • 124
  • 9