/* * Copyright (c) 2017 NetApp * All rights reserved */ buildscript { repositories { maven { url "http://oci-repo.nane.netapp.com:8081/nexus/content/repositories/maven-gradle" } } dependencies { classpath "io.spring.gradle:dependency-management-plugin:1.0.1.RELEASE" } } apply from: '../../Build/init.gradle' class ImlParser extends DefaultTask { File imlFile File jarDir File srcDir @TaskAction void parse() { if (!imlFile.exists()) { println "Please run idea target before build" throw new RuntimeException("Please run idea target before build") } jarDir.mkdirs() srcDir.mkdirs() def root = new XmlParser().parse(imlFile.getPath()) def jars = root.component.orderEntry.library.CLASSES.root as Set jars += root.component.orderEntry.library.SOURCES.root as Set jars.each { URL url = new URL(it.@url.replaceFirst("jar:", "jar:file:")) JarURLConnection connection = (JarURLConnection) url.openConnection(); File jar = new File(connection.getJarFileURL().getFile()) // use ants version of copy because gradles copy doesn't like pulling things from outside the project if (jar.getPath().endsWith("-sources.jar")) { ant.copy(file: jar.getPath(), todir: srcDir.getPath()) } else { ant.copy(file: jar.getPath(), todir: jarDir.getPath()) } } } } subprojects { apply plugin: 'java' apply plugin: 'idea' apply plugin: 'io.spring.dependency-management' repositories { mavenLocal() maven { url "http://oci-repo.nane.netapp.com:8081/nexus/content/groups/public/" } } task parse(type: ImlParser, dependsOn: 'idea') { ext.projectFile = file("${project.name}.iml") inputs.files(projectFile) imlFile projectFile jarDir file("$buildDir/jar") srcDir file("$buildDir/src") } }