Gradle Review (2) Add dependent jar package in-eclipse

Source: Internet
Author: User
Tags testng

What I call dependency means that when you write code, you can't find a package, or you don't import it into the project's library. For example, the following conditions:



When I was doing testng study, I used the testng jar package, and the script in Build is as follows:


Apply plugin: ' java '
apply plugin: ' eclipse '

sourcecompatibility = 1.7
Version = ' 1.0 '
jar {
    manifest {
        attributes ' implementation-title ': ' Gradle Quickstart ', ' implementation-version ': Version
    }
}

repositories {
    mavencentral ()
}

dependencies {
    compile group: ' Commons-collections ', name: ' Commons-collections ', Version: ' 3.2 '
    compile ' org.testng:testng:6.8.17 '
    testcompile group: ' JUnit ', name: ' JUnit ', version: ' 4.+ '
}

Test {
    systemproperties ' property ': ' Value '
}

uploadarchives {
    Repositories {
       Flatdir {
           dirs ' repos '}}
}

How do you put the jar package in a reference library similar to the following? This allows the jar package to be imported.




Solution 1


Some people say that you can use the following Script task:


Task Copyjars (type:copy) {from
	configurations.runtime to
	' Libs '
}

After performing this task, a Libs directory is added and our jar packages are placed in this directory:



But that's not going to solve the problem.


2.gradle Eclipse Command


In fact, the above directly knocked Gradle eclipse can be solved


D:\eclipse\workspare\testng_gradl>gradle Eclipse
: Eclipseclasspath
: Eclipsejdt
: Eclipseproject
: Eclipse

BUILD successful total

time:4.103 secs

Back to eclipse, you can see that the following changes have occurred



One more referenced Libraries, and then the mistake was gone. It is my small white, alas, ashamed AH



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.