简体   繁体   English

在Travis-CI上,gradlew组装失败

[英]gradlew assemble failing on Travis-CI

I'm trying to get a private build to behave on Travis-Ci Pro but it keeps complaining because ./gradlew assemble is failing. 我正试图让一个私有的版本在Travis-Ci Pro上表现,但它一直抱怨因为./gradlew assemble失败。 Here's the full log: 这是完整的日志:

Using worker: worker-linux-docker-4002cef1.prod.travis-ci.com:travis-linux-15

travis_fold:start:system_info
[0K[33;1mBuild system information[0m
Build language: java
Build group: stable
Build dist: precise
[34m[1mBuild image provisioning date and time[0m
Thu Feb  5 15:09:33 UTC 2015
[34m[1mOperating System Details[0m
Distributor ID: Ubuntu
Description:    Ubuntu 12.04.5 LTS
Release:    12.04
Codename:   precise
[34m[1mLinux Version[0m
3.13.0-29-generic
[34m[1mCookbooks Version[0m
a68419e https://github.com/travis-ci/travis-cookbooks/tree/a68419e
[34m[1mGCC version[0m
gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[34m[1mLLVM version[0m
clang version 3.4 (tags/RELEASE_34/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
[34m[1mPre-installed Ruby versions[0m
ruby-1.9.3-p551
[34m[1mPre-installed Node.js versions[0m
v0.10.36
[34m[1mPre-installed Go versions[0m
1.4.1
[34m[1mRedis version[0m
redis-server 2.8.19
[34m[1mriak version[0m
2.0.2
[34m[1mMongoDB version[0m
MongoDB 2.4.12
[34m[1mCouchDB version[0m
couchdb 1.6.1
[34m[1mNeo4j version[0m
1.9.4
[34m[1mRabbitMQ Version[0m
3.4.3
[34m[1mElasticSearch version[0m
1.4.0
[34m[1mInstalled Sphinx versions[0m
2.0.10
2.1.9
2.2.6
[34m[1mDefault Sphinx version[0m
2.2.6
[34m[1mInstalled Firefox version[0m
firefox 31.0esr
[34m[1mPhantomJS version[0m
1.9.8
[34m[1mant -version[0m
Apache Ant(TM) version 1.8.2 compiled on December 3 2011
[34m[1mmvn -version[0m
Apache Maven 3.2.5 (12a6b3acb947671f09b81f49094c53f426d8cea1; 2014-12-14T17:29:23+00:00)
Maven home: /usr/local/maven
Java version: 1.7.0_76, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-oracle/jre
Default locale: en_US, platform encoding: ANSI_X3.4-1968
OS name: "linux", version: "3.13.0-29-generic", arch: "amd64", family: "unix"
travis_fold:end:system_info
[0K

Installing an SSH key from: default repository key
Key fingerprint: 23:d9:a6:24:7b:c4:67:d8:c6:45:13:5c:0f:56:04:92

travis_fold:start:git.checkout
[0Ktravis_time:start:06c3823f
[0K$ git clone --depth=50 --branch=cli-interface git@github.com:atomicpages/java-grader.git atomicpages/java-grader
Cloning into 'atomicpages/java-grader'...
remote: Counting objects: 62, done.[K
remote: Compressing objects:   2% (1/45)   [K
remote: Compressing objects:   4% (2/45)   [K
remote: Compressing objects:   6% (3/45)   [K
remote: Compressing objects:   8% (4/45)   [K
remote: Compressing objects:  11% (5/45)   [K
remote: Compressing objects:  13% (6/45)   [K
remote: Compressing objects:  15% (7/45)   [K
remote: Compressing objects:  17% (8/45)   [K
remote: Compressing objects:  20% (9/45)   [K
remote: Compressing objects:  22% (10/45)   [K
remote: Compressing objects:  24% (11/45)   [K
remote: Compressing objects:  26% (12/45)   [K
remote: Compressing objects:  28% (13/45)   [K
remote: Compressing objects:  31% (14/45)   [K
remote: Compressing objects:  33% (15/45)   [K
remote: Compressing objects:  35% (16/45)   [K
remote: Compressing objects:  37% (17/45)   [K
remote: Compressing objects:  40% (18/45)   [K
remote: Compressing objects:  42% (19/45)   [K
remote: Compressing objects:  44% (20/45)   [K
remote: Compressing objects:  46% (21/45)   [K
remote: Compressing objects:  48% (22/45)   [K
remote: Compressing objects:  51% (23/45)   [K
remote: Compressing objects:  53% (24/45)   [K
remote: Compressing objects:  55% (25/45)   [K
remote: Compressing objects:  57% (26/45)   [K
remote: Compressing objects:  60% (27/45)   [K
remote: Compressing objects:  62% (28/45)   [K
remote: Compressing objects:  64% (29/45)   [K
remote: Compressing objects:  66% (30/45)   [K
remote: Compressing objects:  68% (31/45)   [K
remote: Compressing objects:  71% (32/45)   [K
remote: Compressing objects:  73% (33/45)   [K
remote: Compressing objects:  75% (34/45)   [K
remote: Compressing objects:  77% (35/45)   [K
remote: Compressing objects:  80% (36/45)   [K
remote: Compressing objects:  82% (37/45)   [K
remote: Compressing objects:  84% (38/45)   [K
remote: Compressing objects:  86% (39/45)   [K
remote: Compressing objects:  88% (40/45)   [K
remote: Compressing objects:  91% (41/45)   [K
remote: Compressing objects:  93% (42/45)   [K
remote: Compressing objects:  95% (43/45)   [K
remote: Compressing objects:  97% (44/45)   [K
remote: Compressing objects: 100% (45/45)   [K
remote: Compressing objects: 100% (45/45), done.[K
Receiving objects:   1% (1/62)   
Receiving objects:   3% (2/62)   
Receiving objects:   4% (3/62)   
Receiving objects:   6% (4/62)   
Receiving objects:   8% (5/62)   
Receiving objects:   9% (6/62)   
Receiving objects:  11% (7/62)   
Receiving objects:  12% (8/62)   
Receiving objects:  14% (9/62)   
Receiving objects:  16% (10/62)   
Receiving objects:  17% (11/62)   
Receiving objects:  19% (12/62)   
Receiving objects:  20% (13/62)   
Receiving objects:  22% (14/62)   
Receiving objects:  24% (15/62)   
remote: Total 62 (delta 13), reused 54 (delta 5), pack-reused 0[K
Receiving objects:  25% (16/62)   
Receiving objects:  27% (17/62)   
Receiving objects:  29% (18/62)   
Receiving objects:  30% (19/62)   
Receiving objects:  32% (20/62)   
Receiving objects:  33% (21/62)   
Receiving objects:  35% (22/62)   
Receiving objects:  37% (23/62)   
Receiving objects:  38% (24/62)   
Receiving objects:  40% (25/62)   
Receiving objects:  41% (26/62)   
Receiving objects:  43% (27/62)   
Receiving objects:  45% (28/62)   
Receiving objects:  46% (29/62)   
Receiving objects:  48% (30/62)   
Receiving objects:  50% (31/62)   
Receiving objects:  51% (32/62)   
Receiving objects:  53% (33/62)   
Receiving objects:  54% (34/62)   
Receiving objects:  56% (35/62)   
Receiving objects:  58% (36/62)   
Receiving objects:  59% (37/62)   
Receiving objects:  61% (38/62)   
Receiving objects:  62% (39/62)   
Receiving objects:  64% (40/62)   
Receiving objects:  66% (41/62)   
Receiving objects:  67% (42/62)   
Receiving objects:  69% (43/62)   
Receiving objects:  70% (44/62)   
Receiving objects:  72% (45/62)   
Receiving objects:  74% (46/62)   
Receiving objects:  75% (47/62)   
Receiving objects:  77% (48/62)   
Receiving objects:  79% (49/62)   
Receiving objects:  80% (50/62)   
Receiving objects:  82% (51/62)   
Receiving objects:  83% (52/62)   
Receiving objects:  85% (53/62)   
Receiving objects:  87% (54/62)   
Receiving objects:  88% (55/62)   
Receiving objects:  90% (56/62)   
Receiving objects:  91% (57/62)   
Receiving objects:  93% (58/62)   
Receiving objects:  95% (59/62)   
Receiving objects:  96% (60/62)   
Receiving objects:  98% (61/62)   
Receiving objects: 100% (62/62)   
Receiving objects: 100% (62/62), 13.52 KiB | 0 bytes/s, done.
Resolving deltas:   0% (0/13)   
Resolving deltas:  38% (5/13)   
Resolving deltas:  46% (6/13)   
Resolving deltas:  53% (7/13)   
Resolving deltas:  69% (9/13)   
Resolving deltas:  76% (10/13)   
Resolving deltas:  84% (11/13)   
Resolving deltas:  92% (12/13)   
Resolving deltas: 100% (13/13)   
Resolving deltas: 100% (13/13), done.
Checking connectivity... done.
travis_time:end:06c3823f:start=1450114509982135009,finish=1450114510406203180,duration=424068171
[0K$ cd atomicpages/java-grader
$ git checkout -qf d3c067dead18a524bf85efb7eb90cad63d47368c
travis_fold:end:git.checkout
[0K
[33;1mThis job is running on container-based infrastructure, which does not allow use of 'sudo', setuid and setguid executables.[0m
[33;1mIf you require sudo, add 'sudo: required' to your .travis.yml[0m
[33;1mSee http://docs.travis-ci.com/user/workers/container-based-infrastructure/ for details.[0m
$ jdk_switcher use oraclejdk8
Switching to Oracle JDK8 (java-8-oracle), JAVA_HOME will be set to /usr/lib/jvm/java-8-oracle
$ export TERM=dumb
$ java -Xmx32m -version
java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)
$ javac -J-Xmx32m -version
javac 1.8.0_31
travis_fold:start:install
[0Ktravis_time:start:16e15912
[0K$ ./gradlew assemble
Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain

[31;1mThe command "eval ./gradlew assemble" failed. Retrying, 2 of 3.[0m

Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain

[31;1mThe command "eval ./gradlew assemble" failed. Retrying, 3 of 3.[0m

Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain

[31;1mThe command "eval ./gradlew assemble" failed 3 times.[0m

travis_time:end:16e15912:start=1450114512754418536,finish=1450114515995381755,duration=3240963219
[0K
[31;1mThe command "./gradlew assemble" failed and exited with 1 during .[0m

Your build has been stopped.

I'm not really sure what to do. 我不确定该怎么做。 I followed the gradle setup for a project per the Travis documentation and it should work fine... Here's my travis config file 我按照Travis文档跟踪了项目的gradle设置,它应该可以正常工作......这是我的travis配置文件

language: java
jdk:
  - oraclejdk8
  - oraclejdk7
  - openjdk7

before_script:
- chmod a+x gradlew

sccript: ./gradlew build

If I build locally via IntelliJ IDEA or by the following: 如果我通过IntelliJ IDEA或通过以下方式在本地构建:

  • gradle build
  • chmod a+x gradlew && ./gradlew build

it works flawlessly. 它完美无瑕。 Any hints? 任何提示?

For anyone passing by my issue was in my .gitignore file. 对于任何路过我的问题的人都在我的.gitignore文件中。 I inadvertently added this entry: 我无意中添加了这个条目:

gradle/

Which was causing gradle/wrapper/gradle-wrapper.jar to not be included in my repo. 这导致gradle/wrapper/gradle-wrapper.jar不包含在我的gradle/wrapper/gradle-wrapper.jar中。 Removing this entry in the .gitignore file and committing the changes to the repo fixed the issue. 删除.gitignore文件中的此条目并将更改提交到repo修复了该问题。

In fact, not only gradle/wrapper/gradle-wrapper.jar has to be there, but also it should have -x permission. 实际上,不仅gradle/wrapper/gradle-wrapper.jar必须存在,而且它应该具有-x权限。 So if you already committed it, but it doesnot have -x , you should do the following: 因此,如果您已经提交了它,但它没有-x ,那么您应该执行以下操作:

  1. chmod +x gradle/wrapper/gradle-wrapper.jar
  2. git add -f gradle/wrapper/gradle-wrapper.jar

Reference: Could not find or load main class org.gradle.wrapper.GradleWrapperMain 参考: 无法找到或加载主类org.gradle.wrapper.GradleWrapperMain

If you don't want to add .jar file into your repository, you can install wrapper before your build is started on travi-ci: 如果您不想将.jar文件添加到存储库中,则可以在travi-ci上启动构建之前安装wrapper

install: gradle wrapper --gradle-version 4.2

language: java

jdk:
  - oraclejdk8

More about wrapper in gradle documentation and install commands in travis-ci doc . 有关gradle文档中的包装器和travis-ci doc中的安装命令的更多信息。

In my case I had the gradle-wrapper.jar in the repository, but it still gave me the: Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain 在我的情况下,我在存储库中有gradle-wrapper.jar ,但它仍然给了我: Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain

It turned out that because of the fact I enforced LF line endings in my .gitattributes the gradle-wrapper.jar file got corrupted during commit. 事实证明,由于我在.gitattributes强制执行LF行结尾,因此gradle-wrapper.jar文件在提交期间被破坏。

To fix it do the following: 要修复它,请执行以下操作:

  1. In .gitattributes add the following line *.jar binary .gitattributes添加以下行*.jar binary
  2. Remove gradle wrapper files: rm -rf gradle/ gradlew gradlew.bat 删除gradle包装器文件: rm -rf gradle/ gradlew gradlew.bat
  3. Regenrate the wrapper: gradle wrapper --gradle-version=5.1.1 --distribution-type=all 重新包装包装器: gradle wrapper --gradle-version=5.1.1 --distribution-type=all
  4. Commit and push :) 提交并推送:)

For those it didn't work by above answers, you could try 对于那些不能通过上述答案工作的人,你可以试试

jdk: openjdk8 instead of oraceljdk8 in .travis file jdk:openjdk8而不是.travis文件中的oraceljdk8

You can check the difference between oracle JDK and Open Jdk though. 您可以检查oracle JDK和Open Jdk之间的区别。 It should not matter as both are licenced one from oracle and one from open GNU PL but if you want specific difference you could visit - https://www.baeldung.com/oracle-jdk-vs-openjdk 它应该没有关系,因为它们都是来自oracle和开放GNU PL的许可,但是如果你想要特定的差异你可以访问 - https://www.baeldung.com/oracle-jdk-vs-openjdk

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM