Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use this in recipe #47

Open
maulik9898 opened this issue Jun 9, 2024 · 2 comments
Open

How to use this in recipe #47

maulik9898 opened this issue Jun 9, 2024 · 2 comments

Comments

@maulik9898
Copy link

I want to use this layer in my recipe which compile java using gradlew. currently its bitbake gives error saying JAVA_HOME is not definde or no java present.

@sebveit
Copy link
Contributor

sebveit commented Jun 10, 2024

You should/could execute the distTar task of gradle to create an archive
and copy that archive to your OE/Yocto setup.
You also need a custom layer with a custom recipe in it.
The recipe could be situated under meta-myownlayer/recipes-core/my-java-app/my-java-app_1.0.bb
with the following content:

DESCRIPTION = "My own Java app that runs on the device."
HOMEPAGE = "https://git.example.org/my-java-app"
SECTION = "my-custom"

LICENSE = "Proprietary"
LICENSE_FLAGS = "commercial"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Proprietary;md5=0557f9d92cf58f2ccdd50f62f8ac0b28"

# RDEPENDS must be list of package names (not recipe names)
# RDEPENDS:${PN} = "postgresql mysql"

SRC_URI = "file://my-java-app-1.0-SNAPSHOT.tar \
           file://my-java-app.service \
           file://config.properties.dist \
          "

inherit systemd

FILES:${PN} = "/opt/my-java-app"
SYSTEMD_SERVICE:${PN} = "my-java-app.service"

do_configure[noexec] = "1"
do_compile[noexec] = "1"

do_install() {
  install -d ${D}/opt/my-java-app/bin
  install -m 0755 ${S}/bin/my-java-app \
    ${D}/opt/my-java-app/bin/

  install -d ${D}/opt/my-java-app/lib
  install -m 0644 ${S}/lib/* \
    ${D}/opt/my-java-app/lib/

  install -d ${D}/opt/my-java-app/etc
  install -m 0640 ${WORKDIR}/config.properties.dist \
    ${D}/opt/my-java-app/etc/

  install -d ${D}${systemd_system_unitdir}
  install -m 0644 ${WORKDIR}/my-java-app.service \
    ${D}${systemd_system_unitdir}
}

This should work without further config like JAVA_HOME.
Please read the documentation of Yocto about writing your own recipe.
See https://docs.yoctoproject.org/dev-manual/new-recipe.html but make sure to use the correct branch/release on the documentation.

@sebveit sebveit pinned this issue Jul 22, 2024
@GeVa2072
Copy link
Contributor

Hi @maulik9898,

don’t forget to add to `RDEPENDS:${PN}ˋ openjdk-xx-jre, where xx is java version to embed in your target for running your app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants