Cyclenerd / scp-tools-gitlab

🦊 Docker Image with SAP Cloud Platform Tools (SAP Business Technology Platform) optimized for GitLab Runner and Google Cloud Build
https://hub.docker.com/r/cyclenerd/scp-tools-gitlab
GNU Affero General Public License v3.0
11 stars 5 forks source link

Add Maven to the package #5

Closed dbizien closed 1 year ago

dbizien commented 2 years ago

Hi,

I'm using your image on GitLab to deploy my projects on SAP BTP. I have recently update the BI project to integrate the Hana Analytic Adapter (haa) inside the project. (See the blog from SAP : https://blogs.sap.com/2021/07/12/sap-analysis-for-microsoft-office-and-sap-hana-cloud-hands-on-video-tutorials/ )

Nevertheless, the haa needs maven to be builded. At this day, add it in my gitlab-ci but it could be a lot more efficient if it was included in the image.

To add it to your image, you just need 2 commands 👍

Installation outils maven

- apt update
- apt -y install maven

Regards,

Cyclenerd commented 2 years ago

Can you please provide more details what exactly is done in/with the image. You are also welcome to send a pull request.

dbizien commented 2 years ago

Hi,

I use the image to build & deploy on GitLab projects on SAP Business Technology Platform on Cloud Foundry. I need maven for a project developed on Business Application Studio for BI. In the project, there is a java component delivered by SAP which permit the connexion between SAC or Analysis for office and HANA on BTP. Maven is used to build the component during the build phase on GitLab and then GitLab deploy the mtar to BTP. I do not offer a pull request because I'm not an expert with docker image. I know the command will work as I have add them in my GitLab CI file in order to build the mtar. Nevertheless, It is not very optimum to install maven each time I'm using your great image ! (By the way, really thank you for your job, it was really helpful).

Regards, David

Cyclenerd commented 2 years ago

Maven will replace the SAP JDK with OpenJDK:

Setting up openjdk-11-jre-headless:amd64 (11.0.13+8-0ubuntu1~20.04) ...
update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/bin/java to provide /usr/bin/java (java) in auto mode
update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/bin/jjs to provide /usr/bin/jjs (jjs) in auto mode
update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/bin/keytool to provide /usr/bin/keytool (keytool) in auto mode
update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/bin/rmid to provide /usr/bin/rmid (rmid) in auto mode
update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/bin/rmiregistry to provide /usr/bin/rmiregistry (rmiregistry) in auto mode
update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/bin/pack200 to provide /usr/bin/pack200 (pack200) in auto mode
update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/bin/unpack200 to provide /usr/bin/unpack200 (unpack200) in auto mode
update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/lib/jexec to provide /usr/bin/jexec (jexec) in auto mode
Setting up maven (3.6.3-1) ...
update-alternatives: using /usr/share/maven/bin/mvn to provide /usr/bin/mvn (mvn) in auto mode

I want to keep SAP JDK in the image.

dbizien commented 2 years ago

Understood. I will investigate a bit more in order to see if I found another way to compile or we can keep SAP JDK with Maven. Thanks.

theCalcaholic commented 2 years ago

@Cyclenerd Ubuntu installs various java versions alongside each other, openjdk does not replace SAP jdk

You can verify this with the following command:

# update-alternatives --list java
/usr/lib/jvm/java-11-openjdk-amd64/bin/java
/usr/lib/jvm/sapmachine-17/bin/java

If you want to configure SAP jdk as the default (i.e. the java version in PATH), add the following command:

update-alternatives --set java /usr/lib/jvm/sapmachine-17/bin/java

SAP JDK actually installs more alternatives than that, but those aren't overwritten by openjdk (at least as it is installed by the maven package). If you want to make sure that all of these are set to the appropriate SAP JDK binary (even if maven or another package were to overwrite any of them in the future), you can use the following code snippet:

apt-get -y --no-install-recommends install maven
for alternative in jar jarsigner java javac javadoc javap jcmd jconsole jdb jdeprscan jdeps jfr jhsdb jimage jinfo jlink jmap jmod jpackage jps jrunscript jshell jstack jstat jstatd keytool
do
  update-alternatives --set "${alternative} "/usr/lib/jvm/sapmachine-17/bin/${alternative}" || true
done

But personally, I think that might be overkill :)

Cyclenerd commented 1 year ago

Added with pull https://github.com/Cyclenerd/scp-tools-gitlab/pull/16