• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

heroku/heroku-buildpack-java: A Heroku buildpack for Java apps.

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

heroku/heroku-buildpack-java

开源软件地址:

https://github.com/heroku/heroku-buildpack-java

开源编程语言:

Shell 85.5%

开源软件介绍:

Heroku buildpack for Java CircleCI

java

This is the official Heroku buildpack for Java apps. It uses Maven 3.6.2 to build your application and OpenJDK 8 to run it. However, the JDK version can be configured as described below.

How it works

The buildpack will detect your app as Java if it has a pom.xml file, or one of the other POM formats supports by the Maven Polyglot plugin, in its root directory. It will use Maven to execute the build defined by your pom.xml and download your dependencies. The .m2 folder (local maven repository) will be cached between builds for faster dependency resolution. However neither the mvn executable nor the .m2 folder will be available in your slug at runtime.

Documentation

For more information about using Java and buildpacks on Heroku, see these Dev Center articles:

Examples

Configuration

Choose a JDK

Create a system.properties file in the root of your project directory and set java.runtime.version=1.8.

Example:

$ ls
Procfile pom.xml src

$ echo "java.runtime.version=1.8" > system.properties

$ git add system.properties && git commit -m "Java 8"

$ git push heroku main
...
-----> Java app detected
-----> Installing OpenJDK 1.8... done
-----> Installing Maven 3.3.3... done
...

Choose a Maven Version

You can define a specific version of Maven for Heroku to use by adding the Maven Wrapper to your project. When this buildpack detects the presence of a mvnw script and a .mvn directory, it will run the Maven Wrapper instead of the default mvn command.

If you need to override this, the system.properties file also allows for a maven.version entry (regardless of whether you specify a java.runtime.version entry). For example:

java.runtime.version=1.8
maven.version=3.3.9

Customize Maven

There are three config variables that can be used to customize the Maven execution:

  • MAVEN_CUSTOM_GOALS: set to clean dependency:list install by default
  • MAVEN_CUSTOM_OPTS: set to -DskipTests by default
  • MAVEN_JAVA_OPTS: set to -Xmx1024m by default

These variables can be set like this:

$ heroku config:set MAVEN_CUSTOM_GOALS="clean package"
$ heroku config:set MAVEN_CUSTOM_OPTS="--update-snapshots -DskipTests=true"
$ heroku config:set MAVEN_JAVA_OPTS="-Xss2g"

Other options are available for defining a custom settings.xml file.

Development

To make changes to this buildpack, fork it on Github. Push up changes to your fork, then create a new Heroku app to test it, or configure an existing app to use your buildpack:

# Create a new Heroku app that uses your buildpack
heroku create --buildpack <your-github-url>

# Configure an existing Heroku app to use your buildpack
heroku buildpacks:set <your-github-url>

# You can also use a git branch!
heroku buildpacks:set <your-github-url>#your-branch

For example if you want to have Maven available to use at runtime in your application, you can copy it from the cache directory to the build directory by adding the following lines to the compile script:

for DIR in ".m2" ".maven" ; do
  cp -r $CACHE_DIR/$DIR $BUILD_DIR/$DIR
done

This will copy the local Maven repo and Maven binaries into your slug.

Commit and push the changes to your buildpack to your GitHub fork, then push your sample app to Heroku to test. Once the push succeeds you should be able to run:

$ heroku run bash

and then:

$ ls -al

and you'll see the .m2 and .maven directories are now present in your slug.

Run Tests Locally

Tests can be run and debugged locally by using the Circle CI CLI.

For example, to run Hatchet tests on heroku-18 run:

$ circleci local execute --job hatchet-heroku-18 \
    --env HEROKU_API_USER=$(heroku whoami) \
    --env HEROKU_API_KEY=$(heroku auth:token)

Available jobs are defined in .circleci/config.yml.

Costs

This command uses the credentials from your local heroku configuration. This means your account will be billed for any cost these tests incur. Proceed with caution.

License

Licensed under the MIT License. See LICENSE file.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap