/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

apply plugin: 'java'

repositories {
  mavenCentral()
}

dependencies {
  compile "org.eclipse.tycho:org.eclipse.jdt.compiler.apt:1.1.0.v20140509-1235"
  compile "org.eclipse.jdt:core:3.3.0-v_771"
  compile files(getToolsJar())
}

def getToolsJar()
{
  def jar = files("${System.properties['java.home']}/../lib/tools.jar",
        "${System.properties['java.home']}/lib/tools.jar",
        "${System.properties['java.home']}/../Classes/classes.jar").find { it.exists() }

  if (jar != null)
  {
    return jar
  }

  throw new GradleException("jdk tools jar not found")
}

cleanEclipse {
  doLast {
    delete ".apt_generated"
    delete ".settings"
    delete ".factorypath"
    delete "bin"
  }
}

// no need for source or javadoc jars to be published for build-plugin
nexus {
  attachSources = false
  attachJavadoc = false
}

// don't publish the build plugin when releasing (however we do need it when buildling locally for testing)
if (ext.release.toBoolean()) {
  configurations.archives.artifacts.removeAll { return it.name == "build-plugin"; }
}
