apply plugin: 'java'
apply plugin: 'eclipse'

jar {
	manifest {
		attributes 'Implementation-Title': 'PDF-AS-4 Library', 'JARMANIFEST': 'PDF-AS-LIB'
	}
}

buildscript {
	repositories {
		mavenLocal()
		mavenCentral()
	}
	dependencies { classpath("commons-io:commons-io:2.4") }
}

configurations { 
	generateJavaFromWsdlDeps 
	
	pdfDoclet { extendsFrom compile }
}

task createConf(type: Zip, dependsOn: JavaPlugin.PROCESS_RESOURCES_TASK_NAME) {
	from 'src/configuration'
	archiveName 'config.zip'
	destinationDir new File(projectDir, 'src/main/resources/config')
}

compileJava.dependsOn(createConf)


repositories {
	mavenLocal()
	mavenCentral()
	maven { url "http://nexus.iaik.tugraz.at/nexus/content/groups/internal" }
}

dependencies {
	compile project (':pdf-as-common')
	compile group: 'org.apache.httpcomponents', name: 'httpmime', version: '4.3.1'
	compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.3.1'
	compile group: 'org.apache.pdfbox', name: 'pdfbox', version: '1.8.2'
	compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.1'
	compile group: 'org.apache.commons', name: 'commons-io', version: '1.3.2'
	compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
	compile group: 'org.apache.axis2', name: 'axis2', version: '1.6.2'
	compile group: 'org.apache.axis2', name: 'axis2-jaxws', version: '1.6.2'
	compile group: 'org.apache.axis2', name: 'axis2-transport-local', version: '1.6.2'
	compile group: 'ognl', name: 'ognl', version: '3.0.6'
	compile files('libs/iaik_eccelerate_cms.jar')
	compile files('libs/iaik_eccelerate.jar')
	compile files('libs/iaik_jce.jar')
	compile files('libs/iaik_jce_full.jar')
	compile files('libs/iaik_cms.jar')
	compile group: 'log4j', name: 'log4j', version: '1.2.17'
	compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.5'
	compile group: 'com.google.zxing', name: 'core', version: '2.2'
	compile group: 'com.google.zxing', name: 'javase', version: '2.2'
	pdfDoclet files('libs/pdfdoclet-1.0.3-all.jar')
	testCompile group: 'junit', name: 'junit', version: '4.+'
}

/*javadoc {
	revision = getCheckedOutGitCommitHash()
	project.configure(options) {
		memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED
		charSet = "ISO-8859-1"
		docTitle = "PDF-AS 4.0 Library"
		exclude = '/**'
		include = 'at/gv/egiz/pdfas/lib/api/**'
		windowTitle = "PDF-AS 4.0 Library"
		header = "<b>PDF-AS 4.0 Library $version [$revision]</b>"
		use = "true"
		links("http://java.sun.com/j2ee/1.4/docs/api", "http://java.sun.com/j2se/1.5.0/docs/api")
	}
}*/

task apidocs(type: Javadoc) {
	classpath = configurations.compile
	source = sourceSets.main.allJava
	project.configure(options) {
		destinationDir = new File(projectDir, '../docs/api')
		memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED
		charSet = "ISO-8859-1"
		docTitle = "PDF-AS " + pdfasversion + " Documentation"
		version = pdfasversion
		include = include('at/gv/egiz/pdfas/lib/api/**')
		windowTitle = "PDF-AS " + pdfasversion + " Library"
		header = "<b>PDF-AS " + pdfasversion + " Library  " + pdfasversion + " [" + revision + "]</b>"
		use = "true"
		links("http://java.sun.com/j2ee/1.4/docs/api", "http://java.sun.com/j2se/1.5.0/docs/api")
	}
}

task fulldocs(type: Javadoc) {
	classpath = configurations.compile
	source = sourceSets.main.allJava
	project.configure(options) {
		destinationDir = new File(projectDir, '../docs/full')
		memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED
		charSet = "ISO-8859-1"
		docTitle = "PDF-AS " + pdfasversion + " Documentation"
		version = pdfasversion
		include = include('at/gv/egiz/**')
		windowTitle = "PDF-AS " + pdfasversion + " Library"
		header = "<b>PDF-AS " + pdfasversion + " Library  " + pdfasversion + " [" + revision + "]</b>"
		use = "true"
		links("http://java.sun.com/j2ee/1.4/docs/api", "http://java.sun.com/j2se/1.5.0/docs/api")
	}
}

/*task apidocspdf(type: Javadoc) {
	classpath = configurations.compile
	source = sourceSets.main.allJava
	options.docletpath = configurations.pdfDoclet.files.asType(List)
	options.doclet = "com.tarsec.javadoc.pdfdoclet.PDFDoclet"
	options.addStringOption("pdf", "../docs/api.pdf")
}*/

task apidocspdf << {
	def proc = "./doc.sh".execute()
	proc.in.eachLine {line -> println line}
	proc.err.eachLine {line -> println 'ERROR: ' + line}
	proc.waitFor()
}

test {
	systemProperties 'property': 'value'
}

uploadArchives {
	repositories {
		flatDir {
			dirs 'repos'
		}
	}
}