On Oct 15, 2008, at 1:05 PM, mvlcek wrote:

One of our projects is a web service (with CXF as library), where the web service is defined in an annotated Java class, e.g.:

@WebService @SOAPBinding (style=Style.DOCUMENT,use=Use.LITERAL,parameterStyle=ParameterStyle.WR APPED) public interface MyWebService { public MyClass2 myMethod ( @WebParam(name="myParam") MyClass1 myParam) throws MyException; } Additionally to the web service implementation we need to build (compile, jar) the client, which consists of the MyWebService class along with all referenced classes, e.g. MyClass1, MyClass2, MyException. Using ANT we compile the class MyWebService to a separate directory (which also compiles all referenced classes) using the libraries defined for the configuration "client" in ivy.xml, then package them.

How would I do this in gradle, i.e.:

define an additional configuration "client" with dependencies

dependencies {
        addConfiguration("client")
        client "some:dep:1.0"
        linkConfWithTask('client', 'webserviceCompile')
}

have a second compile task using these dependencies and compiling only MyWebService and referenced classes

I assume here that the sources for this classes are in the default source folder:

createTask('webserviceCompile', type: Compile, dependsOn: resources).configure {
        destinationDir = new File(buildDir, 'webservice-classes')
include 'com/mycompany/webservice/**', '...' // Ant patterns to defined which classes should be compiled
        exclude ... // Possibly needed
conventionMapping(DefaultConventionsToPropertiesMapping.COMPILE) // use default conventions for source folder, target compatibility, ...
}

package the resulting classes into a jar (besides packaging the web service implementation into a war)

Assumed your project name is foo, this will create a jar

jar(appendix: 'webservice') {
        fileSet(dir: new File(buildDir, 'webservice-classes'))
        configurations = ['client']     
}

publish the web service implementation and the client jar to the enterprise repository, where the published ivy.xml contains the correct dependencies including the "client" configuration

You only have to define the enterprise repository (via an Ivy resolver):

uploadLibs {
        dependsOn 'webserviceCompile'
        uploadResolvers.add(new SshResolver()) {
                user = 'someuser'
                ...
        }       
}

I had not time to test the snippets above explicitly.

- Hans

--
Hans Dockter
Gradle Project lead
http://www.gradle.org





---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email


Reply via email to