2

这个hello world 项目运行良好,但hello_api-latest.jar文件在哪里?(尽管客户端实际上并不“需要” JAR,它仍然应该下载。)

JAR 在类路径中:

thufir@mordor:~/NetBeansProjects/hello_client$ 
thufir@mordor:~/NetBeansProjects/hello_client$ gradle clean build;java -jar build/libs/hello_client.jar
:clean
:compileJava
:processResources UP-TO-DATE
:classes
:jar
:startScripts
:distTar
:distZip
:assemble
:compileTestJava UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:test UP-TO-DATE
:check UP-TO-DATE
:build

BUILD SUCCESSFUL

Total time: 1.229 secs

hello world

thufir@mordor:~/NetBeansProjects/hello_client$ 
thufir@mordor:~/NetBeansProjects/hello_client$ jar -xf build/libs/hello_client.jar 
thufir@mordor:~/NetBeansProjects/hello_client$ 
thufir@mordor:~/NetBeansProjects/hello_client$ cat META-INF/MANIFEST.MF 
Manifest-Version: 1.0
Main-Class: net.bounceme.mordor.Main
Class-Path: hello_api-latest.jar

thufir@mordor:~/NetBeansProjects/hello_client$ 
thufir@mordor:~/NetBeansProjects/hello_client$ tree build
build
├── classes
│   └── main
│       └── net
│           └── bounceme
│               └── mordor
│                   └── Main.class
├── dependency-cache
├── distributions
│   ├── hello_client.tar
│   └── hello_client.zip
├── libs
│   └── hello_client.jar
├── scripts
│   ├── hello_client
│   └── hello_client.bat
└── tmp
    ├── compileJava
    │   └── emptySourcePathRef
    └── jar
        └── MANIFEST.MF

13 directories, 7 files
thufir@mordor:~/NetBeansProjects/hello_client$ 

构建文件:

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

sourceCompatibility = '1.8'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
if (!hasProperty('mainClass')) {
    ext.mainClass = 'Main'
}

mainClassName = 'net.bounceme.mordor.Main'

repositories {
    mavenCentral()
    maven { url "https://jitpack.io" }

}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.10'
    compile 'com.github.THUFIR:hello_api:latest'

}



jar {
    manifest {
        attributes ('Main-Class': 'net.bounceme.mordor.Main',
            "Class-Path": configurations.compile.collect { it.getName() }.join(' '))
    }
}

值得注意的是,jitpack 依赖项没有显示在 Netbeans 中:

在此处输入图像描述

日志末尾的构建工件似乎表明hello_api-latest.jar找到了 JAR :

latest
commit 244c611ae48dc95daee544fbfb5767ae1f961e10
Author: thufir 
Date:   Fri Feb 5 05:39:47 2016 -0800

    increment

submodule status:
Run gradle build
Gradle build script
WARNING: Gradle wrapper not found. Please add. Using default gradle to build.
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8

------------------------------------------------------------
Gradle 2.7
------------------------------------------------------------

Build time:   2015-09-14 07:26:16 UTC
Build number: none
Revision:     c41505168da69fb0650f4e31c9e01b50ffc97893

Groovy:       2.3.10
Ant:          Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM:          1.8.0_60 (Oracle Corporation 25.60-b23)
OS:           Linux 3.14.32-xxxx-grs-ipv6-64 amd64

0m0.684s
Getting a list of gradle tasks
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
Found javadoc task

WARNING:
Gradle 'install' task not found. Please add the 'maven' or 'android-maven' plugin.
See the documentation and examples: https://jitpack.io/docs/

Looking for android-library
Looking for com.android.application
Adding maven plugin
Running: gradle clean -Pgroup=com.github.THUFIR -Pversion=latest -xtest install
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
:clean UP-TO-DATE
:compileJava
Download https://repo1.maven.org/maven2/org/codehaus/groovy/groovy-all/2.4.1/groovy-all-2.4.1.pom
Download https://repo1.maven.org/maven2/org/codehaus/groovy/groovy-all/2.4.1/groovy-all-2.4.1.jar
:processResources UP-TO-DATE
:classes
:jar
:install

BUILD SUCCESSFUL

Total time: 1.883 secs
Gradle exit code 0
Looking for artifacts...
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
Found artifact: com.github.THUFIR:hello_api:latest
EXIT_CODE=0
2016-03-10T09:47:34.133966887Z
Exit code: 0

Build artifacts:
com.github.THUFIR:hello_api:latest

Files: 
com/github/THUFIR/hello_api/latest
com/github/THUFIR/hello_api/latest/build.log
com/github/THUFIR/hello_api/latest/hello_api-latest.jar
com/github/THUFIR/hello_api/latest/hello_api-latest.pom
com/github/THUFIR/hello_api/latest/hello_api-latest.pom.md5
com/github/THUFIR/hello_api/latest/hello_api-latest.pom.sha1

但它下载哪里?

也可以看看:

https://stackoverflow.com/a/22724504/262852

https://stackoverflow.com/a/30094915/262852

https://stackoverflow.com/a/34329145/262852

更新

这里是:

thufir@mordor:~$ 
thufir@mordor:~$ tree .gradle/ | grep latest
│       │   │       └── latest
│       │   │           │   └── hello_api-latest.pom
│       │   │               └── hello_api-latest.jar
│       │   │   │       └── latest
│       │   │   │       └── latest
thufir@mordor:~$ 
4

1 回答 1

1

与任何外部依赖项一样,它被下载到 gradle 缓存中。默认位置是~/.gradle

于 2016-03-10T12:00:40.797 回答