Краткое руководство по Maven Wrapper
Maven Wrapper — отличный выбор для проектов, которым нужна определенная версия Maven (или для пользователей, которые вообще не хотят устанавливать Maven). Вместо того, чтобы устанавливать множество его версий в операционной системе, мы можем просто использовать скрипт-оболочку для конкретного проекта.
В этой быстрой статье мы покажем, как настроить Maven Wrapper для существующего проекта Maven.
2. Настройка оболочки Maven
Есть два способа настроить его в проекте, самый простой из которых — использовать соответствующий плагин для его автоматизации или применить ручную установку.
2.1. Плагин
Давайте используем этот плагин Maven Wrapper для автоматической установки в простом проекте Spring Boot.
Во-первых, нам нужно зайти в основную папку проекта и выполнить эту команду:
mvn -N wrapper:wrapper
Мы также можем указать версию Maven:
mvn -N wrapper:wrapper -Dmaven=3.5.2
Параметр -N означает -нерекурсивный, поэтому оболочка будет применяться только к основному проекту текущего каталога, а не к каким-либо подмодулям.
После выполнения цели у нас будет больше файлов и каталогов в проекте:
- mvnw : это исполняемый сценарий оболочки Unix, используемый вместо полностью установленного Maven.
- mvnw.cmd : это пакетная версия вышеуказанного скрипта.
- mvn : скрытая папка, в которой находится библиотека Java Maven Wrapper и файл ее свойств.
2.2. Руководство
При ручном подходе мы можем скопировать файлы и папки, показанные выше, из другого проекта в основную папку текущего проекта.
После этого нам нужно указать версию Maven для использования в файле свойств оболочки, расположенном в файле .mvn/wrapper/maven-wrapper.properties .
Например, в нашем файле свойств есть следующая строка:
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.2/apache-maven-3.5.2-bin.zip
Следовательно, будет загружена и использована версия 3.5.2.
3. Варианты использования
Обертка должна работать с различными операционными системами, такими как:
После этого мы можем запустить наши цели для системы Unix следующим образом:
./mvnw clean install
И следующая команда для Windows:
mvnw.cmd clean install
Если у нас нет указанного Maven в свойствах обертки, он будет скачан и установлен в папку $USER_HOME/.m2/wrapper/dists системы.
Давайте запустим наш проект Spring-Boot:
./mvnw spring-boot:run
Вывод такой же, как и для полностью установленного Maven:
Примечание: мы используем исполняемый файл mvnw вместо mvn, который теперь представляет собой программу командной строки Maven.
Теперь, когда мы знаем, что такое обертка Maven, давайте ответим на один из частых вопросов: нужно ли добавлять файлы mvnw в наши проекты?
Короткий ответ: нет. Файлы mvnw не обязательно являются частью наших проектов . Однако включение их может быть полезным. Например, это позволит любому, кто клонирует наш проект, собрать его без установки Maven.
4. Вывод
В этом руководстве мы увидели, как настроить и использовать Maven Wrapper в проекте Maven.
Как всегда, исходный код этой статьи можно найти на GitHub .
Maven Wrapper
The Maven Wrapper is an easy way to ensure a user of your Maven build has everything necessary to run your Maven build.
Why might this be necessary? Maven to date has been very stable for users, is available on most systems or is easy to procure: but with many of the recent changes in Maven it will be easier for users to have a fully encapsulated build setup provided by the project. With the Maven Wrapper, this is very easy to do and it’s a great idea and initial implementation borrowed from Gradle.
The easiest way to setup the Maven Wrapper for your project is to use the Maven Wrapper Plugin with its provided wrapper goal. To add or update all the necessary Maven Wrapper files to your project execute the following command:
mvn wrapper:wrapper
Normally you instruct users to install a specific version of Apache Maven, put it on the PATH and then run the mvn command like the following:
mvn clean install
But now, with a Maven Wrapper setup, you can instruct users to run wrapper scripts:
./mvnw clean install
mvnw.cmd clean install
A normal Maven build will be executed, with the one important change that if the user doesn’t have the necessary version of Maven specified in .mvn/wrapper/maven-wrapper.properties it will be downloaded for the user first, installed and then used.
Subsequent uses of mvnw / mvnw.cmd use the previously downloaded, specific version as needed.
Supported Systems
The wrapper should work on various operating systems including
- Linux (numerous versions, tested on Ubuntu and CentOS)
- OSX / macOS
- Windows (various newer versions)
- Solaris (10 and 11)
- BSD
A POSIX-compatible Bourne shell is required to run the wrapper script.
In terms of Apache Maven versions itself, the wrapper should work with any Maven 3.x version and it defaults to the release used when setting up the wrapper. We do NOT plan to support the deprecated, EOL’ed Maven 2.x.
The maven-wrapper.jar (to download and install target Maven version required by mvnw ) and the Maven Wrapper Plugin (to inject Wrapper into a project) use Java 7.
Verbose Mode
The wrapper supports a verbose mode in which it outputs further information. It is activated by setting the MVNW_VERBOSE environment variable to true .
By default it is off.
Usage without Binary JAR
By default, the Maven Wrapper JAR archive is added to the using project as small binary file .mvn/wrapper/maven-wrapper.jar . It is used to bootstrap the download and invocation of Maven from the wrapper shell scripts.
If your project is not allowed to contain binary files like this, you can use the source distribution of the maven wrapper which adds a file .mvn/wrapper/MavenWrapperDownloader.java file instead:
# defaults to bin mvn wrapper:wrapper -Dtype=source
You can also chose to opt out of all additional resources except the wrapper scripts:
mvn wrapper:wrapper -Dtype=script
Another type is the lite implementation of mvnw / mvnw.cmd scripts which download the maven directly via wget or curl on *nix, or PowerShell on Windows, then call the original mvn / mvn.cmd scripts of the downloaded maven distribution. This type does not use maven-wrapper.jar nor MavenWrapperDownloader.java , only the wrapper scripts are required.
mvn wrapper:wrapper -Dtype=only-script
If the JAR is not found to be available by the scripts they will attempt to download the file from the URL specified in .mvn/wrapper/maven-wrapper.properties under wrapperUrl and put it in place. The download is attempted via curl, wget and, as last resort, by compiling the .mvn/wrapper/MavenWrapperDownloader.java file and executing the resulting class.
If your Maven repository is password protected you can specify your username via the environment variable MVNW_USERNAME and the password via the environment variable MVNW_PASSWORD .
Using a Different Version of Maven
To switch the version of Maven used to build a project, you can initialize it using:
mvn wrapper:wrapper -Dmaven=3.5.4
which works for any version except snapshots. Once you have a wrapper you can change its version by setting the distributionUrl in .mvn/wrapper/maven-wrapper.properties , e.g.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip
Using Basic Authentication for Distribution Download
To download Maven from a location that requires Basic Authentication you have 2 options:
- Set the environment variables MVNW_USERNAME and MVNW_PASSWORD or
- add user and password to the distributionUrl like that: distributionUrl=https://username:password@/maven2/org/apache/maven/apache-maven/3.2.1/apache-maven-3.2.1-bin.zip
Specifying Maven Distribution Base Path
This is a feature of Maven itself and the wrapper just happens to take it into account. Simply set MAVEN_USER_HOME to the desired path and the wrapper uses it as the base of the Maven distro installation.
Using a Maven Repository Manager
When using an internal Maven repository manager, you have two options:
- Just set the correct URL to wrapper jar and Maven distro in maven-wrapper.properties in your project
- Leave the default URL in the project pointing to Maven Central and set the environment variable MVNW_REPOURL to your repo manager URL such as https://repo.example.com/central-repo-proxy .
If MVNW_REPOURL is set during the wrapper installation with the maven-wrapper-plugin, the URL is used in the maven-wrapper.properties file.
If not set, but your mirror URL in your settings.xml is configured, it will be used.
Checksum verification of downloaded binaries
To avoid supply-chain-attacks by downloading a corrupted artifact, it is possible to specify checksums for both the maven-wrapper.jar and the downloaded distribution. To apply verification, add the expected file’s SHA-256 sum in hex notation, using only small caps, to maven-wrapper.properties . The property for validating the maven-wrapper.jar file is named wrapperSha256Sum whereas the distribution file property is named distributionSha256Sum .
Internals
Maven Wrapper is composed of 3 pieces:
- maven-wrapper, providing the maven-wrapper.jar that downloads, installs and runs target Maven distribution,
- maven-wrapper-distribution, that provides mvnw / mvnw.cmd scripts distributions,
- maven-wrapper-plugin, the wrapper plugin to ease installing Wrapper into a project.
What is the purpose of mvnw and mvnw.cmd files?
When I created a Spring Boot application I could see mvnw and mvnw.cmd files in the root of the project. What is the purpose of these two files?
13k 7 7 gold badges 47 47 silver badges 76 76 bronze badges
asked Aug 2, 2016 at 14:53
shaunthomas999 shaunthomas999
5,584 2 2 gold badges 27 27 silver badges 30 30 bronze badges
6 Answers 6
These files are from Maven wrapper. It works similarly to the Gradle wrapper.
This allows you to run the Maven project without having Maven installed and present on the path. It downloads the correct Maven version if it’s not found (as far as I know by default in your user home directory).
The mvnw file is for Linux (bash) and the mvnw.cmd is for the Windows environment.
To create or update all necessary Maven Wrapper files execute the following command:
mvn -N io.takari:maven:wrapper
To use a different version of maven you can specify the version as follows:
mvn -N io.takari:maven:wrapper -Dmaven=3.3.3
Both commands require maven on PATH (add the path to maven bin to Path on System Variables) if you already have mvnw in your project you can use ./mvnw instead of mvn in the commands.
5,184 3 3 gold badges 50 50 silver badges 67 67 bronze badges
answered Aug 2, 2016 at 14:57
8,077 2 2 gold badges 31 31 silver badges 45 45 bronze badges
Thanks for the answer. Can you explain when this gets generated, like is it when you initially create a project? Will it gets updated along the line when you do changes to your pom like add remove dependencies/plugins ?
Sep 20, 2017 at 23:20
and, should you add/commit the mvnw.cmd files?
Jan 15, 2019 at 3:26
yes, of course. it allows you to quickly run your maven build without the need to extra install maven or having it on PATH.
Jan 15, 2019 at 19:04
So many thanks for the answer, it’s very helpful ¿Could you tell us something about the portability of the maven settings files when we working in that way? Saludos and thanks again.
Sep 13, 2019 at 4:49
@DanielHernández the maven wrapper uses the default settings.xml on the users system. and according to this issue there are some tricks how you could add a custom settings.xml to the repo but it seems then it ignores the user settings on system.
Sep 13, 2019 at 6:30
Command mvnw uses Maven that is by default downloaded to ~/.m2/wrapper on the first use.
URL with Maven is specified in each project at .mvn/wrapper/maven-wrapper.properties :
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip
To update or change Maven version invoke the following (remember about —non-recursive for multi-module projects):
./mvnw io.takari:maven:wrapper -Dmaven=3.3.9
or just modify .mvn/wrapper/maven-wrapper.properties manually.
To generate wrapper from scratch using Maven (you need to have it already in PATH run:
mvn io.takari:maven:wrapper -Dmaven=3.3.9
answered Dec 20, 2016 at 10:01
Michal Kordas Michal Kordas
10.5k 8 8 gold badges 58 58 silver badges 105 105 bronze badges
The Maven Wrapper is an excellent choice for projects that need a specific version of Maven (or for users that don’t want to install Maven at all). Instead of installing many versions of it in the operating system, we can just use the project-specific wrapper script.
mvnw: it’s an executable Unix shell script used in place of a fully installed Maven
mvnw.cmd: it’s for Windows environment
Use Cases
The wrapper should work with different operating systems such as:
After that, we can run our goals like this for the Unix system:
./mvnw clean install
And the following command for Batch:
./mvnw.cmd clean install
If we don’t have the specified Maven in the wrapper properties, it’ll be downloaded and installed in the folder $USER_HOME/.m2/wrapper/dists of the system.
Maven Wrapper plugin
Maven Wrapper plugin to make auto installation in a simple Spring Boot project.
First, we need to go in the main folder of the project and run this command:
mvn -N io.takari:maven:wrapper
We can also specify the version of Maven:
mvn -N io.takari:maven:wrapper -Dmaven=3.5.2
The option -N means –non-recursive so that the wrapper will only be applied to the main project of the current directory, not in any submodules.
14.2k 5 5 gold badges 40 40 silver badges 70 70 bronze badges
answered Nov 13, 2019 at 15:26
Romil Patel Romil Patel
13k 7 7 gold badges 47 47 silver badges 76 76 bronze badges
Maybe you should mention that part of the text is extracted from baeldung.com/maven-wrapper
Sep 15, 2020 at 11:20
short answer: to run Maven and Gradle in the terminal without following manual installation processes.
./gradlew clean build ./gradlew bootRun
./mvnw clean install ./mvnw spring-boot:run
«The recommended way to execute any Gradle build is with the help of the Gradle Wrapper (in short just “Wrapper”). The Wrapper is a script that invokes a declared version of Gradle, downloading it beforehand if necessary. As a result, developers can get up and running with a Gradle project quickly without having to follow manual installation processes saving your company time and money.«
Gradle would also add some specific files corresponding to the Maven files Gradlew and Gradle.bat
Вопрос №26534 от пользователя Ильнар Шафигуллин в проекте «Казино»
jitpack.io также удалось настроить. Решение было следующим:
- залить на гит каталог .mvn
- Версию jdk в pom.xml и jitpack.yml поменял на 11.
В связи с этим возник вопрос — как можно узнать актуальную версию jdk, которую поддерживает jitpack? Потому что с 12 версией на локальном ПК всё работает, а jitpack отказывался работать. Несколько тыков с релизами помогли понять что дело было в этом, но всё же)
Кстати, в игре Slot у меня был очень странный баг, не понимаю из-за чего это было. Иногда при старте игры у игрока сразу было оооочень много денег, т.е. не 100$ как указано в переменной int money, а сотни тысяч. При запуске из консоли этот баг встречался довольно часто. Решилось переводом переменной int money из локального поля метода main в static поле класса. После этого баг больше не встречался. Но так и не понял я как такой баг может появиться. Кстати, один раз на него наткнулся при запуске из IDE
А теперь Travis отвалился.. жесть
там специальный файл пишется .travis.yml и в нём указывается версия openjdk:
language: java jdk: oraclejdk11
Насчёт 12-й надо проверять, может и не поддерживается — тогда нужно написать им в support, они сделают. 11-я поддерживается точно.
Последний запушенный как раз такой. Падает по ошибке:
Где-то в другом месте ошибка..
20 часов назад Travis работал нормально с вот таким конфигом:
Ошибка сегодня утром произошла похоже когда я начал перетряхивать pom.xml. Судя по истории сборки падали сначала по ошибке:
[Help 1]
Сборку на Travice также исправил, теперь зелёная. Но лечил, на сколько я понимаю, костылями. Файл .travis.yml Сейчас такой:
Соотственно, travis почему-то не видел обёртку Maven’а, а после того как мы директивно заставили его скачать её и выполнять команды из под него, то всё стало работать. Директория .mwn на репозиторий залита, поэтому причины такого поведения Travis мне не ясны. Возможно Вам понятно что не так?
А Вы логи тревиса смотрели? Что в них? Какая ощшибка?
Вот конец Job Log последней неудачной сборки
А ниже полный лог, если вдруг выше недостаточно информации
= 3 will be closed before executing a command Environment variables to check for sanity: TZ TERM LINGUAS LC_* LANGUAGE LANG COLORTERM Environment variables to remove: RUBYOPT RUBYLIB PYTHONUSERBASE PYTHONINSPECT PYTHONPATH PYTHONHOME TMPPREFIX ZDOTDIR READNULLCMD NULLCMD FPATH PERL5DB PERL5OPT PERL5LIB PERLLIB PERLIO_DEBUG JAVA_TOOL_OPTIONS SHELLOPTS GLOBIGNORE PS4 BASH_ENV ENV TERMCAP TERMPATH TERMINFO_DIRS TERMINFO _RLD* LD_* PATH_LOCALE NLSPATH HOSTALIASES RES_OPTIONS LOCALDOMAIN CDPATH IFS Environment variables to preserve: JAVA_HOME TRAVIS CI DEBIAN_FRONTEND XAUTHORIZATION XAUTHORITY PS2 PS1 PATH LS_COLORS KRB5CCNAME HOSTNAME HOME DISPLAY COLORS Locale to use while parsing sudoers: C Directory in which to store input/output logs: /var/log/sudo-io File in which to store the input/output log: % Add an entry to the utmp/utmpx file when allocating a pty PAM service name to use PAM service name to use for login shells Create a new PAM session for the command to run in Maximum I/O log sequence number: 0 Local IP address and netmask pairs: 10.240.0.28/255.255.255.255 172.17.0.1/255.255.0.0 Sudoers I/O plugin version 1.8.9p5 gzip version gzip 1.6 Copyright (C) 2007, 2010, 2011 Free Software Foundation, Inc. Copyright (C) 1993 Jean-loup Gailly. This is free software. You may redistribute copies of it under the terms of the GNU General Public License . There is NO WARRANTY, to the extent permitted by law. Written by Jean-loup Gailly. zip version Copyright (c) 1990-2008 Info-ZIP - Type 'zip "-L"' for software license. This is Zip 3.0 (July 5th 2008), by Info-ZIP. Currently maintained by E. Gordon. Please send bug reports to the authors using the web page at www.info-zip.org; see README for details. Latest sources and executables are at ftp://ftp.info-zip.org/pub/infozip, as of above date; see http://www.info-zip.org/ for other sites. Compiled with gcc 4.8.2 for Unix (Linux ELF) on Oct 21 2013. Zip special compilation options: USE_EF_UT_TIME (store Universal Time) BZIP2_SUPPORT (bzip2 library version 1.0.6, 6-Sept-2010) bzip2 code and library copyright (c) Julian R Seward (See the bzip2 license for terms of use) SYMLINK_SUPPORT (symbolic links supported) LARGE_FILE_SUPPORT (can read and write large files on file system) ZIP64_SUPPORT (use Zip64 to store large files in archives) UNICODE_SUPPORT (store and read UTF-8 Unicode paths) STORE_UNIX_UIDs_GIDs (store UID/GID sizes/values using new extra field) UIDGID_NOT_16BIT (old Unix 16-bit UID/GID extra field not used) [encryption, version 2.91 of 05 Jan 2007] (modified for Zip 3) Encryption notice: The encryption code of this program is not copyrighted and is put in the public domain. It was originally written in Europe and, to the best of our knowledge, can be freely distributed in both source and object forms from any country, including the USA under License Exception TSU of the U.S. Export Administration Regulations (section 740.13(e)) of 6 June 2002. Zip environment options: ZIP: [none] ZIPOPT: [none] vim version VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Nov 24 2016 16:43:18) Included patches: 1-52 Extra patches: 8.0.0056 Modified by pkg-vim-maintainers@lists.alioth.debian.org Compiled by buildd@ Huge version without GUI. Features included (+) or not (-): +acl +farsi +mouse_netterm +syntax +arabic +file_in_path +mouse_sgr +tag_binary +autocmd +find_in_path -mouse_sysmouse +tag_old_static -balloon_eval +float +mouse_urxvt -tag_any_white -browse +folding +mouse_xterm -tcl ++builtin_terms -footer +multi_byte +terminfo +byte_offset +fork() +multi_lang +termresponse +cindent +gettext -mzscheme +textobjects -clientserver -hangul_input +netbeans_intg +title -clipboard +iconv +path_extra -toolbar +cmdline_compl +insert_expand -perl +user_commands +cmdline_hist +jumplist +persistent_undo +vertsplit +cmdline_info +keymap +postscript +virtualedit +comments +langmap +printer +visual +conceal +libcall +profile +visualextra +cryptv +linebreak +python +viminfo +cscope +lispindent -python3 +vreplace +cursorbind +listcmds +quickfix +wildignore +cursorshape +localmap +reltime +wildmenu +dialog_con -lua +rightleft +windows +diff +menu -ruby +writebackup +digraphs +mksession +scrollbind -X11 -dnd +modify_fname +signs -xfontset -ebcdic +mouse +smartindent -xim +emacs_tags -mouseshape -sniff -xsmp +eval +mouse_dec +startuptime -xterm_clipboard +ex_extra +mouse_gpm +statusline -xterm_save +extra_search -mouse_jsbterm -sun_workshop -xpm system vimrc file: "$VIM/vimrc" user vimrc file: "$HOME/.vimrc" 2nd user vimrc file: "~/.vim/vimrc" user exrc file: "$HOME/.exrc" fall-back for $VIM: "/usr/share/vim" Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 Linking: gcc -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,--as-needed -o vim -lm -ltinfo -lnsl -lselinux -lacl -lattr -lgpm -ldl -L/usr/lib/python2.7/config-x86_64-linux-gnu -lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions iptables version iptables v1.4.21 curl version curl 7.35.0 (x86_64-pc-linux-gnu) libcurl/7.35.0 OpenSSL/1.0.1f zlib/1.2.8 libidn/1.28 librtmp/2.3 wget version GNU Wget 1.15 built on linux-gnu. rsync version rsync version 3.1.0 protocol version 31 gimme version v1.2.0 nvm version 0.33.6 perlbrew version /home/travis/perl5/perlbrew/bin/perlbrew - App::perlbrew/0.80 phpenv version rbenv 1.1.1-25-g6aa70b6 rvm version rvm 1.29.3 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io] default ruby version ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux] CouchDB version couchdb 1.6.1 ElasticSearch version 5.5.0 Installed Firefox version firefox 56.0.2 MongoDB version MongoDB 3.4.10 PhantomJS version 2.1.1 Pre-installed PostgreSQL versions 9.2.24 9.3.20 9.4.15 9.5.10 9.6.6 RabbitMQ Version 3.6.14 Redis version redis-server 4.0.6 riak version 2.2.3 Pre-installed Go versions 1.7.4 ant version Apache Ant(TM) version 1.9.3 compiled on April 8 2014 mvn version Apache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 2017-10-18T07:58:13Z) Maven home: /usr/local/maven-3.5.2 Java version: 1.8.0_151, vendor: Oracle Corporation Java home: /usr/lib/jvm/java-8-oracle/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "4.4.0-98-generic", arch: "amd64", family: "unix" gradle version ------------------------------------------------------------ Gradle 4.0.1 ------------------------------------------------------------ Build time: 2017-07-07 14:02:41 UTC Revision: 38e5dc0f772daecca1d2681885d3d85414eb6826 Groovy: 2.4.11 Ant: Apache Ant(TM) version 1.9.6 compiled on June 29 2015 JVM: 1.8.0_151 (Oracle Corporation 25.151-b12) OS: Linux 4.4.0-98-generic amd64 lein version Leiningen 2.8.1 on Java 1.8.0_151 Java HotSpot(TM) 64-Bit Server VM Pre-installed Node.js versions v4.8.6 v6.12.0 v6.12.1 v8.9 v8.9.1 phpenv versions system 5.6 * 5.6.32 (set by /home/travis/.phpenv/version) 7.0 7.0.25 7.1 7.1.11 hhvm hhvm-stable composer --version Composer version 1.5.2 2017-09-11 16:59:25 Pre-installed Ruby versions ruby-2.2.7 ruby-2.3.4 ruby-2.4.1 install_jdk Installing oraclejdk11 $ export JAVA_HOME=~/oraclejdk11 $ export PATH="$JAVA_HOME/bin:$PATH" $ ~/bin/install-jdk.sh --target "/home/travis/oraclejdk11" --workspace "/home/travis/.cache/install-jdk" --feature "11" --license "BCL" install-jdk.sh 2019-03-22 Variables: feature = 11 license = BCL os = linux-x64 url = http://download.oracle.com/otn-pub/java/jdk/11.0.2+9/f51449fcd52f4d52b93a989c5c56ed3c/jdk-11.0.2_linux-x64_bin.tar.gz status = 302 archive = /home/travis/.cache/install-jdk/jdk-11.0.2_linux-x64_bin.tar.gz Downloading JDK from http://download.oracle.com/otn-pub/java/jdk/11.0.2+9/f51449fcd52f4d52b93a989c5c56ed3c/jdk-11.0.2_linux-x64_bin.tar.gz. java version "11.0.2" 2019-01-15 LTS Java(TM) SE Runtime Environment 18.9 (build 11.0.2+9-LTS) Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.2+9-LTS, mixed mode) git.checkout 0.57s$ git clone --depth=50 --branch=master https://github.com/ShafigullinIK/project-lvl1-s498.git ShafigullinIK/project-lvl1-s498 Cloning into 'ShafigullinIK/project-lvl1-s498'. remote: Enumerating objects: 218, done. remote: Counting objects: 100% (218/218), done. remote: Compressing objects: 100% (130/130), done. remote: Total 218 (delta 85), reused 174 (delta 41), pack-reused 0 Receiving objects: 100% (218/218), 76.47 KiB | 3.06 MiB/s, done. Resolving deltas: 100% (85/85), done. $ cd ShafigullinIK/project-lvl1-s498 $ git checkout -qf fbd1d0e982d57cc301147d8e342684575732d9c4 $ java -Xmx32m -version java version "11.0.2" 2019-01-15 LTS Java(TM) SE Runtime Environment 18.9 (build 11.0.2+9-LTS) Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.2+9-LTS, mixed mode) $ javac -J-Xmx32m -version javac 11.0.2 3.01s$ ./mvnw install -DskipTests=true -Dmaven.javadoc.skip=true -B -V /home/travis/.travis/functions: line 315: ./mvnw: Permission denied The command "eval ./mvnw install -DskipTests=true -Dmaven.javadoc.skip=true -B -V " failed. Retrying, 2 of 3. /home/travis/.travis/functions: line 315: ./mvnw: Permission denied The command "eval ./mvnw install -DskipTests=true -Dmaven.javadoc.skip=true -B -V " failed. Retrying, 3 of 3. /home/travis/.travis/functions: line 315: ./mvnw: Permission denied The command "eval ./mvnw install -DskipTests=true -Dmaven.javadoc.skip=true -B -V " failed 3 times. The command "./mvnw install -DskipTests=true -Dmaven.javadoc.skip=true -B -V" failed and exited with 126 during . Your build has been stopped.
Похоже, что у скрипта ./mvnw не хватает прав на исполнение. Вставьте перед вызовом — chmod +x ./mvnw вот так:
language: java jdk: oraclejdk11 install: - mvn -N io.takari:maven:wrapper - chmod +x ./mvnw - ./mvnw install -DskipTests=true -Dmaven.javadoc.skip=true -B -V
Вячеслав, он и в таком виде работет:
Другое дело, что без » — mvn -N io.takari:maven:wrapper» не хочет работать. Как у остальных ребят с указанием просто языка и jdk
Не думаю, что это — большая проблема. Wrapper — это вполне штатный способ сборки проекта, так что использовать его вполне нормально. Не вижу зачем нужно избавляться от этого в тревисе учитывая, что Вы сами локально используете тот же wrapper. Нужно стараться что бы сборки происходили похожим образом, что бы локальные сборки не отличались от продакшн и соответственно были релевантны.
Вопрос в том что у других работает без этого, вы выше приводили файл из 2 строчек, который должен работать. У меня он не работает. Предполагаю, что раз не работает и пришлось в ручную добавлять эти строки, значит что то где то сделано не так. Мне интересно было понять что не так.
Ильнар Шафигуллин, по факту — только писать в службу поддержки jitpack’а. Или документацию пытаться шерстить, но там есть не всё и не всегда. Я так и делал когда только вышла 11-я java. Теперь такая же проблема с 12-й.