Create a CentOS virtual machine on virtual box
-
Define a new linux guest in virtual box
-
Insert the CentOS dvd iso into the virtual dvd drive
-
Enable networking. After installation, by default CentOS 7 networking is disabled.
vi /etc/sysconfig/network-scripts/ifcfg-enp0s3 #change ONBOOT=no to ONBOOT=yes systemctl restart network
-
(optional) Add port forwarding to allow ssh connections for convenience, i.e. 2222 to 22 on the CentOS guest
Install preferred vcs
yum install git
Install Maven
yum install maven
Setup CentOS for building RPMs
-
Create a build user
useradd builduser
-
Install RPM tools
yum install rpm-build rpmdevtools
-
Setup build directory structure
su - builduser rpmdev-setuptree
Build java-rpm-example
git clone https://github.com/Chomeh/java-rpm-example.git
cd java-rpm-example
mvn install
cd target
cp myservice-0.1-rpm.tar.gz ~/rpmbuild/SOURCES
rpmbuild -ba java-rpm-example.spec
Deplopy java-rpm-example
#as root
yum install ~builduser/rpmbuild/RPMS/noarch/myservice-0.1-1.el7.centos.noarch.rpm
service myservice start
tail -f /var/log/myservice/myservice.log