How to run "ant update" in Hybris with only "Update Running System"? - java

I'm trying to run ant update from the command line after building my Hybris project but it runs Update Running System, Clear hMC Configuration from Database, Create essential data and Localize type (please refer the following image):
Is there a way to run ant update command from command line so that it will only select "Update Running System"?
What parameter can I pass with ant update to only run "Update Running System" and not any other options?

You can use the command -DconfigFile=<your file> :
Example:
ant updatesystem -Dtenant=<my tenant> -DconfigFile=path/to/my/config.json
And here is an example of the config.json
{
"init": "Go",
"initmethod": "update",
"clearhmc": "true",
"essential": "true",
"localizetypes": "true",
"solrfacetsearch_sample": "true",
"hmc_sample": "true",
"solrfacetsearchhmc_sample": "true",
"customerreview_sample": "true",
"voucher_sample": "true",
"promotions_sample": "true",
"basecommerce_sample": "true",
"cms2_sample": "true",
"cms2lib_sample": "true",
"ticketsystem_sample": "true",
"payment_sample": "true",
"btg_sample": "true",
"platformhmc_sample": "true",
"commerceservices_sample": "true",
"commercewebservicescommons_sample": "true",
"acceleratorservices_sample": "true",
"acceleratorcms_sample": "true",
"yacceleratorfulfilmentprocess_sample": "true",
"yacceleratorcore_sample": "true",
....
"electronicsstore_importCoreData": [
"yes"
],
"electronicsstore_importSampleData": [
"yes"
],
"electronicsstore_activateSolrCronJobs": [
"yes"
],
"yacceleratortest_createTestData": [
"yes"
],
"yacceleratorcockpits_importCustomReports": [
"yes"
]
}
As you can see, it's not so easy to implement this file. As suggested in Initializing and Updating SAP Hybris Commerce, go to the HAC once, do your configuration in the webpage and click on Dump configuration. It will give you the generated json file.

Try with ant ant updatesystem .
To see the list of possible commands(targets) you can write ant -p . There you can find more about the commands.

ant updatesystem [-Dtenant=tenantID -DdryRun=true|false
-DtypeSystemOnly=true|false -DconfigFile=PATH_TO_CONFIG_FILE]

You can also use this command to update the system without importing any impexes.
ant updatesystem -DtypeSystemOnly=true

Related

Is it posssible to sign JavaApplicationStub with intstall4j?

I'm trying to create a macOS Single bundle archive for my Java program. But you know MacOs have some new security rule. So i subscribe for an Developer ID Application for generate the archive.
When i launch the build after uploading the archive it come back with this response from Apple :
{
"logFormatVersion": 1,
"jobId": "X",
"status": "Invalid",
"statusSummary": "Archive contains critical validation errors",
"statusCode": 4000,
"archiveFilename": "XXX.dmg",
"uploadDate": "2021-02-11T15:54:19Z",
"sha256": "",
"ticketContents": null,
"issues": [
{
"severity": "error",
"code": null,
"path": "XXX.dmg/XXX.app/Contents/MacOS/JavaApplicationStub",
"message": "The signature of the binary is invalid.",
"docUrl": null,
"architecture": "x86_64"
}
]
}
So i try everything but i don't know how to sign the JavaApplication with install4j.
I'm sorry if i done some error in my english writing.
I'm trying to learn ^ ^ .
Thank you

VS Code starts debugging in integrated terminal instead of debug console for java

Can somebody help me with this. I am getting output in terminal not in debug console.
Here is my Launch json file.
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Debug (Launch) - Current File",
"request": "launch",
"mainClass": "${file}"
}
]
}
Add "console": "internalConsole" in launch.json, which specifies VS Code debug console (input stream not supported) to launch the program.
More information about debugging, please view Launch args in Java.

Can't figure out how to use Prettier Plugin in .prettierrc

I'm using Prettier for a Java project. Prettier doesn't format Java by default, so instead I installed this plugin here: https://github.com/jhipster/prettier-java
Following the directions in the README works fine, however, I'd prefer not to type a terminal command to reformat all my java files every time I modify anything. Instead I'd like to format a file anytime I save it. This is currently in my settings.json:
"[java]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"editor.formatOnSave": true
However, using Shift+Alt+F, the default command for formatting in VScode, results in the error "There is no formatter for "java" files installed". How do I configure my .prettierrc file to properly use the plugin to format java files?
This is my .prettierrc file right now:
{
"plugins": [
"prettier-plugin-java"
],
"pluginSearchDirs": [
"./node_modules"
],
"overrides": [{
"files": "**/*.java",
"options": {
plugins: [
"prettier-plugin-java"
]
}
}]
}
Used same settings in .prettierrc and settings.json file
except
"[java]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
and added default formatter for java files as follows
Open command Palette... Ctrl + Shift + P (mac command + shift + P) and
search Format Document With...
select Configure Default Formatter...
choose Language Support for Java(TM) by Red Hat
Working sample
Now if I add following in settings.json
"[java]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
got the same issue as of yours
So the solution will be to remove above settings from the settings.json file.
settings.json file
{
"files.eol": "\n",
"terminal.explorerKind": "external",
"terminal.integrated.shell.osx": "/bin/zsh",
"editor.minimap.enabled": true,
"workbench.colorTheme": "Visual Studio Dark",
"editor.fontSize": 14,
"editor.fontFamily": "source code pro, Menlo, Monaco, 'Courier New', monospace",
"terminal.external.osxExec": "iterm.app",
"window.zoomLevel": 1,
"go.useLanguageServer": true,
"editor.formatOnSave": true,
"editor.suggestSelection": "first",
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
"breadcrumbs.enabled": false
}
P.S.
Make sure Java Extension Pack vscjava.vscode-java-pack is installed, used v0.12.1
Ref:
https://github.com/redhat-developer/vscode-java/issues/220
Beautify / Format Java code in Visual Studio Code
https://code.visualstudio.com/docs/java/java-linting
https://github.com/jhipster/prettier-java
https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode

Jenkins Java: Get user who started the build

Under http://[JENKINS_NAME]/job/[JOB_NAME]/[BUILD_NUMBER]/
I can see Started by user [USER_NAME].
I want to get that username from my java application.
Any help is much appreciated.
You can make a http call to get all these details. URL to get those details is:
http://<Jenkins URL>/job/<job name>/<build number>/api/json
After the rest call, you will be getting this json.
{
"_class": "hudson.model.FreeStyleBuild",
"actions": [
{
"_class": "hudson.model.CauseAction",
"causes": [
{
"_class": "hudson.model.Cause$UserIdCause",
"shortDescription": "Started by user XXXXXX",
"userId": "xxx#yyy.com",
"userName": "ZZZZZZZZ"
}
]
},
{},
{
"_class": "jenkins.metrics.impl.TimeInQueueAction"
},
{},
{}
],
...
}
So All you have do is parse this json and get the value under javavar['actions'][0]['causes'][0]['userName']. Definitely it will be like that only. I maynot be sure about the indexes. You just try and figure out. Hope this helps.
Mostly for every page in the jenkins instance, you will be having REST API link. Please click on it to see the rest api url and its output for that url.
You could get the build user from Jenkins environment (i.e as an env var). If you use Jenkins 2 pipeline, For example:
pipeline {
//rest of the pipeline
stages {
stage('Build Info') {
steps {
wrap([$class: 'BuildUser']) {
sh 'java -jar <your_java_app>.jar'
}
}
}
}
In your java app you should be able to get the environment variable using System.getenv("BUILD_USER") or else you could pass it as a JVM arg. Ex: sh 'java -jar -DbuildUser=$BUILD_USER <your_java_app>.jar' and get the buildUser system property in the application.
On older version of Jenkins, you may use Build User Vars Plugin or Env Inject plugin. As in the answers on this question. how to get the BUILD_USER in Jenkins when job triggered by timer

Apache Ignite on on DC/OS marathon (or any other java app)

I've been trying to configure Apache Ignite on DC/OS (1.8.7) marathon using the official docs at http://apacheignite.gridgain.org/docs/mesos-deployment but short of some hacks I haven't been able to get it to work following the docs. One of the core reasons appear to be that the cmd
"cmd": "java -jar ignite-mesos-1.8.0.jar"
will through an error "sh: java: command not found". This would indicate that java is not in the path but on the marathon hosts I've validated that java is in fact accessible on the path for my regular user at least.
I suspect that somehow java needs to be added to the path of mesos-container that is trying to run the cmd but I've been unable to find any documentation on how to set the path or default environment variables (ignite-mesos spawns tasks that need JAVA_HOME set as well, which is also missing in the tasks) in the containers that get created. For reference my marathon.json file is below...
{
"id": "/ignition",
"cmd": "java -jar ignite-mesos-1.8.0.jar",
"args": null,
"user": null,
"env": {
"IGNITE_MEMORY_PER_NODE": "2048",
"IGNITE_NODE_COUNT": "3",
"IGNITE_VERSION": "1.8.0",
"MESOS_MASTER_URL": "zk://master.mesos:2181/mesos",
"IGNITE_RUN_CPU_PER_NODE": "0.1"
},
"instances": 0,
"cpus": 0.25,
"mem": 2048,
"disk": 0,
"gpus": 0,
"executor": null,
"constraints": null,
"fetch": [
{
"uri": "http://SERVER_HERE/ignite-mesos-1.8.0.jar"
}
],
"storeUrls": null,
"backoffSeconds": 1,
"backoffFactor": 1.15,
"maxLaunchDelaySeconds": 3600,
"container": null,
"healthChecks": null,
"readinessChecks": null,
"dependencies": null,
"upgradeStrategy": {
"minimumHealthCapacity": 1,
"maximumOverCapacity": 1
},
"labels": {
"HAPROXY_GROUP": "external"
},
"acceptedResourceRoles": null,
"ipAddress": null,
"residency": null,
"secrets": null,
"taskKillGracePeriodSeconds": null,
"portDefinitions": [
{
"protocol": "tcp",
"port": 10108
}
],
"requirePorts": false
}
Ignite seems to expect a JDK 1.7/1.8 installation on each agent node, and the JAVA_HOME environment variable set accordingly.
Unfortunately, the Mesos framework doesn't seem to be well-maintained, as it still uses Mesos 0.22 libraries.

Categories