Skip to main content

Posts

Showing posts from January, 2017

Gradle : How To Exclude Files and Packages from a Jar file

How To Exclude File from a Jar file. Gradle task Jar has a property excludes which takes an array as an input and exclude these files from the Jar file it creates. Let's assume the following directory structure Following example excludes files from the Jar file. task createExcludingFiles(type :Jar){ from ('src'){ excludes = ["main/java/com/ekiras/demo/D.java","main/java/com/ekiras/demo/E.java"] } } This will exclude files D.java , E.java from the jar file. Run the gradle task using command gradle -q createExcludingFiles . The Jar file created will have the following files. META-INF/ META-INF/MANIFEST.MF main/ main/java/ main/java/com/ main/java/com/ekiras/ main/java/com/ekiras/demo/ main/java/com/ekiras/demo/A.java main/java/com/ekiras/demo/C.java main/java/com/ekiras/demo/F.java main/java/com/ekiras/demo/B.java main/java/com/ekiras/demo/p1/ main/java/com/ekiras/demo/p1/X.java main/java/com/ekiras/demo/p1/Z.java main/java/com/ekiras/de

Gradle : How to create a Jar file

How to name a Jar file Lets take the following jar file for explaning the jar naming conventions. customName_wrapper_2.0.1_SNAPSHOT.jar A jar file has the following properties Property Description baseName customName appendix wrapper version 2.0.1 classifier SNAPSHOT archiveName - Here property archiveName if specified will override all the other naming conventions like baseName etc. It should be a fully qualified name of the Jar including the extension (.jar) Other Properties of Gradle Task :: Jar Property Description destinationDir Destination where jar is to be created manifest Include Manifest file from Directory from where files are to be read Creating a Jar file Let's assume the following directory structure Create a Jar file with all files. We can write a gradle task to include all files in src to our jar file as follows task createAll(type : Jar){ from 'src' } When we run the gradle task as gradle -q createAll will give the following files in the jar META-I

Tomcat : How to start Tomcat on more than one Port.

How to start Tomcat on more than one Port. Tomcat settings can be found in TomcatFolder/conf/server.xml file. Root element of the configuration is Server tag. You can add multiple Service under Server tag for running tomcat on more than one port. Default Service Configuration should look as follows < Service name = "Catalina" > < Connector port = "8080" protocol = "HTTP/1.1" connectionTimeout = "20000" redirectPort = "8443" /> < Connector port = "8009" protocol = "AJP/1.3" redirectPort = "8443" /> < Engine name = "Catalina" defaultHost = "localhost" > < Realm className = "org.apache.catalina.realm.LockOutRealm" > < Realm className = "org.apache.catalina.realm.UserDatabaseRealm" resourceName = "UserDatabase" /> </ Realm >

Tomcat : How to change default port 8080 of Tomcat

How to change default port 8080 of Tomcat Look for the file server.xml in folder path-to-Tomcat/conf/ This file containes the configuration for tomcat. Look for the following lines in this file. < Connector port = "8080" protocol = "HTTP/1.1" connectionTimeout = "20000" redirectPort = "8443" /> Connector port="8080" defines the port on which the tomcat will run. If you want to run tomcat on any port other than 8080 then you can just change the port number here. e.g Running Tomcat on port 8090 < Connector port = "8090" protocol = "HTTP/1.1" connectionTimeout = "20000" redirectPort = "8443" /> e.g Running Tomcat on port 9000 < Connector port = "9000" protocol = "HTTP/1.1" connectionTimeout = "20000" redirectPort = "8443" /> Also Read How to c