Getting other Java project JARs into Docker image? - java

I have a Quarkus project that uses some other common code from another Java project that I use mvn install on so it has access to it locally. Within Quarkus applications theres a Dockerfile.jvm that you can use to build the Docker image. The question is how do I get this other project into the Quarkus application's Docker image that I want to use? If I use mvn package and copy the JAR files into the target/ folder it doesn't seem to get picked up so I'm not sure what other ways to try this. Do I need to maybe copy the JARs into the target/ folder and then run use a mvn install from that path or something?

Related

How can I use multiple properties files and encryption keys in gitlab CI/CD stages

I have multiple properties files, encryption keys and others files stored across multiple location in my project. In the sonarqube stage, I am doing mvn sonar:sonar which basically builds the complete project as per my understanding. I know that mvn sonar:sonar stage happens on root or home directory where I had to create .m2 folder as well on root.
I am running this on Java maven project.
On my local or in other stages everything is working fine as it uses the local project directories where it finds all the properties file and project.
Can someone let me know what is the best practice/ way to run mvn sonar:sonar stage so that I don't have to individually create and copy files and folders as per local.

Docker File for Building Docker Image for Multi Module Java Maven Project

We have a Multi Module Project which is currently Builds in a specific order and creates a JAR and then finally ARM gets built which has all the other project as pom dependency and builds a WAR.
Screenshot of all the project
Order in Which Build is running
Now we are moving to docker and I am new in that and want something similar building but finally it should build a Docker image instead of WAR. So wanted to ask what will be the correct way, whether to keep the docker file in all the project or only in the ARM is enough which should convert war to docker image.
Can anyone provide some basic steps for writing docker file and guide to start and the correct way of implementation ?

Running a project built in docker in Eclipse

Sorry if I am being ignorant but I am quite confused on
How to run this project in eclipse:
https://github.com/ivanlomba/taboleiro
It was packed with docker and I have no experience with it whatsoever.
If anyone could help me out it would be great!
I'm not an Eclipse user, but It's a Spring Boot application and uses Maven as build tool, so you can import the project (files inside code folder) as "Existing maven project". There are tons of tutorials about creating/importing a Spring Boot project with Eclipse and Maven if you have any doubts.
If you don't use Docker you will need to configure the mysql database manually. You can find the schema of the database inside resources folder.
Docker part is only to deploy. Search for how to set up environment variables in your OS.
get Java 8 or newer, make sure the folder above bin of Java is defined as JAVA_HOME (like if your javac.exe path is "c:\program files\java\java8_121\bin\javac.exe" then JAVA_HOME="c:\program files\java\java8_121" without slash in the end
Download maven, unzip to a folder like c:\apps\maven then add the parent of the bin folder as MAVEN_HOME
like MAVEN_HOME=c:\apps\maven\maven_4_xyz
Change the PATH variable to be
PATH=%JAVA_HOME%\bin;%MAVEN_HOME%\bin;%PATH%
Now in termimal cd to the code folder of where you have cloned or unzipped https://github.com/ivanlomba/taboleiro/tree/master/code then give the commands
mvn install
mvn test
Now in IDE install maven plugin too if its not there, then can import as an existing maven project.
If your in linux change the paths to
MAVEN_HOME=/path/maven_4_xyz
and
export PATH=$JAVA_HOME/bin:$GRADLE_HOME/bin:$MVN_HOME/bin:$PATH
in ~/.profile or other place

How to Install & Deploy a java app (.jsp file) in apache tomcat

I have successfully installed apache tomcat & verified it to be working using the curl command
curl http://localhost:8080/
Tomcat is installed in
/var/lib/tomcat8/
webapps/ROOT/index.html
webapps/ROOT/META-INF
lib
I have received following structure of the java app in a zip file
App/
build.xml
deploy.sh
run.sh
www/
*.jsp files
WEB-INF/lib/*.jar files
I want to install and run this app on my server. How can I do that. Specifically I want to know where to place these folders. Do I need to run any of the deploy or build files. Do i need to install the jar files? If I directly run one of the .jsp files from curl command, it crashes due to missing java class.
Perhaps I am missing something obvious but I am new to java env and could not find it from google.
If you haven't tried it yet, consider using Maven to build your projects.
This will automate and simplify a lot of similar work for you, like creating a .war file and deploying your project to Tomcat. With Maven, you have to set the <packaging>war</packaging> in pom.xml (a project configuration file) and run mvn tomcat7:deploy command.
For details look at the above link to Maven docs or for instance check out this tutorial.
You can also use the Tomcat Manager under (default) http://localhost:8080/manager to deploy the .war file manually.

problems deploying a maven application with mvn command

I have a maven application under eclipse . The jsp pages and WEB-INF folder are located under the path NomeMiaApplicazione\src\main\webapp. I run these commands : mvn clean ,
mvn eclipse: eclipse and mvn compile under the root folder of the application, and in all three cases, the build is successful. However when I access the folder ( into the workspace )
. metadata.plugins\org.eclipse.wst.server.core\tmp2\wtpwebapps\NomeMiaApplicazione
, there are no jsp pages . what would be the solution for this problem ? thks !
It is necessary to clarify the role of the commands you used and their impact on Eclipse.
The mvn eclipse:eclipse command creates the Eclipse project files, in order to save you the hassle of configuring a new project and identifying all the sources for it. This command is also equivalent to creating a new Eclipse project from an existing Maven project using the m2e Eclipse plugin. See also this page regarding the eclipse:eclipse command. That being said, you only need to run such command once, and then import the resulting project into Eclipse.
Secondarily, mvn compile builds your source files into the target directory of your NomeMiaApplicazione root folder. This command does not involve Eclipse in any way. Also, web resources are still not packaged. To package them, you need to issue mvn package: you will then find the <artifact>-<version>.war file again under target, and the pre-packaged content under target\<artifact>-<version>. Beware that, in order to account for the webapp content, your Maven packaging must be of type war. Check the pom.xml for the <packaging> tag.
Finally, deployment is still another issue. If you actually need to move your .war file from the target directory to somewhere else (namely, an autodeploy folder of a servlet container), you can configure the Maven Deploy Plugin and issue mvn deploy. I'd rather suggest you to search SO for deploy war eclipse and/or deploy war maven, since there's plenty of related stuff. In the first case, you will find how to use Eclipse as a facility for deployment, while the second case leverages the command line to provide a more portable/flexible deployment procedure.
That's because mvn compile ends on compile phase of Maven's default lifecycle. Do mvn package and check then. And by the way, default Maven output directory is target so rather check it instead of kind of WTP temporary dirs.

Categories

Resources