Import SWT as a Gradle dependency

2019-06-05 08:01发布

问题:

I am looking at how to import the SWT UI library into my Java project. I found the pom file for SWT on maven at: https://repo1.maven.org/maven2/org/eclipse/swt/3.3.0-v3346/swt-3.3.0-v3346.pom

From the file I added the following line to my build.gradle file

compile "org.eclipse:swt:3.3.0"

however when I added it to my build.gradle I received the following error:

Project 'L-CAD Main' is missing required library: '/home/ashley/unresolved dependency - org.eclipse swt 3.3.0'

If I understand this right this means it can't find the dependency, so I don't know what I'm doing wrong.

My IDE is Eclipse.

回答1:

You have to use the whole package name in the dependency line, including the version number.

Therefore add: compile "org.eclipse:swt:3.3.0-v3346" to the build.gradle file.