apply plugin: 'java'
repositories{
  mavenCentral()
}

sourceCompatibility = 1.8
jar {
    manifest {
        attributes("Implementation-Title": "w2phtml",
                   "Implementation-Version": "0.4.8",
		   "Main-Class" : "writer2latex.Application",
		   "Class-Path" : "jasp.jar parser.jar")
    }
}
configurations{
    bundledLibs
}
dependencies{
    bundledLibs 'org.libreoffice:jurt:5.3.2'
    bundledLibs 'org.libreoffice:juh:5.3.2'
    bundledLibs 'org.libreoffice:ridl:5.3.2'
    bundledLibs 'org.libreoffice:unoil:5.3.2'
    compile 'junit:junit:4.12'
    bundledLibs group: 'org.apache.jena', name: 'jena-core', version: '3.14.0'
    bundledLibs files('idl')
    configurations.compile.extendsFrom(configurations.bundledLibs)
}
jar {
    from {
            configurations.bundledLibs.collect { it.isDirectory() ? it : zipTree(it) }
    }
    from('src/main/java') {
        include '**/*.properties'
        include '**/*.xml'
        exclude '**/*Test.class'
        exclude '**/AllTests.class'
        exclude 'org/openoffice/**/*'
    }
}
task xhtml(type: Jar) {
    manifest {
        attributes("Implementation-Title": "w2phtml",
                   "Implementation-Version": "0.4.8",
		   "Built-By": "litvinovg",
                   "RegistrationClassName" : "org.openoffice.da.comp.writer2xhtml.W2XRegistration",
                   "Class-Path" : "jasp.jar parser.jar")
    }
    baseName = "writer2xhtml-filter"
    from { 
	configurations.bundledLibs.collect { 
	    it.isDirectory() ? it : zipTree(it) 
	} 
    }
    from sourceSets.main.output 
        exclude '**/*Test.class'
        exclude '**/AllTests.class'
        include 'org/openoffice/da/comp/wl2common/**/*.class'
        include 'org/openoffice/da/comp/writer2xhtml/**/*.class'
        include 'org/openoffice/da/comp/wl2common/**/*.properties'
	include 'writer2latex/api/**/*.class'
	include 'writer2latex/base/**/*.class'
	include 'writer2latex/epub/**/*.class'
	include 'writer2latex/office/**/*.class'
	include 'writer2latex/util/**/*.class'
	include 'writer2latex/xhtml/**/*.class'
	include 'writer2latex/xhtml/**/*.xml'
	include 'writer2latex/xmerge/**/*.class'
    from 'src/main/java'
	include 'writer2latex/xhtml/**/*.properties'
	include 'writer2latex/xhtml/**/**/*.properties'
    from sourceSets.main.output
    include 'org/**/*'
    
    
   
}
task oxt(type: Zip){
    dependsOn xhtml
    archiveName 'w2phtml.oxt'
    from 'src/main/oxt/writer2xhtml' 
    include '*' 
    include '**' 
    from 'build/libs/writer2xhtml-filter.jar'
    include '*' 
    from 'src/main/idl/writer2xhtml'
    include 'writer2xhtml.rdb' 
}