Saturday, 23 December 2017

Using Ant build.xml for dependency management

Steps:
  1. Right click on the project in project explorer in Eclipse --> new 'Ant Files'. This will generate a template file (.xml and a .properties file). 
  2. Create a Ivy.xml file by right clicking on the project --> new 'Ivy File'.
  3. Now you have 3 files in your project structure. the contents of these files are as follows:
axix_bujava.xml

<?xml version="1.0"?>

<project xmlns:ivy="antlib:org.apache.ivy.ant" default="retrieve-dependencies" basedir=".">

 <echo message="pulling in property files"/>
 <property file="axis_bujava.properties"/>
 
 <echo message="calling the web services generation ant task: axis_bujava"/>
 
 <target name="retrieve-dependencies" description="Retrieve dependencies with Apache IVY">
     <ivy:retrieve type="jar" />
 </target>
 
</project>

ivy.xml
<?xml version="1.0" encoding="ISO-8859-1"?>

<ivy-module version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd">
    <info
        organisation="com.test"
        module="Test"
        status="integration">
 </info>
 <dependencies>
    <dependency org="commons-validator" name="commons-validator" rev="1.3.1"/>
    
    <!-- https://mvnrepository.com/artifact/commons-logging/commons-logging -->
  <dependency org="commons-logging" name="commons-logging" rev="1.2"/>
    
    <!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
  <dependency org="org.springframework" name="spring-context" rev="5.0.2.RELEASE"/>
    
 </dependencies>
</ivy-module>


axis_bujava.properties
###############################################################################
# Copyright (c) 2008, 2014 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
# Contributors:
#     IBM Corporation - initial API and implementation
###############################################################################
!-- ScenarioType REQUIRED. Differentiates from "client" scenario.
ScenarioType=service

!-- InitialSelection REQUIRED.  Workspace relative URI to the input WSDL or Java
InitialSelection=/dynamicWebProjectName/src/packagename/myService.java

!--Utility property values - use these to list valid values for the following properties:
!-- Service.RuntimeId, Service.ServerId 
ListRuntimes=true
ListServers=true
!-- Verbose will list informational messages as well as errors if set to true
Verbose=true

!--  Service.RuntimeId - ID of web service runtime 
Service.RuntimeId=org.eclipse.jst.ws.axis.creation.axisWebServiceRT
!-- Service.ServerId -  ID of target server 
Service.ServerId=org.eclipse.jst.server.tomcat.80
!-- Service.TypeId - Java Bean is default for both Top Down and Bottom Up
!-- Service.TypeId=Java Bean

!-- ServiceProjectName - !--type:String - name of Service project - this property can be used to give the service project a different name than the project containing the initial selection.  type: String    
!--ServiceProjectName=serviceProjectName
!-- ServiceEarProjectName - !--type:String - name of Service EAR project - this property can be used to give the service EAR project a different name than the EAR project already associated with the service project.  type: String
!--ServiceEarProjectName=serviceEarProjectName

!-- Mappings
!-- Top down or bottom up scenario. Workspace relative URI to property file containing mappings.
!-- Top Down: Mappings are used to override the default package names of the generated Java template classes.
!-- The content of the properties file must be of the format namespace=package  
!-- Bottom Up: Mappings are used to override the default namespace names in the generated WSDL.
!-- The content of the properties file must be of the format package = namespace 
!--Mappings=/testProj/mappings/mappings.txt

!-- JavaOutput
!-- Top down - String: the workspace relative URI for a Java source folder for the generated Java code - must be existing workspace source folder
!--JavaOutput=/projectName/JavaSource

!-- Methods
!-- Bottom up - space delimited string of method signatures (i.e. method1(parmType1) method2(parmType2)) to be exposed in output WSDL.  If no list is provided, all methods are exposed.
!-- Methods=

!-- Style
!-- Bottom up - String: one of: RPC, DOCUMENT, WRAPPED
!--Style=DOCUMENT

!-- Use
!-- Bottom up - String: one of: LITERAL, ENCODED 
!--Use=LITERAL

!--OverwriteFilesEnabled - set to true to overwrite files that already exist. type:boolean 
!-- note for non-interactive mode it is recommended that this be set to true
!--OverwriteFilesEnabled=true

!--CreateFoldersEnabled - set to true create folders necessary during file generation type:boolean
!-- note for non-interactive mode it is recommended that this be set to true
!--CreateFoldersEnabled=true

!--CheckoutFilesEnabled - set to true to check out files with no warning to the user type:boolean
!-- note for non-interactive mode it is recommended that this be set to true
!--CheckoutFilesEnabled=true


Now right-click on axix_bujava.xml --> Run As --> Ant Build

No comments:

Post a Comment