Java commands in Eclim - java

When I run eclim -? commands, I get the following output.
Available Commands:
archive_read -f file
history_add -p project -f file
history_clear -p project -f file
history_list -p project -f file
history_revision -p project -f file -r revision
jobs [-f family]
locate_file -p pattern -s scope [-n project] [-f file]
[-i]
ping
problems -p project [-e]
project_build -p project
project_by_resource -f file
project_close -p project
project_create -f folder [-p name] -n natures [-d depends]
[-a args]
project_delete -p project
project_import -f folder
project_info -p project
project_link_resource -f file
project_list [-n nature]
project_move -p project -d dir
project_nature_add -p project -n nature [-a args]
project_nature_aliases [-m]
project_nature_remove -p project -n nature
project_natures [-p project]
project_open -p project
project_refresh -p project
project_refresh_file -p project -f file
project_rename -p project -n name
project_run [-p project] [-v vim_instance_name] [-x vim_executable] [-l]
[-d] [-c] [-n name]
project_run_terminate [-l launchid]
project_setting -p project -s setting [-v value]
project_settings [-p project]
project_update -p project [-b buildfile] [-s settings]
projects
refactor_redo [-p]
refactor_undo [-p]
reload
setting -s setting
settings
settings_update [-s settings]
shutdown
workspace_dir
xml_format -f file -w linewidth -i indent -m fileformat
xml_validate -p project -f file [-s]
I do not see Java commands such as java_search or java_element_doc. How can I access them?
I have installed eclim version 2.5, and selected "Java Development" in the installation menu.

Related

Github action gradle build cannot create application properties file in jar file

I'm building CI/CD using Spring Boot, gradle, GitHub Actions, Docker, AWS.
application properties is separate (application-dev.properties, application-prod.properties) and generates files in GitHub-Actions like that
## make application-dev.properties
- name: make application-dev.properties
if: contains(github.ref, 'feature/#125-CICD')
run: |
echo "ls -a . & pwd"
pwd
ls -a .
echo "mkdir & touch"
mkdir -p ./src/main/resource
cd ./src/main/resource
touch ./application-dev.properties
pwd
ls -a .
echo "copy properties"
echo $DEV_PROP >> ./application-dev.properties
cat application-dev.properties
shell: bash
env:
DEV_PROP: ${{ secrets.PROPERTIES_DEV }}
It's working fine and created file
next, after build with gradle, when i extracted the jar file after building the gradle and checked it, the properties file does not exist.
check jar file code like that
## check jar file
- name: check jar file
if: contains(github.ref, 'feature/#125-CICD')
run: |
pwd
ls -a .
cd ./build/libs
ls -a .
jar xvf Web-Team-2-Backend-0.0.1-SNAPSHOT.jar
ls -a .
cd ./BOOT-INF/classes
pwd
ls -a .
shell: bash
If you check the result, the application-dev.properties file created before does not exist...
What's the problem?
the full code is as follows:
name: CI/CD
# event trigger
on:
push:
branches:
- main
- develop
- feature/#125-CICD
permissions:
contents: read
jobs:
CI-CD:
runs-on: ubuntu-latest
steps:
## jdk setting
- uses: actions/checkout#v3
- name: Set up JDK 11
uses: actions/setup-java#v3
with:
java-version: '11'
distribution: 'temurin' # https://github.com/actions/setup-java
## gradle caching
- name: Gradle Caching
uses: actions/cache#v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
## make application-dev.properties
- name: make application-dev.properties
if: contains(github.ref, 'feature/#125-CICD')
run: |
echo "ls -a . & pwd"
pwd
ls -a .
echo "mkdir & touch"
mkdir -p ./src/main/resource
cd ./src/main/resource
touch ./application-dev.properties
pwd
ls -a .
echo "copy properties"
echo $DEV_PROP >> ./application-dev.properties
cat application-dev.properties
shell: bash
env:
DEV_PROP: ${{ secrets.PROPERTIES_DEV }}
## gradle build
- name: Build with Gradle
run: ./gradlew build -x test -x ktlintCheck -x ktlintTestSourceSetCheck -x ktlintMainSourceSetCheck -x ktlintKotlinScriptCheck
## check jar file
- name: check jar file
if: contains(github.ref, 'feature/#125-CICD')
run: |
pwd
ls -a .
cd ./build/libs
ls -a .
jar xvf Web-Team-2-Backend-0.0.1-SNAPSHOT.jar
ls -a .
cd ./BOOT-INF/classes
pwd
ls -a .
shell: bash
i solved this problem..
path is resources, not resource :(
## make application-dev.properties
- name: make application-dev.properties
if: contains(github.ref, 'feature/#125-CICD')
run: |
echo "ls -a . & pwd"
pwd
ls -a .
echo "mkdir & touch"
mkdir -p ./src/main/resource << here !!
cd ./src/main/resource
touch ./application-dev.properties
pwd
ls -a .
echo "copy properties"
echo $DEV_PROP >> ./application-dev.properties
cat application-dev.properties
shell: bash
env:
DEV_PROP: ${{ secrets.PROPERTIES_DEV }}

How to run xmlstarlet commands on Heroku

I have build.xml where a shell script fires xmlstarlet ed -L -s "/Package/types[name='$TYPENAME']" -t elem -n members -v "$ENTITY" $SCRIPTFILE command to create xml nodes.
if [[ "$2" != *"destructive"* ]]
then
xmlstarlet ed -L -s /Package -t elem -n version -v "43.0" $SCRIPTFILE
fi
xmlstarlet ed -L -i /Package -t attr -n xmlns -v "http://soap.sforce.com/2006/04/metadata" $SCRIPTFILE
This works fine when running locally via springboot app as I have xmlstartlet installed. But when I host this in Heroku it fails with generate_package_unix6199938543217323388.sh: line 193: xmlstarlet: command not found. Is there a workaround or a way to install xmlstartlet on heroku ?
You can install the xmlstarlet apt package by using the apt buildpack. To do so, create an Aptfile in the root directory of your app with the following contents:
xmlstarlet
Make sure you add it to Git with git add and git commit.
Then add the apt buildpack to your app by running:
$ heroku buildpacks:add -i 1 heroku-community/apt
When you redeploy, the xmlstarlet command should be installed.

Logs stucks when deployment is done through teamcity

Recently we migrated to Teamcity deployment from manual process. Ours is java application on linux server.
Whenever deployment is done through Teamcity, logs are stuck i.e. after shutdown log messages nothing else is printed in the logs. Then we run manual stop and start scripts on the server to get the logs running.
Looks like somehow Teamcity locks log file and doesn't release it.
How to overcome it?
In Teamcity, deploy step is defined as below:
REMOTE_PATH="/opt/app/$ARTIFACT/releases/teamcity"
cd $TEAMCITY_REPO_HOME/$ARTIFACT/build/libs
echo "Uploading artifact"
ssh $UAT_HOST -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "mkdir -p $REMOTE_PATH"
scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $ARTIFACT.jar $UAT_HOST:$REMOTE_PATH
echo "Stopping service"
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $UAT_HOST "sh /opt/app/$ARTIFACT/stop.sh"
sleep 3s
echo "Copying new artifact"
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $UAT_HOST "cp $REMOTE_PATH/$ARTIFACT.jar /opt/app/$ARTIFACT"
sleep 6s
echo "Starting service"
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $UAT_HOST "sh /opt/app/$ARTIFACT/start.sh"
Taking ideas from above comments of Andy Dufresne, I created one deploy script as below:
This single script stops server, takes backup of current artifact, copies new build and then executes start script to start the server.
#!/bin/bash
#check for correct number of arguments
if [ "$#" -ne 1 ]; then
echo "Incorrect number of arguments, exiting..."
exit 1
fi
ARTIFACT=$1
cd "/opt/app/$ARTIFACT"
echo $(pwd)
echo "Stopping service"
bash stop.sh
sleep 3s
echo "Tagging artifact with release"
cp "releases/teamcity/$ARTIFACT.jar" "releases/teamcity/$ARTIFACT`date +'_%y_%m_%d'`.jar"
echo "Deleting old releases"
cd "releases/teamcity" && \
ls | grep -v '/$' | head -n -6 | xargs -d '\n' -r rm -- && \
cd "/opt/app/$ARTIFACT" && \
ls -l "releases/teamcity"
echo "Copying new artifact"
cp "releases/teamcity/$ARTIFACT.jar" .
echo "Starting service"
bash start.sh
sleep 2s
This script is called from team-city in its build steps(previously stopping server, copying artifact and starting server all were done by teamcity explicitly as outlined in the question.)
Now teamcity build step looks concise as under and WORKS as expected(that important !!!):
REMOTE_PATH="/opt/app/$ARTIFACT/releases/teamcity"
cd $TEAMCITY_REPO_HOME/$ARTIFACT/build/libs
echo "Uploading artifact"
ssh -o "StrictHostKeyChecking=no" "$UAT_HOST" "mkdir -p $REMOTE_PATH"
scp -o "StrictHostKeyChecking=no" "$ARTIFACT.jar" "$UAT_HOST:$REMOTE_PATH"
echo "Deploying artifact"
ssh -o "StrictHostKeyChecking=no" "$UAT_HOST" "sh /opt/app/$ARTIFACT/deploy.sh $ARTIFACT"

run java project using .sh file in jenkins in mac

i want to run a java project in jenkins in mac.i have the following .sh file and its code is given below:
#!/bin/bash
echo $#
${jvmargs[#]}
DIR=$(dirname $0)
args=( "$#" )
javaProps=( )
server_jvmargs=( -Djava.awt.headless=true -Xms1024m -Xmx1024m"${jvmargs[#]}" )
XX_HOME="$DIR"
client_classpath="$XX_HOME/lib/others/*:$XX_HOME/lib/http/*:$XX_HOME/lib/selenium-java-2.37.0/*:$XX_HOME/lib/selenium-java-2.37.0/libs/*:$XX_HOME/lib/TestNG/*:$XX_HOME/lib/mailactivation/*:$XX_HOME/bin"
BIN_PATH="$XX_HOME/bin"
SRC_PATH="$XX_HOME/src"
rm -rfv "$BIN_PATH"
chmod 777 "$BIN_PATH"
mkdir -p "$BIN_PATH"
cd $DIR
javac \
-cp "$client_classpath" \
-d "$BIN_PATH" \
-sourcepath $SRC_PATH src/com/*.java
java \
"${server_jvmargs[#]}" \
"${javaProps[#]}" \
-Dxx.home="$XX_HOME" \
-Duser.dir="$XX_HOME" \
-cp "$client_classpath" \
org.testng.TestNG temp-testng-customsuite.xml
i set the custom workspace and use this run.sh file in build setup(Execute Shell). But it shows the following error:
Started by user Ali Azam JenkinTest
Building in workspace /Users/aliazam/Desktop/App/eclipse/workspace/Training
java.io.IOException: Failed to mkdirs: /Users/aliazam/Desktop/App/eclipse/workspace/Training
at hudson.FilePath.mkdirs(FilePath.java:1164)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1268)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild. java:610)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:532)
at hudson.model.Run.execute(Run.java:1741)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:410)
Finished: FAILURE
can anyone please help me to solve this problem????

Makefile run more than once

I'm trying to compile my Java code with this Makefile. How ever when I run make, it compiles the code more than once.
Makefile:
.PHONY: all clean run
SOURCES = \
Models/CustomException \
Models/Forest \
Models/ForestContainer \
Models/Owner \
Models/OwnerContainer \
Models/Tree
SRC = $(addprefix src/, $(addsuffix .java, $(SOURCES)))
BIN = $(addprefix bin/, $(addsuffix .class, $(SOURCES)))
all: ${BIN}
clean:
-rm -f ${BIN};
${BIN}: ${SRC}
mkdir -p bin/Controllers;
mkdir -p bin/Models;
mkdir -p bin/Views;
javac -d bin ${SRC};
run: all
java -cp bin Program;
Output:
┌─( klim ) - ( ~/workspace/Forest-mvc )
└─> make
mkdir -p bin/Controllers;
mkdir -p bin/Models;
mkdir -p bin/Views;
javac -d bin src/Models/CustomException.java src/Models/Forest.java src/Models/ForestContainer.java src/Models/Owner.java src/Models/OwnerContainer.java src/Models/Tree.java;
mkdir -p bin/Controllers;
mkdir -p bin/Models;
mkdir -p bin/Views;
javac -d bin src/Models/CustomException.java src/Models/Forest.java src/Models/ForestContainer.java src/Models/Owner.java src/Models/OwnerContainer.java src/Models/Tree.java;
mkdir -p bin/Controllers;
mkdir -p bin/Models;
mkdir -p bin/Views;
javac -d bin src/Models/CustomException.java src/Models/Forest.java src/Models/ForestContainer.java src/Models/Owner.java src/Models/OwnerContainer.java src/Models/Tree.java;
mkdir -p bin/Controllers;
mkdir -p bin/Models;
mkdir -p bin/Views;
javac -d bin src/Models/CustomException.java src/Models/Forest.java src/Models/ForestContainer.java src/Models/Owner.java src/Models/OwnerContainer.java src/Models/Tree.java;
mkdir -p bin/Controllers;
mkdir -p bin/Models;
mkdir -p bin/Views;
javac -d bin src/Models/CustomException.java src/Models/Forest.java src/Models/ForestContainer.java src/Models/Owner.java src/Models/OwnerContainer.java src/Models/Tree.java;
mkdir -p bin/Controllers;
mkdir -p bin/Models;
mkdir -p bin/Views;
javac -d bin src/Models/CustomException.java src/Models/Forest.java src/Models/ForestContainer.java src/Models/Owner.java src/Models/OwnerContainer.java src/Models/Tree.java;
As you can see it runs the commands more than once, actually 6 times. The number of times it run the commands increase/decrease as number of SOURCES are added/removed
How can this be?
just add the main classes after javac.
${BIN}: ${SRC}
javac -d bin -cp . Models/Tree.java
All the classes and the folders (packages) that depend of the main classes will be automatically compiled. Your make is compiling again and again some classes that have already been compiled.
The first target in your Makefile, all, depends on 6 different sub-targets. Presumably, at the beginning of the run, none of these exists, so make thinks it needs to build each of those 6 sub-targets. However, building any one of those sub-targets actually builds all 6 of them the way you have this defined - but make doesn't know that.
The bottom line is, it's doing what you told it to. The fact that what you told it to do is redundant doesn't matter to make.
For each target int ${BIN} make will invoke the ${BIN}: ${SRC} rule but you give it all the sources on the command line for javac. You probably want to replace the ${SRC} with $< on the javac line.

Categories