text:
#include "config.h"

#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

#include <utlist.h>

#include "deviceapi.h"
#include "logging.h"
#include "lowlevel.h"
#include "lowl-vcom.h"
#include "util.h"

BFG_REGISTER_DRIVER(hashfast_ums_drv)

#define HASHFAST_QUEUE_MEMORY 0x20

#define HASHFAST_ALL_CHIPS 0xff
#define HASHFAST_ALL_CORES 0xff

#define HASHFAST_HEADER_SIZE 8
#define HASHFAST_MAX_DATA 0x3fc
#define HASHFAST_HASH_SIZE (0x20 + 0xc + 4 + 4 + 2 + 1 + 1)
#define HASHFAST_MAX_VOLTAGES 4
#define HASHFAST_CONFIG_DATA_SIZE  0x10

enum hashfast_opcode {
	HFOP_NULL          =    0,
	HFOP_ROOT          =    1,
	HFOP_RESET         =    2,
	HFOP_PLL_CONFIG    =    3,
	HFOP_ADDRESS       =    4,
	HFOP_READDRESS     =    5,
	HFOP_HIGHEST       =    6,
	HFOP_BAUD          =    7,
	HFOP_UNROOT        =    8,
	HFOP_HASH          =    9,
	HFOP_NONCE         = 0x0a,
	HFOP_ABORT         = 0x0b,
	HFOP_STATUS        = 0x0c,
	HFOP_GPIO          = 0x0d,
	HFOP_CONFIG        = 0x0e,
	HFOP_STATISTICS    = 0x0f,
	HFOP_GROUP         = 0x10,
	HFOP_CLOCKGATE     = 0x11,

	HFOP_USB_INIT      = 0x80,
	HFOP_GET_TRACE     = 0x81,
	HFOP_LOOPBACK_USB  = 0x82,
	HFOP_LOOPBACK_UART = 0x83,
	HFOP_DFU           = 0x84,
	HFOP_USB_SHUTDOWN  = 0x85,
	HFOP_DIE_STATUS    = 0x86,
	HFOP_GWQ_STATUS    = 0x87,
	HFOP_UMS_CLOCK_CHANGE = 0x88,
	HFOP_WORK_RESTART  = 0x88,
	HFOP_USB_STATS1    = 0x89,
	HFOP_USB_GWQSTATS  = 0x8a,
	HFOP_USB_NOTICE    = 0x8b,
	HFOP_USB_DEBUG     = 0xff,
};

enum hashfast_config_hdata {
	HFCH_WRITE         = 1 << 0xf,
	HFCH_THERMAL_LIMIT = 1 << 0xe,
	HFCH_TACHO         = 1 << 0xd,
};

enum hashfast_config_flags {
	HFCF_STATUS_PERIOD = 1 << 0xb,
	HFCF_STATUS_IDLE   = 1 << 0xc,
	HFCF_STATUS_EMPTY  = 1 << 0xd,
	HFCF_PWM_ACTIVE_LV = 1 << 0xe,
};

enum hashfast_clock_change_cmd {
	HFWR_SET_CLOCK     = 1 << 0xc,
};

typedef unsigned long hashfast_isn_t;

static inline
float hashfast_temperature_conv(const uint8_t * const data)
{
	// Temperature is 12-bit fraction ranging between -61.5 C and ~178.5 C
	int32_t tempdata = ((uint32_t)data[1] << 8) | data[0];
	tempdata &= 0xfff;
	tempdata *= 240;
	tempdata -= 251904;  // 61.5 * 4096
	float temp = tempdata;
	temp /= 4096.;
	return temp;
}

static inline
float hashfast_voltage_conv(const uint8_t vdata)
{
	// Voltage is 8-bit fraction ranging between 0 V and ~1.2 V
	return (float)vdata / 256. * 1.2;
}

struct hashfast_parsed_msg {
	uint8_t opcode;
	uint8_t chipaddr;
	uint8_t coreaddr;
	uint16_t hdata;
	uint8_t data[HASHFAST_MAX_DATA];
	size_t datalen;
};

static
ssize_t hashfast_write(const int fd, void * const buf, size_t bufsz)
{
	const ssize_t rv = write(fd, buf, bufsz);
	if ((opt_debug && opt_dev_protocol) || unlikely(rv != bufsz))
	{
		const int e = errno;
		char hex[(bufsz * 2) + 1];
		bin2hex(hex, buf, bufsz);
		if (rv < 0)
			applog(LOG_WARNING, "%s fd=%d: SEND (%s) => %d errno=%d(%s)",
			       "hashfast", fd, hex, (int)rv, e, bfg_strerror(e, BST_ERRNO));
		else
		if (rv < bufsz)
			applog(LOG_WARNING, "%s fd=%d: SEND %.*s(%s)",
			       "hashfast", fd, (int)(rv * 2), hex, &hex[rv * 2]);
		else
		if (rv > bufsz)
			applog(LOG_WARNING, "%s fd=%d: SEND %s => +%d",
			       "hashfast", fd, hex, (int)(rv - bufsz));
		else
			applog(LOG_DEBUG, "%s fd=%d: SEND %s",
			       "hashfast", fd, hex);
	}
	return rv;
}

static
ssize_t hashfast_read(const int fd, void * const buf, size_t bufsz)
{
	const ssize_t rv = serial_read(fd, buf, bufsz);
	if (opt_debug && opt_dev_protocol && rv)
	{
		char hex[(rv * 2) + 1];
		bin2hex(hex, buf, rv);
		applog(LOG_DEBUG, "%s fd=%d: RECV %s",
		       "hashfast", fd, hex);
	}
	return rv;
}

static
bool hashfast_prepare_msg(uint8_t * const buf, const uint8_t opcode, const uint8_t chipaddr, const uint8_t coreaddr, const uint16_t hdata, const size_t datalen)
{
	buf[0] = '\xaa';
	buf[1] = opcode;
	buf[2] = chipaddr;
	buf[3] = coreaddr;
	buf[4] = hdata & 0xff;
	buf[5] = hdata >> 8;
	if (datalen > 1020 || datalen % 4)
		return false;
	buf[6] = datalen / 4;
	buf[7] = crc8ccitt(&buf[1], 6);
	return true;
}

static
bool hashfast_send_msg(const int fd, uint8_t * const buf, const uint8_t opcode, const uint8_t chipaddr, const uint8_t coreaddr, const uint16_t hdata, const size_t datalen)
{
	if (!hashfast_prepare_msg(buf, opcode, chipaddr, coreaddr, hdata, datalen))
		return false;
	const size_t buflen = HASHFAST_HEADER_SIZE + datalen;
	return (buflen == hashfast_write(fd, buf, buflen));
}

static
bool hashfast_parse_msg(const int fd, struct hashfast_parsed_msg * const out_msg)
{
	uint8_t buf[HASHFAST_HEADER_SIZE];
startover:
	if (HASHFAST_HEADER_SIZE != hashfast_read(fd, buf, HASHFAST_HEADER_SIZE))
		return false;
	uint8_t *p = memchr(buf, '\xaa', HASHFAST_HEADER_SIZE);
	if (p != buf)
	{
ignoresome:
		if (!p)
			goto startover;
		int moreneeded = p - buf;
		int alreadyhave = HASHFAST_HEADER_SIZE - moreneeded;
		memmove(buf, p, alreadyhave);
		if (moreneeded != hashfast_read(fd, &buf[alreadyhave], moreneeded))
			return false;
	}
	const uint8_t correct_crc8 = crc8ccitt(&buf[1], 6);
	if (buf[7] != correct_crc8)
	{
		p = memchr(&buf[1], '\xaa', HASHFAST_HEADER_SIZE - 1);
		goto ignoresome;
	}
	out_msg->opcode   = buf[1];
	out_msg->chipaddr = buf[2];
	out_msg->coreaddr = buf[3];
	out_msg->hdata    = (uint16_t)buf[4] | ((uint16_t)buf[5] << 8);
	out_msg->datalen  = buf[6] * 4;
	return (out_msg->datalen == hashfast_read(fd, &out_msg->data[0], out_msg->datalen));
}

static
bool hashfast_lowl_match(const struct lowlevel_device_info * const info)
{
	if (lowlevel_match_product(info, "GoldenNonce"))
		return true;
	return (info->manufacturer && strstr(info->manufacturer, "HashFast"));
}

static
const char *hashfast_set_clock(struct cgpu_info * const proc, const char * const optname, const char * const newvalue, char * const replybuf, enum bfg_set_device_replytype * const out_success)

{
	uint16_t * const clockp = proc->device_data;
	*clockp = atoi(newvalue);
	return NULL;
}

static const struct bfg_set_device_definition hashfast_set_device_funcs_probe[] = {
	{"clock", hashfast_set_clock, "clock frequency"},
	{NULL},
};

static const struct bfg_set_device_definition hashfast_set_device_funcs[];

static
bool hashfast_detect_one(const char * const devpath)
{
	uint16_t clock = 550;
	uint8_t buf[HASHFAST_HEADER_SIZE];
	const int fd = serial_open(devpath, 0, 100, true);
	if (fd == -1)
	{
		applog(LOG_DEBUG, "%s: Failed to open %s", __func__, devpath);
		return false;
	}
	struct hashfast_parsed_msg * const pmsg = malloc(sizeof(*pmsg));
	drv_set_defaults(&hashfast_ums_drv, hashfast_set_device_funcs_probe, &clock, devpath, detectone_meta_info.serial, 1);
	hashfast_send_msg(fd, buf, HFOP_USB_INIT, 0, 0, clock, 0);
	do {
		if (!hashfast_parse_msg(fd, pmsg))
		{
			applog(LOG_DEBUG, "%s: Failed to parse response on %s",
			        __func__, devpath);
			serial_close(fd);
			goto err;
		}
	} while (pmsg->opcode != HFOP_USB_INIT);
	serial_close(fd);
	const int expectlen = 0x20 + (pmsg->chipaddr * pmsg->coreaddr) / 8;
	if (pmsg->datalen < expectlen)
	{
		applog(LOG_DEBUG, "%s: USB_INIT response too short on %s (%d < %d)",
		       __func__, devpath, (int)pmsg->datalen, expectlen);
		goto err;
	}
	if (pmsg->data[8] != 0)
	{
		applog(LOG_DEBUG, "%s: USB_INIT failed on %s (err=%d)",
		        __func__, devpath, pmsg->data[8]);
		goto err;
	}
	uint16_t fwrev = upk_u16le(pmsg->data, 0);
	if (!fwrev)
	{
		// fwrev == 0 means latest experimental; make it >= every possible comparison
		fwrev = 0xffff;
		pk_u16le(pmsg->data, 0, fwrev);
	}

	if (serial_claim_v(devpath, &hashfast_ums_drv))
		return false;

	// Hijack hdata for a quick way to transfer clock to init
	pmsg->hdata = clock;

	struct cgpu_info * const cgpu = malloc(sizeof(*cgpu));
	*cgpu = (struct cgpu_info){
		.drv = &hashfast_ums_drv,
		.device_path = strdup(devpath),
		.deven = DEV_ENABLED,
		.procs = (pmsg->chipaddr * pmsg->coreaddr),
		.threads = 1,
		.device_data = pmsg,
		.cutofftemp = 100,
	};

	if (fwrev >= 0x0005)
		cgpu->set_device_funcs = hashfast_set_device_funcs;

	return add_cgpu(cgpu);

err:
	free(pmsg);
	return false;
}

static
bool hashfast_lowl_probe(const struct lowlevel_device_info * const info)
{
	return vcom_lowl_probe_wrapper(info, hashfast_detect_one);
}

struct hashfast_dev_state {
	uint8_t cores_per_chip;
	int fd;
	struct hashfast_chip_state *chipstates;
	uint16_t fwrev;
};

struct hashfast_chip_state {
	struct cgpu_info **coreprocs;
	hashfast_isn_t last_isn;
	float voltages[HASHFAST_MAX_VOLTAGES];
	uint16_t clock;
	uint16_t clock_desired;
	uint8_t cfgdata[HASHFAST_CONFIG_DATA_SIZE];
};

struct hashfast_core_state {
	uint8_t chipaddr;
	uint8_t coreaddr;
	int next_device_id;
	uint8_t last_seq;
	hashfast_isn_t last_isn;
	hashfast_isn_t last2_isn;
	bool has_pending;
	unsigned queued;
};

static
const char *hashfast_set_clock_runtime(struct cgpu_info * const proc, const char * const optname, const char * const newvalue, char * const replybuf, enum bfg_set_device_replytype * const out_success)
{
	struct thr_info * const thr = proc->thr[0];
	struct hashfast_dev_state * const devstate = proc->device_data;
	struct hashfast_core_state * const cs = thr->cgpu_data;
	struct hashfast_chip_state * const chipstate = &devstate->chipstates[cs->chipaddr];

	const int nv = atoi(newvalue);
	if (nv >= 0xfff)
		return "Clock frequency too high";

	chipstate->clock_desired = nv;

	return NULL;
}

static const struct bfg_set_device_definition hashfast_set_device_funcs[] = {
	{"clock", hashfast_set_clock_runtime, "clock frequency"},
	{NULL},
};

static
void hashfast_init_cfgdata(struct hashfast_chip_state * const chipstate)
{
	uint8_t * const cfgdata = chipstate->cfgdata;

	const uint16_t status_ms = 500;
	const bool send_status_on_core_idle = false;
	const bool send_status_on_pending_empty = false;
	const bool pwm_active_level = false;
	const uint8_t status_batching_delay_ms = 0;
	const uint8_t watchdog_sec = 0;
	const uint8_t rx_header_timeout = 20, rx_data_timeout = 20;
	const uint8_t stats_sec = 10;
	const uint8_t temp_measure_ms = 100;
	const uint16_t lf_clocks_per_usec = 125 /* FIXME: or 126? */;
	const uint8_t max_nonces_per_frame = 1;
	const uint8_t voltage_sample_points = 0x1f;
	const uint8_t pwm_phases = 1, pwm_period = 0, pwm_pulse_period = 0;
	const uint8_t temp_trim = 0;

	pk_u16le(cfgdata, 0,
	         (status_ms & 0x7ff) | (status_ms ? HFCF_STATUS_PERIOD : 0) |
	         (send_status_on_core_idle     ? HFCF_STATUS_IDLE   : 0) |
	         (send_status_on_pending_empty ? HFCF_STATUS_EMPTY  : 0) |
	         (pwm_active_level             ? HFCF_PWM_ACTIVE_LV : 0));
	pk_u8(cfgdata, 2, status_batching_delay_ms);
	pk_u8(cfgdata, 3, watchdog_sec & 0x7f);

	pk_u8(cfgdata, 4, rx_header_timeout & 0x7f);
	pk_u8(cfgdata, 5, rx_data_timeout   & 0x7f);
	pk_u8(cfgdata, 6, stats_sec         & 0x7f);
	pk_u8(cfgdata, 7, temp_measure_ms);

	pk_u16le(cfgdata, 8,
	         ((lf_clocks_per_usec - 1) & 0xfff) |
	         ((max_nonces_per_frame & 0xf) << 0xc));
	pk_u8(cfgdata, 0xa, voltage_sample_points);
	pk_u8(cfgdata, 0xb,
	      ((pwm_phases - 1) & 3) |
	      ((temp_trim & 0xf) << 2));

	pk_u16le(cfgdata, 0xc, pwm_period);
	pk_u16le(cfgdata, 0xe, pwm_pulse_period);
}

static
uint16_t hashfast_chip_thermal_cutoff_hdata(const float temp)
{
	const uint16_t v = (temp + 61.5) * 0x1000 / 240;
	return HFCH_THERMAL_LIMIT | (v & 0x3ff);
}

static
bool hashfast_init(struct thr_info * const master_thr)
{
	struct cgpu_info * const dev = master_thr->cgpu, *proc;
	struct hashfast_parsed_msg * const pmsg = dev->device_data;
	struct hashfast_dev_state * const devstate = malloc(sizeof(*devstate));
	struct hashfast_chip_state * const chipstates = malloc(sizeof(*chipstates) * pmsg->chipaddr), *chipstate;
	struct hashfast_core_state * const corestates = malloc(sizeof(*corestates) * dev->procs), *cs;
	int i;

	*devstate = (struct hashfast_dev_state){
		.chipstates = chipstates,
		.cores_per_chip = pmsg->coreaddr,
		.fd = serial_open(dev->device_path, 0, 1, true),
		.fwrev = upk_u16le(pmsg->data, 0),
	};

	const uint16_t clock = pmsg->hdata;

	for (i = 0; i < pmsg->chipaddr; ++i)
	{
		chipstate = &chipstates[i];
		*chipstate = (struct hashfast_chip_state){
			.coreprocs = malloc(sizeof(struct cgpu_info *) * pmsg->coreaddr),
			.clock = clock,
			.clock_desired = clock,
		};
		hashfast_init_cfgdata(chipstate);
	}

	for ((i = 0), (proc = dev); proc; ++i, (proc = proc->next_proc))
	{
		struct thr_info * const thr = proc->thr[0];
		const bool core_is_working = pmsg->data[0x20 + (i / 8)] & (1 << (i % 8));

		if (!core_is_working)
			proc->deven = DEV_RECOVER_DRV;
		proc->device_data = devstate;
		thr->cgpu_data = cs = &corestates[i];
		*cs = (struct hashfast_core_state){
			.chipaddr = i / pmsg->coreaddr,
			.coreaddr = i % pmsg->coreaddr,
		};
		chipstates[cs->chipaddr].coreprocs[cs->coreaddr] = proc;
	}
	free(pmsg);

	// TODO: actual clock = [12,13]

	for_each_managed_proc(proc, dev)
	{
		proc->status = LIFE_INIT2;
	}

	timer_set_now(&master_thr->tv_poll);
	return true;
}

static
bool hashfast_queue_append(struct thr_info * const thr, struct work * const work)
{
	struct cgpu_info * const proc = thr->cgpu;
	struct hashfast_dev_state * const devstate = proc->device_data;
	const int fd = devstate->fd;
	struct hashfast_core_state * const cs = thr->cgpu_data;
	struct hashfast_chip_state * const chipstate = &devstate->chipstates[cs->chipaddr];
	const size_t cmdlen = HASHFAST_HEADER_SIZE + HASHFAST_HASH_SIZE;
	uint8_t cmd[cmdlen];
	uint8_t * const hashdata = &cmd[HASHFAST_HEADER_SIZE];
	hashfast_isn_t isn;
	uint8_t seq;

	if (cs->has_pending || chipstate->clock_desired != chipstate->clock)
	{
		thr->queue_full = true;
		return false;
	}

	isn = ++chipstate->last_isn;
	seq = ++cs->last_seq;
	work->device_id = seq;
	cs->last2_isn = cs->last_isn;
	cs->last_isn = isn;
	hashfast_prepare_msg(cmd, HFOP_HASH, cs->chipaddr, cs->coreaddr, (cs->coreaddr << 8) | seq, 56);
	memcpy(&hashdata[   0], work->midstate, 0x20);
	memcpy(&hashdata[0x20], &work->data[64], 0xc);
	memset(&hashdata[0x2c], '\0', 0xa);  // starting_nonce, nonce_loops, ntime_loops
	hashdata[0x36] = 32;  // search target (number of zero bits)
	hashdata[0x37] = 0;
	cs->has_pending = true;

	if (cmdlen != hashfast_write(fd, cmd, cmdlen))
		return false;

	DL_APPEND(thr->work, work);
	if (cs->queued > HASHFAST_QUEUE_MEMORY)
	{
		struct work * const old_work = thr->work;
		DL_DELETE(thr->work, old_work);
		free_work(old_work);
	}
	else
		++cs->queued;

	return true;
}

static
void hashfast_queue_flush(struct thr_info * const thr)
{
	struct cgpu_info * const proc = thr->cgpu;
	struct hashfast_dev_state * const devstate = proc->device_data;
	const int fd = devstate->fd;
	struct hashfast_core_state * const cs = thr->cgpu_data;
	uint8_t cmd[HASHFAST_HEADER_SIZE];
	uint16_t hdata = 2;
	if ((!thr->work) || stale_work(thr->work->prev, true))
	{
		applog(LOG_DEBUG, "%"PRIpreprv": Flushing both active and pending work",
		       proc->proc_repr);
		hdata |= 1;
	}
	else
		applog(LOG_DEBUG, "%"PRIpreprv": Flushing pending work",
		       proc->proc_repr);
	hashfast_send_msg(fd, cmd, HFOP_ABORT, cs->chipaddr, cs->coreaddr, hdata, 0);
}

static
struct cgpu_info *hashfast_find_proc(struct thr_info * const master_thr, int chipaddr, int coreaddr)
{
	struct cgpu_info *proc = master_thr->cgpu;
	struct hashfast_dev_state * const devstate = proc->device_data;
	if (coreaddr >= devstate->cores_per_chip)
		return NULL;
	const unsigned chip_count = proc->procs / devstate->cores_per_chip;
	if (chipaddr >= chip_count)
		return NULL;
	struct hashfast_chip_state * const chipstate = &devstate->chipstates[chipaddr];
	return chipstate->coreprocs[coreaddr];
}

static
hashfast_isn_t hashfast_get_isn(struct hashfast_chip_state * const chipstate, uint16_t hfseq)
{
	const uint8_t coreaddr = hfseq >> 8;
	const uint8_t seq = hfseq & 0xff;
	struct cgpu_info * const proc = chipstate->coreprocs[coreaddr];
	struct thr_info * const thr = proc->thr[0];
	struct hashfast_core_state * const cs = thr->cgpu_data;
	if (cs->last_seq == seq)
		return cs->last_isn;
	if (cs->last_seq == (uint8_t)(seq + 1))
		return cs->last2_isn;
	return 0;
}

static
void hashfast_submit_nonce(struct thr_info * const thr, struct work * const work, const uint32_t nonce, const bool searched)
{
	struct cgpu_info * const proc = thr->cgpu;
	struct hashfast_core_state * const cs = thr->cgpu_data;

	applog(LOG_DEBUG, "%"PRIpreprv": Found nonce for seq %02x (last=%02x): %08lx%s",
	       proc->proc_repr, (unsigned)work->device_id, (unsigned)cs->last_seq,
	       (unsigned long)nonce, searched ? " (searched)" : "");
	submit_nonce(thr, work, nonce);
}

static
bool hashfast_poll_msg(struct thr_info * const master_thr)
{
	struct cgpu_info * const dev = master_thr->cgpu;
	struct hashfast_dev_state * const devstate = dev->device_data;
	const int fd = devstate->fd;

	struct hashfast_parsed_msg msg;
	if (!hashfast_parse_msg(fd, &msg))
		return false;

	switch (msg.opcode)
	{
		case HFOP_NONCE:
		{
			const uint8_t *data = msg.data;
			for (int i = msg.datalen / 8; i; --i, (data = &data[8]))
			{
				const uint32_t nonce = (data[0] <<  0)
				                     | (data[1] <<  8)
				                     | (data[2] << 16)
				                     | (data[3] << 24);
				const uint8_t seq = data[4];
				const uint8_t coreaddr = data[5];
				// uint32_t ntime = data[6] | ((data[7] & 0xf) << 8);
				const bool search = data[7] & 0x10;
				struct cgpu_info * const proc = hashfast_find_proc(master_thr, msg.chipaddr, coreaddr);
				if (unlikely(!proc))
				{
					applog(LOG_ERR, "%s: Unknown chip/core address %u/%u",
					       dev->dev_repr, (unsigned)msg.chipaddr, (unsigned)coreaddr);
					inc_hw_errors_only(master_thr);
					continue;
				}
				struct thr_info * const thr = proc->thr[0];
				struct hashfast_core_state * const cs = thr->cgpu_data;
				struct work *work;

				DL_SEARCH_SCALAR(thr->work, work, device_id, seq);
				if (unlikely(!work))
				{
					applog(LOG_WARNING, "%"PRIpreprv": Unknown seq %02x (last=%02x)",
					       proc->proc_repr, (unsigned)seq, (unsigned)cs->last_seq);
					inc_hw_errors2(thr, NULL, &nonce);
					continue;
				}

				unsigned nonces_found = 1;

				hashfast_submit_nonce(thr, work, nonce, false);
				if (search)
				{
					for (int noffset = 1; noffset <= 0x80; ++noffset)
					{
						const uint32_t nonce2 = nonce + noffset;
						if (test_nonce(work, nonce2, false))
						{
							hashfast_submit_nonce(thr, work, nonce2, true);
							++nonces_found;
						}
					}
					if (!nonces_found)
					{
						inc_hw_errors_only(thr);
						applog(LOG_WARNING, "%"PRIpreprv": search=1, but failed to turn up any additional solutions",
						       proc->proc_repr);
					}
				}

				hashes_done2(thr, 0x100000000 * nonces_found, NULL);
			}
			break;
		}
		case HFOP_STATUS:
		{
			const uint8_t *data = &msg.data[8];
			struct cgpu_info *proc = hashfast_find_proc(master_thr, msg.chipaddr, 0);
			struct cgpu_info *first_proc = proc;
			if (unlikely(!proc))
			{
				applog(LOG_ERR, "%s: Unknown chip address %u",
				       dev->dev_repr, (unsigned)msg.chipaddr);
				inc_hw_errors_only(master_thr);
				break;
			}
			struct hashfast_chip_state * const chipstate = &devstate->chipstates[msg.chipaddr];
			hashfast_isn_t isn = hashfast_get_isn(chipstate, msg.hdata);
			const float temp = hashfast_temperature_conv(&msg.data[0]);
			for (int i = 0; i < HASHFAST_MAX_VOLTAGES; ++i)
				chipstate->voltages[i] = hashfast_voltage_conv(msg.data[2 + i]);
			int cores_uptodate, cores_active, cores_pending, cores_transitioned;
			cores_uptodate = cores_active = cores_pending = cores_transitioned = 0;
			for (int i = 0; i < devstate->cores_per_chip; ++i, (proc = proc->next_proc))
			{
				struct thr_info * const thr = proc->thr[0];
				struct hashfast_core_state * const cs = thr->cgpu_data;
				const uint8_t bits = data[i / 4] >> (2 * (i % 4));
				const bool has_active  = bits & 1;
				const bool has_pending = bits & 2;
				bool try_transition = true;

				proc->temp = temp;

				if (cs->last_isn <= isn)
					++cores_uptodate;
				else
					try_transition = false;

				if (has_active)
					++cores_active;

				if (has_pending)
					++cores_pending;
				else
				if (try_transition)
				{
					++cores_transitioned;
					cs->has_pending = false;
					// Avoid refilling pending slot if we are preparing to change the clock frequency
					if (chipstate->clock_desired == chipstate->clock)
						thr->queue_full = false;
				}
			}
			applog(LOG_DEBUG, "%s: STATUS from chipaddr=0x%02x with hdata=0x%04x (isn=0x%lx): total=%d uptodate=%d active=%d pending=%d transitioned=%d",
			       dev->dev_repr, (unsigned)msg.chipaddr, (unsigned)msg.hdata, isn,
			       devstate->cores_per_chip, cores_uptodate,
			       cores_active, cores_pending, cores_transitioned);
			if ((!cores_active) && chipstate->clock_desired != chipstate->clock)
			{
				// All cores finished their work, change clock frequency and then refill
				uint8_t buf[HASHFAST_HEADER_SIZE + HASHFAST_CONFIG_DATA_SIZE];
				uint16_t clock = chipstate->clock_desired, hdata;
				if (!hashfast_send_msg(fd, buf, HFOP_UMS_CLOCK_CHANGE, msg.chipaddr, 0, HFWR_SET_CLOCK | clock, 0))
				{
					applog(LOG_ERR, "%"PRIpreprv": Clock change failure (%s)", proc->proc_repr, "OP_UMS_CLOCK_CHANGE");
					goto clockchangefailed;
				}
				// Until we send HFOP_CONFIG, the state is undefined
				chipstate->clock = 0;

				hdata = HFCH_WRITE;
				hdata |= hashfast_chip_thermal_cutoff_hdata(110);
				pk_uNle(chipstate->cfgdata, 8, 0, 0xc, clock);
				memcpy(&buf[HASHFAST_HEADER_SIZE], chipstate->cfgdata, HASHFAST_CONFIG_DATA_SIZE);
				if (!hashfast_send_msg(fd, buf, HFOP_CONFIG, msg.chipaddr, 0, hdata, HASHFAST_CONFIG_DATA_SIZE))
				{
					applog(LOG_ERR, "%"PRIpreprv": Clock change failure (%s)", proc->proc_repr, "OP_CONFIG");
					goto clockchangefailed;
				}

				chipstate->clock = clock;

				// Time to refill queues
				proc = first_proc;
				for (int i = 0; i < devstate->cores_per_chip; ++i, (proc = proc->next_proc))
				{
					struct thr_info * const thr = proc->thr[0];
					thr->queue_full = false;
				}

clockchangefailed: ;
			}
			break;
		}
	}
	return true;
}

static
void hashfast_poll(struct thr_info * const master_thr)
{
	struct cgpu_info * const dev = master_thr->cgpu;
	struct timeval tv_timeout;
	timer_set_delay_from_now(&tv_timeout, 10000);
	while (true)
	{
		if (!hashfast_poll_msg(master_thr))
		{
			applog(LOG_DEBUG, "%s poll: No more messages", dev->dev_repr);
			break;
		}
		if (timer_passed(&tv_timeout, NULL))
		{
			applog(LOG_DEBUG, "%s poll: 10ms timeout met", dev->dev_repr);
			break;
		}
	}

	timer_set_delay_from_now(&master_thr->tv_poll, 100000);
}

static
struct api_data *hashfast_api_stats(struct cgpu_info * const proc)
{
	struct hashfast_dev_state * const devstate = proc->device_data;
	struct thr_info * const thr = proc->thr[0];
	struct hashfast_core_state * const cs = thr->cgpu_data;
	struct hashfast_chip_state * const chipstate = &devstate->chipstates[cs->chipaddr];
	struct api_data *root = NULL;
	char key[] = "VoltageNN";

	for (int i = 0; i < HASHFAST_MAX_VOLTAGES; ++i)
	{
		snprintf(&key[7], 3, "%d", i);
		if (chipstate->voltages[i])
			root = api_add_volts(root, key, &chipstate->voltages[i], false);
	}

	return root;
}

static
struct api_data *hashfast_api_devdetail(struct cgpu_info * const proc)
{
	struct thr_info * const thr = proc->thr[0];
	struct hashfast_core_state * const cs = thr->cgpu_data;
	struct api_data *root = NULL;

	root = api_add_uint8(root, "Chip Address", &cs->chipaddr, false);
	root = api_add_uint8(root, "Core Address", &cs->coreaddr, false);

	return root;
}

#ifdef HAVE_CURSES
static
void hashfast_wlogprint_status(struct cgpu_info * const proc)
{
	struct hashfast_dev_state * const devstate = proc->device_data;
	struct thr_info * const thr = proc->thr[0];
	struct hashfast_core_state * const cs = thr->cgpu_data;
	struct hashfast_chip_state * const chipstate = &devstate->chipstates[cs->chipaddr];

	{
		// -> "NNN.xxx / NNN.xxx / NNN.xxx"
		size_t sz = (HASHFAST_MAX_VOLTAGES * 10) + 1;
		char buf[sz];
		char *s = buf;
		int rv = 0;
		for (int i = 0; i < HASHFAST_MAX_VOLTAGES; ++i)
		{
			const float voltage = chipstate->voltages[i];
			if (!voltage)
				continue;
			_SNP("%.3f / ", voltage);
		}
		if (rv >= 3 && s[-2] == '/')
		{
			s[-3] = '\0';
			wlogprint("Voltages: %s\n", buf);
		}
	}
}

static
void hashfast_tui_wlogprint_choices(struct cgpu_info * const proc)
{
	wlogprint("[C]lock speed ");
}

static
const char *hashfast_tui_handle_choice(struct cgpu_info * const proc, const int input)
{
	switch (input)
	{
		case 'c': case 'C':
		{
			char prompt[0x80];
			snprintf(prompt, sizeof(prompt), "Set clock speed (%u-%u)", 1, 0xffe);
			return proc_set_device_tui_wrapper(proc, NULL, hashfast_set_clock_runtime, prompt, NULL);
		}
	}
	return NULL;
}
#endif

struct device_drv hashfast_ums_drv = {
	.dname = "hashfast_ums",
	.name = "HFA",

	.lowl_match = hashfast_lowl_match,
	.lowl_probe = hashfast_lowl_probe,

	.thread_init = hashfast_init,

	.minerloop = minerloop_queue,
	.queue_append = hashfast_queue_append,
	.queue_flush = hashfast_queue_flush,
	.poll = hashfast_poll,

	.get_api_stats = hashfast_api_stats,
	.get_api_extra_device_detail = hashfast_api_devdetail,

#ifdef HAVE_CURSES
	.proc_wlogprint_status = hashfast_wlogprint_status,
	.proc_tui_wlogprint_choices = hashfast_tui_wlogprint_choices,
	.proc_tui_handle_choice = hashfast_tui_handle_choice,
#endif
};


text:
package com.github.baleio.sbt.bom

import sbt._
import Keys._

object Resolvers {
  val mirror = "Baleio Mirror" at "http://nexus.bale.io/content/groups/public"
  val releases = "Baleio Releases" at "http://nexus.bale.io/content/repositories/baleio-releases"
  val snapshots = "Baleio Snapshots" at "http://nexus.bale.io/content/repositories/baleio-snapshots"
  val thirdparty = "Baleio 3rd Party" at "http://nexus.bale.io/content/repositories/baleio -thirdparty"
  val allResolvers = Seq(releases, snapshots, thirdparty, mirror)
}

object Dependencies {
  // Versions
  object Versions {
    val activemq = "5.9.0"
    val akka = "2.3.0"
    val ant = "1.9.3"
    val asm = "4.2"
    val aspectj = "1.7.4"
    val avro = "1.7.6"
    val batik = "1.6-1"
    val bouncycastle = "1.50"
    val camel = "2.13.0"
    val cglib = "3.1"
    val cucumber = "1.1.5"
    val cxf = "2.7.10"
    val freemarker = "2.3.20"
    val groovy = "2.2.2"
    val guice = "4.0-beta"
    val hibernate = "4.3.4.Final"
    val httpComponents = "4.3.3"
    val jackson = "2.3.2"
    val jackson1 = "1.9.12"
    val java = "1.8"
    val jencks = "2.2"
    val jersey1 = "1.18.1"
    val jersey = "2.6"
    val jetty = "9.1.2.v20140210"
    val jetty6 = "6.1.26"
    val json4s = "3.2.7"
    val junit = "4.11"
    val logback = "1.1.2"
    val lucene = "4.7.0"
    val metrics = "3.0.2"
    val netty = "4.0.17.Final"
    val play = "2.3-M1"
    val powermock = "1.5.4"
    val scala = "2.10.4"
    val scalastyle = "0.4.0"
    val slf4j = "1.7.7"
    val spring = "4.0.3.RELEASE"
    val springIntegration = "3.0.1.RELEASE"
    val springSecurity = "3.2.1.RELEASE"
    val springSecurityOauth = "1.0.5.RELEASE"
    val swagger = "1.3.2"
    val testng = "6.8.8"
    val tomcat = "8.0.3"
    val yammerMetrics = "2.2.0"
  }

  var depOverrides = Set[ModuleID]()

  val aopalliance = "aopalliance" % "aopalliance" % "1.0"
  depOverrides = depOverrides ++ Set(aopalliance)

  val oldAntlr = "antlr" % "antlr" % "2.7.7"
  val oldAntlrStringtemplate = "antlr" % "stringtemplate" % "3.2.1"
  depOverrides = depOverrides ++ Set(oldAntlr, oldAntlrStringtemplate)

  val oldAsm = "asm" % "asm" % "3.3.1"
  val oldAsmAttrs = "asm" % "asm-attrs" % "2.2.3"
  val oldAsmCommons = "asm" % "asm-commons" % "3.3.1"
  val oldAsmTree = "asm" % "asm-tree" % "3.3.1"
  val oldAsmUtil = "asm" % "asm-util" % "3.3.1"
  depOverrides = depOverrides ++ Set(oldAsm, oldAsmAttrs, oldAsmCommons, oldAsmTree, oldAsmUtil)

  val batik = "batik" % "batik" % "1.5"
  val batikBridge = "batik" % "batik-brdige" % Versions.batik
  val batikCss = "batik" % "batik-css" % Versions.batik
  val batikDom = "batik" % "batik-dom" % Versions.batik
  val batikExt = "batik" % "batik-ext" % Versions.batik
  val batikParser = "batik" % "batik-parser" % Versions.batik
  val batikRasterizer = "batik" % "batik-rasterizer" % Versions.batik
  val batikScript = "batik" % "batik-script" % Versions.batik
  val batikTranscoder = "batik" % "batik-transcoder" % Versions.batik
  val batikUtil = "batik" % "batik-util" % Versions.batik
  depOverrides = depOverrides ++ Set(batik, batikBridge, batikCss, batikDom, batikExt,
    batikParser, batikRasterizer, batikScript, batikTranscoder, batikUtil)

  val oldBcmailJdk14 = "bouncycastle" % "bcmail-jdk14" % "138"
  val oldBcprovJdk14 = "bouncycastle" % "bcprov-jdk14" % "140"
  val oldbctspJdk14 = "bouncycastle" % "bctsp-jdk14" % "138"
  depOverrides = depOverrides ++ Set(oldBcmailJdk14, oldBcprovJdk14, oldbctspJdk14)

  val oldC3p0 = "c3p0" % "c3p0" % "0.9.1.2"
  depOverrides = depOverrides ++ Set(oldC3p0)

  val oldCglib = "cglib" % "cglib" % Versions.cglib
  val oldCglibNodep = "cglib" % "cglib-nodep" % Versions.cglib
  depOverrides = depOverrides ++ Set(oldCglib, oldCglibNodep)

  val logbackClassic = "ch.qos.logback" % "logback-classic" % Versions.logback
  val logbackCore = "ch.qos.logback" % "logback-core" % Versions.logback
  val logbackJackson = "ch.qos.logback.contrib" % "logback-jackson" % Versions.logback
  val logbackJsonClassic = "ch.qos.logback.contrib" % "logback-json-classic" % Versions.logback
  val logbackJsonCore = "ch.qos.logback.contrib" % "logback-json-core" % Versions.logback
  val logbackMongodbAccess = "ch.qos.logback.contrib" % "logback-mongodb-access" % Versions.logback
  val logbackMongodbClassic = "ch.qos.logback.contrib" % "logback-mongodb-classic" % Versions.logback
  val logbackMongodbCore = "ch.qos.logback.contrib" % "logback-mongodb-core" % Versions.logback
  depOverrides = depOverrides ++ Set(logbackClassic, logbackCore, logbackJackson, logbackJsonClassic, logbackJsonCore,
    logbackMongodbAccess, logbackMongodbClassic, logbackMongodbCore)

  val awsJavaSdk = "com.amazonaws" % "aws-java-sdk" % "1.7.3"
  depOverrides = depOverrides ++ Set(awsJavaSdk)

  val metricsAnnotation = "com.codahale.metrics" % "metrics-annotation" % Versions.metrics
  val metricsCore = "com.codahale.metrics" % "metrics-core" % Versions.metrics
  val metricsEhcache = "com.codahale.metrics" % "metrics-ehcache" % Versions.metrics
  val metricsGanglia = "com.codahale.metrics" % "metrics-ganglia" % Versions.metrics
  val metricsGraphite = "com.codahale.metrics" % "metrics-graphite" % Versions.metrics
  val metricsHealthchecks = "com.codahale.metrics" % "metrics-healthchecks" % Versions.metrics
  val metricsHttpclient = "com.codahale.metrics" % "metrics-httpclient" % Versions.metrics
  val metricsJdbi = "com.codahale.metrics" % "metrics-jdbi" % Versions.metrics
  val metricsJersey = "com.codahale.metrics" % "metrics-jersey" % Versions.metrics
  val metricsJetty8 = "com.codahale.metrics" % "metrics-jetty8" % Versions.metrics
  val metricsJetty9 = "com.codahale.metrics" % "metrics-jetty9" % Versions.metrics
  val metricsJson = "com.codahale.metrics" % "metrics-json" % Versions.metrics
  val metricsJvm = "com.codahale.metrics" % "metrics-jvm" % Versions.metrics
  val metricsLog4j = "com.codahale.metrics" % "metrics-log4j" % Versions.metrics
  val metricsLogback = "com.codahale.metrics" % "metrics-logback" % Versions.metrics
  val metricsServlet = "com.codahale.metrics" % "metrics-servlet" % Versions.metrics
  val metricsServlets = "com.codahale.metrics" % "metrics-servlets" % Versions.metrics
  depOverrides = depOverrides ++ Set(metricsAnnotation, metricsCore, metricsEhcache, metricsGanglia, metricsGraphite,
    metricsHealthchecks, metricsHttpclient, metricsJdbi, metricsJersey, metricsJetty8, metricsJetty9,
    metricsJson, metricsJvm, metricsLog4j, metricsLogback, metricsServlet, metricsServlets)

  val jacksonAnnotations = "com.fasterxml.jackson.core" % "jackson-annotations" % Versions.jackson
  val jacksonCore = "com.fasterxml.jackson.core" % "jackson-core" % Versions.jackson
  val jacksonDatabind = "com.fasterxml.jackson.core" % "jackson-databind" % Versions.jackson
  val jacksonDataformatXml = "com.fasterxml.jackson.dataformat" % "jackson-dataformat-xml" % Versions.jackson
  val jacksonDataformatYaml = "com.fasterxml.jackson.dataformat" % "jackson-dataformat-yaml" % Versions.jackson
  val jacksonDatatypeGuava = "com.fasterxml.jackson.datatype" % "jackson-datatype-guava" % Versions.jackson
  val jacksonDatatypeHppc = "com.fasterxml.jackson.datatype" % "jackson-datatype-hppc" % Versions.jackson
  val jacksonDatatypeJoda = "com.fasterxml.jackson.datatype" % "jackson-datatype-joda" % Versions.jackson
  val jacksonDatatypeJsonOrg = "com.fasterxml.jackson.datatype" % "jackson-datatype-json-org" % Versions.jackson
  val jacksonDatatypeJsr353 = "com.fasterxml.jackson.datatype" % "jackson-datatype-jsr353" % Versions.jackson
  val jacksonJaxrsBase = "com.fasterxml.jackson.jaxrs" % "jackson-jaxrs-base" % Versions.jackson
  val jacksonJaxrsJsonProvider = "com.fasterxml.jackson.jaxrs" % "jackson-jaxrs-json-provider" % Versions.jackson
  val jacksonJaxrsSmileProvider = "com.fasterxml.jackson.jaxrs" % "jackson-jaxrs-smile-provider" % Versions.jackson
  val jacksonJaxrsXmlProvider = "com.fasterxml.jackson.jaxrs" % "jackson-jaxrs-xml-provider" % Versions.jackson
  val jacksonModuleJaxbAnnotations = "com.fasterxml.jackson.module" % "jackson-module-jaxb-annotations" % Versions.jackson
  val jacksonModuleAfterburner = "com.fasterxml.jackson.module" % "jackson-module-afterburner" % Versions.jackson
  depOverrides = depOverrides ++ Set(jacksonAnnotations, jacksonCore, jacksonDatabind, jacksonDataformatXml, jacksonDataformatYaml,
    jacksonDatatypeGuava, jacksonDatatypeHppc, jacksonDatatypeJoda, jacksonDatatypeJsonOrg, jacksonDatatypeJsr353, jacksonJaxrsBase,
    jacksonJaxrsJsonProvider, jacksonJaxrsSmileProvider, jacksonJaxrsXmlProvider, jacksonModuleAfterburner, jacksonModuleJaxbAnnotations)

  val slugify = "com.github.slugify" % "slugify" % "2.1.2"
  depOverrides = depOverrides ++ Set(slugify)

  val googleCollections = "com.google.collections" % "google-collections" % "1.0"
  depOverrides = depOverrides ++ Set(googleCollections)

  val guava = "com.google.guava" % "guava" % "16.0.1"
  depOverrides = depOverrides ++ Set(guava)

  val guice = "com.google.inject" % "guice" % Versions.guice
  val guiceAssistedInject = "com.google.inject.extensions" % "guice-assistedinject" % Versions.guice
  val guiceJmx = "com.google.inject.extensions" % "guice-jmx" % Versions.guice
  val guiceJndi = "com.google.inject.extensions" % "guice-jndi" % Versions.guice
  val guiceMultibindings = "com.google.inject.extensions" % "guice-multibindings" % Versions.guice
  val guiceServlet = "com.google.inject.extensions" % "guice-servlet" % Versions.guice
  depOverrides = depOverrides ++ Set(guice, guiceAssistedInject, guiceJmx, guiceJndi, guiceMultibindings, guiceServlet)

  val findbugs = "com.google.code.findbugs" % "findbugs" % "2.0.3"
  val findbugsAnnotations = "com.google.code.findbugs" % "findbugs-annotations" % "2.0.3"
  val findbugsJsr305 = "com.google.code.findbugs" % "jsr305" % "2.0.3"
  depOverrides = depOverrides ++ Set(findbugs, findbugsAnnotations, findbugsJsr305)

  val jsonSimple = "com.googlecode.json-simple" % "json-simple" % "1.1.1"
  depOverrides = depOverrides ++ Set(jsonSimple)

  val pojosr = "com.googlecode.pojosr" % "de.kalpatec.pojosr.framework" % "0.2.1"
  depOverrides = depOverrides ++ Set(pojosr)

  val hazelcast = "com.hazelcast" % "hazelcast" % "3.1.6"
  depOverrides = depOverrides ++ Set(hazelcast)

  val jsch = "com.jcraft" % "jsch" % "0.1.50"
  depOverrides = depOverrides ++ Set(jsch)

  val itext = "com.lowagie" % "itext" % "4.2.1"
  depOverrides = depOverrides ++ Set(itext)

  val c3p0 = "com.mchange" % "c3p0" % "0.9.2.1"
  depOverrides = depOverrides ++ Set(c3p0)

  val base64 = "com.mindprod" % "base64" % "1.6"
  depOverrides = depOverrides ++ Set(base64)

  val mockrunnerJdbc = "com.mockrunner" % "mockrunner-jdbc" % "1.0.0"
  depOverrides = depOverrides ++ Set(mockrunnerJdbc)

  val checkstyle = "com.puppycrawl.tools" % "checkstyle" % "5.7"
  depOverrides = depOverrides ++ Set(checkstyle)

  val rabbitmqAmqpClient = "com.rabbitmq" % "amqp-client" % "3.2.4"
  depOverrides = depOverrides ++ Set(rabbitmqAmqpClient)

  val jersey1Client = "com.sun.jersey" % "jersey-client" % Versions.jersey1
  val jersey1Core = "com.sun.jersey" % "jersey-core" % Versions.jersey1
  val jersey1Server = "com.sun.jersey" % "jersey-server" % Versions.jersey1
  val jersey1Servlet = "com.sun.jersey" % "jersey-servlet" % Versions.jersey1
  depOverrides = depOverrides ++ Set(jersey1Client, jersey1Core, jersey1Server, jersey1Servlet)

  val jersey1Guice = "com.sun.jersey.contribs" % "jersey-guice" % Versions.jersey1
  val jersey1Mulitpart = "com.sun.jersey.contribs" % "jersey-multipart" % Versions.jersey1
  val jersey1Spring = "com.sun.jersey.contribs" % "jersey-spring" % Versions.jersey1
  depOverrides = depOverrides ++ Set(jersey1Guice, jersey1Mulitpart, jersey1Spring)

  val jersey1OauthClient = "com.sun.jersey.contribs.jersey-oauth" % "oauth-client" % Versions.jersey1
  val jersey1OauthSignature = "com.sun.jersey.contribs.jersey-oauth" % "oauth-signature" % Versions.jersey1
  val jersey1OauthServer = "com.sun.jersey.contribs.jersey-oauth" % "oauth-server" % Versions.jersey1
  depOverrides = depOverrides ++ Set(jersey1OauthClient, jersey1OauthSignature, jersey1OauthServer)

  val jaxbImpl = "com.sun.xml.bind" % "jaxb-impl" % "2.2.8-b01"
  val jaxbXjc = "com.sun.xml.bind" % "jaxb-xjc" % "2.2.8-b01"
  depOverrides = depOverrides ++ Set(jaxbImpl, jaxbXjc)

  val paranamer = "com.thoughtworks.paranamer" % "paranamer" % "2.6"
  depOverrides = depOverrides ++ Set(paranamer)

  val xstream = "com.thoughtworks.xstream" % "xstream" % "1.4.7"
  depOverrides = depOverrides ++ Set(xstream)

  val akkaActor = "com.typesafe.akka" % "akka-actor" % Versions.akka
  val akkaRemote = "com.typesafe.akka" % "akka-remote" % Versions.akka
  val akkaSlf4j = "com.typesafe.akka" % "akka-slf4j" % Versions.akka
  depOverrides = depOverrides ++ Set(akkaActor, akkaRemote, akkaSlf4j)

  val proweb = "com.qas" % "proweb" % "4.0"
  depOverrides = depOverrides ++ Set(proweb)

  val swaggerAnnotations = "com.wordnik" %% "swagger-annotations" % Versions.swagger
  val swaggerCore = "com.wordnik" %% "swagger-core" % Versions.swagger
  val swaggerJaxrs = "com.wordnik" %% "swagger-jaxrs" % Versions.swagger
  val swaggerJerseyJaxrs = "com.wordnik" %% "swagger-jersey-jaxrs" % Versions.swagger
  val swaggerJersey2Jaxrs = "com.wordnik" %% "swagger-jersey2-jaxrs" % Versions.swagger
  val swaggerOauth2Server = "com.wordnik" %% "swagger-oauth2-server" % Versions.swagger
  val swaggerScalaServlet = "com.wordnik" %% "swagger-scala-servlet" % Versions.swagger
  val swaggerServlet = "com.wordnik" %% "swagger-servlet" % Versions.swagger
  depOverrides = depOverrides ++ Set(swaggerAnnotations, swaggerCore, swaggerJaxrs, swaggerJersey2Jaxrs,
    swaggerJerseyJaxrs, swaggerOauth2Server, swaggerScalaServlet, swaggerServlet)

  val yammerMetricsAnnotation = "com.yammer.metrics" % "metrics-annotation" % Versions.yammerMetrics
  val yammerMetricsCore = "com.yammer.metrics" % "metrics-core" % Versions.yammerMetrics
  val yammerMetricsEhcache = "com.yammer.metrics" % "metrics-ehcache" % Versions.yammerMetrics
  val yammerMetricsGuice = "com.yammer.metrics" % "metrics-guice" % Versions.yammerMetrics
  val yammerMetricsJersey = "com.yammer.metrics" % "metrics-jersey" % Versions.yammerMetrics
  val yammerMetricsServlet = "com.yammer.metrics" % "metrics-servlet" % Versions.yammerMetrics
  val yammerMetricsSpring = "com.yammer.metrics" % "metrics-spring" % Versions.yammerMetrics
  val yammerMetricsWeb = "com.yammer.metrics" % "metrics-web" % Versions.yammerMetrics
  depOverrides = depOverrides ++ Set(yammerMetricsAnnotation, yammerMetricsCore, yammerMetricsEhcache, yammerMetricsGuice,
    yammerMetricsJersey, yammerMetricsServlet, yammerMetricsSpring, yammerMetricsWeb)

  val commonsBeanutils = "commons-beanutils" % "commons-beanutils" % "1.9.1"
  val commonsCli = "commons-cli" % "commons-cli" % "1.2"
  val commonsCodec = "commons-codec" % "commons-codec" % "1.9"
  val commonsCollections = "commons-collections" % "commons-collections" % "3.2.1"
  val commonsDaemon = "commons-daemon" % "commons-daemon" % "1.0.15"
  val commonsDbcp = "commons-dbcp" % "commons-dbcp" % "1.4"
  val commonsDigester = "commons-digester" % "commons-digester" % "2.1"
  val commonsFileupload = "commons-fileupload" % "commons-fileupload" %"1.3.1"
  val commonsHttpclient = "commons-httpclient" % "commons-httpclient" % "3.1"
  val commonsIo = "commons-io" % "commons-io" % "2.4"
  val commonsLang = "commons-lang" % "commons-lang" % "2.6"
  val commonsLogging = "commons-logging" % "commons-logging" % "1.1.3"
  val commonsLoggingApi = "commons-logging" % "commons-logging-api" % "1.1"
  val commonsPool = "commons-pool" % "commons-pool" % "1.6"
  val commonsNet = "commons-net" % "commons-net" % "3.3"
  depOverrides = depOverrides ++ Set(commonsBeanutils, commonsCli, commonsCodec, commonsCollections, commonsDaemon, commonsDbcp,
    commonsDigester, commonsFileupload, commonsHttpclient, commonsIo, commonsLang, commonsLogging, commonsLoggingApi,
    commonsPool, commonsNet)

  val dom4j = "dom4j" % "dom4j" % "1.6.1"
  depOverrides = depOverrides ++ Set(dom4j)

  val oldFreemarker = "freemarker" % "freemarker" % "2.3.15"
  depOverrides = depOverrides ++ Set(oldFreemarker)

  val cucumberAndroid = "info.cukes" % "cucumber-android" % Versions.cucumber
  val cucumberClojure = "info.cukes" % "cucumber-clojure" % Versions.cucumber
  val cucumberCore = "info.cukes" % "cucumber-core" % Versions.cucumber
  val cucumberGroovy = "info.cukes" % "cucumber-groovy" % Versions.cucumber
  val cucumberGuice = "info.cukes" % "cucumber-guice" % Versions.cucumber
  val cucumberIoke = "info.cukes" % "cucumber-ioke" % Versions.cucumber
  val cucumberJava = "info.cukes" % "cucumber-java" % Versions.cucumber
  val cucumberJruby = "info.cukes" % "cucumber-jruby" % Versions.cucumber
  val cucumberJunit = "info.cukes" % "cucumber-junit" % Versions.cucumber
  val cucumberJython = "info.cukes" % "cucumber-jython" % Versions.cucumber
  val cucumberNeedle = "info.cukes" % "cucumber-needle" % Versions.cucumber
  val cucumberOpenejb = "info.cukes" % "cucumber-openejb" % Versions.cucumber
  val cucumberPicocontainer = "info.cukes" % "cucumber-picocontainer" % Versions.cucumber
  val cucumberScala = "info.cukes" % "cucumber-scala" % Versions.cucumber
  val cucumberSpring = "info.cukes" % "cucumber-spring" % Versions.cucumber
  val cucumberWeld = "info.cukes" % "cucumber-weld" % Versions.cucumber
  depOverrides = depOverrides ++ Set(cucumberAndroid, cucumberClojure, cucumberCore, cucumberGroovy, cucumberGuice, cucumberIoke,
    cucumberJava, cucumberJruby, cucumberJunit, cucumberJython, cucumberNeedle, cucumberOpenejb, cucumberPicocontainer,
    cucumberScala, cucumberSpring, cucumberWeld)

  val nettyAll = "io.netty" % "netty-all" % Versions.netty
  val nettyBuffer = "io.netty" % "netty-buffer" % Versions.netty
  val nettyCodec = "io.netty" % "netty-codec" % Versions.netty
  val nettyCommon = "io.netty" % "netty-common" % Versions.netty
  val nettyExample = "io.netty" % "netty-example" % Versions.netty
  val nettyHandler = "io.netty" % "netty-handler" % Versions.netty
  val nettyTransport = "io.netty" % "netty-transport" % Versions.netty
  depOverrides = depOverrides ++ Set(nettyAll, nettyBuffer, nettyCodec, nettyCommon, nettyExample, nettyHandler, nettyTransport)

  val javassist = "javassist" % "javassist" % "3.12.1.GA"
  depOverrides = depOverrides ++ Set(javassist)

  val activation = "javax.activation" % "activation" % "1.1.1"
  depOverrides = depOverrides ++ Set(activation)

  val jsr250Api = "javax.annotation" % "jsr250-api" % "1.0"
  depOverrides = depOverrides ++ Set(jsr250Api)

  val javaxAnnotationApi = "javax.annotation" % "javax.annotation-api" % "1.2"
  depOverrides = depOverrides ++ Set(javaxAnnotationApi)

  val javaxCacheApi = "javax.cache" % "cache-api" % "1.0.0-RC1"
  depOverrides = depOverrides ++ Set(javaxCacheApi)

  val elApi = "javax.el" % "el-api" % "2.2"
  depOverrides = depOverrides ++ Set(elApi)

  val javaxElApi = "javax.el" % "javax.el-api" % "3.0.0"
  depOverrides = depOverrides ++ Set(javaxElApi)

  val javaxInject = "javax.inject" % "javax.inject" % "1"
  depOverrides = depOverrides ++ Set(javaxInject)

  val j2ee = "javax.j2ee" % "j2ee" % "1.5"
  depOverrides = depOverrides ++ Set(j2ee)

  val jms = "javax.jms" % "jms" % "1.1"
  depOverrides = depOverrides ++ Set(jms)

  val mail = "javax.mail" % "mail" % "1.4.7"
  depOverrides = depOverrides ++ Set(mail)

  val javaxMailApi = "javax.mail" % "javax.mail-api" % "1.5.1"
  depOverrides = depOverrides ++ Set(javaxMailApi)

  val persistenceApi = "javax.persistence" % "persistence-api" % "1.0.2"
  depOverrides = depOverrides ++ Set(persistenceApi)

  val jsr94 = "javax.rules" % "jsr94" % "1.1"
  depOverrides = depOverrides ++ Set(jsr94)

  val servletApi = "javax.servlet" % "servlet-api" % "2.5"
  depOverrides = depOverrides ++ Set(servletApi)

  val javaxServletApi = "javax.servlet" % "javax.servlet-api" % "3.1.0"
  depOverrides = depOverrides ++ Set(javaxServletApi)

  val jstl = "javax.servlet" % "jstl" % "1.2"
  depOverrides = depOverrides ++ Set(jstl)

  val jspApi = "javax.servlet.jsp" % "jsp-api" % "2.2.1"
  depOverrides = depOverrides ++ Set(jspApi)

  val jstlApi = "javax.servlet.jsp.jstl" % "jstl-api" % "1.2"
  depOverrides = depOverrides ++ Set(jstlApi)

  val jta = "javax.transaction" % "jta" % "1.1"
  depOverrides = depOverrides ++ Set(jta)

  val validationApi = "javax.validation" % "validation-api" % "1.1.0.Final"
  depOverrides = depOverrides ++ Set(validationApi)

  val jsr311Api = "javax.ws.rs" % "jsr311-api" % "1.1.1"
  depOverrides = depOverrides ++ Set(jsr311Api)

  val javaxWsRsApi = "javax.ws.rs" % "javax.ws.rs-api" % "2.0-m10"
  depOverrides = depOverrides ++ Set(javaxWsRsApi)

  val jsr173 = "javax.xml" % "jsr173" % "1.0"
  depOverrides = depOverrides ++ Set(jsr173)

  val jaxbApi = "javax.xml.bind" % "jaxb-api" % "2.2.11"
  depOverrides = depOverrides ++ Set(jaxbApi)

  val staxApi = "javax.xml.stream" % "stax-api" % "1.0-2"
  depOverrides = depOverrides ++ Set(staxApi)

  val jaxen = "jaxen" % "jaxen" % "1.1.4"
  depOverrides = depOverrides ++ Set(jaxen)

  val jdepend = "jdepend" % "jdepend" % "2.9.1"
  depOverrides = depOverrides ++ Set(jdepend)

  val jline = "jline" % "jline" % "2.11"
  depOverrides = depOverrides ++ Set(jline)

  val jodaTime = "joda-time" % "joda-time" % "2.3"
  depOverrides = depOverrides ++ Set(jodaTime)

  val junit = "junit" % "junit" % "4.11"
  depOverrides = depOverrides ++ Set(junit)

  val jxl = "jxl" % "jxl" % "2.6.10"
  depOverrides = depOverrides ++ Set(jxl)

  val log4j = "log4j" % "log4j" % "1.2.17"
  val log4jExtras = "log4j" % "apache-log4j-extras" % "1.2.17"
  depOverrides = depOverrides ++ Set(log4j, log4jExtras)

  val mysqlConnectorJava = "mysql" % "mysql-connector-java" % "5.1.29"
  depOverrides = depOverrides ++ Set(mysqlConnectorJava)

  val jerichoHtml = "net.htmlparser.jericho" % "jericho-html" % "3.3"
  depOverrides = depOverrides ++ Set(jerichoHtml)

  val ehcache = "net.sf.ehcache" % "ehcache" % "2.8.1"
  depOverrides = depOverrides ++ Set(ehcache)

  val flexjson = "net.sf.flexjson" % "flexjson" % "3.2"
  depOverrides = depOverrides ++ Set(flexjson)

  val cobertura = "net.sourceforge.cobertura" % "cobertura" % "2.0.3"
  depOverrides = depOverrides ++ Set(cobertura)

  val saxon = "net.sourceforge.saxon" % "saxon" % "9.1.0.8"
  depOverrides = depOverrides ++ Set(saxon)

  val ognl = "ognl" % "ognl" % "3.0.8"
  depOverrides = depOverrides ++ Set(ognl)

  val opencsv = "opencsv" % "opencsv" % "1.8"
  depOverrides = depOverrides ++ Set(opencsv)

  val antlr = "org.antlr" % "antlr" % "3.5.1"
  val antlrStringtemplate = "org.antlr" % "stringtemplate" % "4.0.2"
  depOverrides = depOverrides ++ Set(antlr, antlrStringtemplate)

  val jakartaOro = "org.apache" % "jakarta-oro" % "2.0.8"
  depOverrides = depOverrides ++ Set(jakartaOro)

  val activemqAll = "org.apache.activemq" % "activemq-all" % Versions.activemq
  val activemqCamel = "org.apache.activemq" % "activemq-camel" % Versions.activemq
  val activemqPool = "org.apache.activemq" % "activemq-pool" % Versions.activemq
  depOverrides = depOverrides ++ Set(activemqAll, activemqCamel, activemqPool)

  val ant = "org.apache.ant" % "ant" % Versions.ant
  val antLauncher = "org.apache.ant" % "ant-launcher" % Versions.ant
  depOverrides = depOverrides ++ Set(ant, antLauncher)

  val avro = "org.apache.avro" % "avro" % Versions.avro
  val avroIpc = "org.apache.avro" % "avro-ipc" % Versions.avro
  depOverrides = depOverrides ++ Set(avro, avroIpc)

  val bsfAll = "org.apache.bsf" % "bsf-all" % "3.0-beta3"
  depOverrides = depOverrides ++ Set(bsfAll)

  val camelAws = "org.apache.camel" % "camel-aws" % Versions.camel
  val camelBeanValidator = "org.apache.camel" % "camel-bean-validator" % Versions.camel
  val camelBindy = "org.apache.camel" % "camel-bindy" % Versions.camel
  val camelCache = "org.apache.camel" % "camel-cache" % Versions.camel
  val camelCore = "org.apache.camel" % "camel-core" % Versions.camel
  val camelCoreXml = "org.apache.camel" % "camel-core-xml" % Versions.camel
  val camelCsv = "org.apache.camel" % "camel-csv" % Versions.camel
  val camelCxf = "org.apache.camel" % "camel-cxf" % Versions.camel
  val camelCxfTransport = "org.apache.camel" % "camel-cxf-transport" % Versions.camel
  val camelDozer = "org.apache.camel" % "camel-dozer" % Versions.camel
  val camelEclipse = "org.apache.camel" % "camel-eclipse" % Versions.camel
  val camelFtp = "org.apache.camel" % "camel-ftp" % Versions.camel
  val camelHttp4 = "org.apache.camel" % "camel-http4" % Versions.camel
  val camelJackson = "org.apache.camel" % "camel-jackson" % Versions.camel
  val camelJaxb = "org.apache.camel" % "camel-jaxb" % Versions.camel
  val camelJdbc = "org.apache.camel" % "camel-jdbc" % Versions.camel
  val camelJms = "org.apache.camel" % "camel-jms" % Versions.camel
  val camelJpa = "org.apache.camel" % "camel-jpa" % Versions.camel
  val camelLucene = "org.apache.camel" % "camel-lucene" % Versions.camel
  val camelMail = "org.apache.camel" % "camel-mail" % Versions.camel
  val camelMongodb = "org.apache.camel" % "camel-mongodb" % Versions.camel
  val camelQuartz = "org.apache.camel" % "camel-quartz" % Versions.camel
  val camelRabbitmq = "org.apache.camel" % "camel-rabbitmq" % Versions.camel
  val camelScala = "org.apache.camel" % "camel-scala" % Versions.camel
  val camelScript = "org.apache.camel" % "camel-script" % Versions.camel
  val camelSmpp = "org.apache.camel" % "camel-smpp" % Versions.camel
  val camelSolr = "org.apache.camel" % "camel-solr" % Versions.camel
  val camelSpring = "org.apache.camel" % "camel-spring" % Versions.camel
  val camelTest = "org.apache.camel" % "camel-test" % Versions.camel
  val camelTestng = "org.apache.camel" % "camel-testng" % Versions.camel
  val camelVelocity = "org.apache.camel" % "camel-velocity" % Versions.camel
  val camelWeb = "org.apache.camel" % "camel-web" % Versions.camel
  val camelWebsocket = "org.apache.camel" % "camel-websocket" % Versions.camel
  val camelXmljson = "org.apache.camel" % "camel-xmljson" % Versions.camel
  val camelXmpp = "org.apache.camel" % "camel-xmpp" % Versions.camel
  val camelXstream = "org.apache.camel" % "camel-xstream" % Versions.camel
  val camelZookeeper = "org.apache.camel" % "camel-zookeeper" % Versions.camel
  depOverrides = depOverrides ++ Set(camelAws, camelBeanValidator, camelBindy, camelCache, camelCore, camelCoreXml, camelCsv,
    camelCxf, camelCxfTransport, camelDozer, camelEclipse, camelFtp, camelHttp4, camelJackson, camelJaxb, camelJdbc,
    camelJms, camelJpa, camelLucene, camelMail, camelMongodb, camelQuartz, camelRabbitmq, camelScala, camelScript,
    camelSmpp, camelSolr, camelSpring, camelTest, camelTestng, camelVelocity, camelWeb, camelWebsocket, camelXmljson,
    camelXmpp, camelXstream, camelZookeeper)

  val commonsLang3 = "org.apache.commons" % "commons-lang3" % "3.3"
  depOverrides = depOverrides ++ Set(commonsLang3)

  val commonsMath3 = "org.apache.commons" % "commons-math3" % "3.2"
  depOverrides = depOverrides ++ Set(commonsMath3)

  val cxfApi = "org.apache.cxf" % "cxf-api" % Versions.cxf
  val cxfBundle = "org.apache.cxf" % "cxf-bundle" % Versions.cxf
  val cxfRtBindingsSoap = "org.apache.cxf" % "cxf-rt-bindings-soap" % Versions.cxf
  val cxfRtBindingsXml = "org.apache.cxf" % "cxf-rt-bindings-xml" % Versions.cxf
  val cxfRtCore = "org.apache.cxf" % "cxf-rt-core" % Versions.cxf
  val cxfRtDatabindingJaxb = "org.apache.cxf" % "cxf-rt-databinding-jaxb" % Versions.cxf
  val cxfRtFeaturesClustering = "org.apache.cxf" % "cxf-rt-features-clustering" % Versions.cxf
  val cxfRtFrontendJaxrs = "org.apache.cxf" % "cxf-rt-frontend-jaxrs" % Versions.cxf
  val cxfRtFrontendJaxws = "org.apache.cxf" % "cxf-rt-frontend-jaxws" % Versions.cxf
  val cxfRtFrontendSimple = "org.apache.cxf" % "cxf-rt-frontend-simple" % Versions.cxf
  val cxfRtRsExtensionProviders = "org.apache.cxf" % "cxf-rt-rs-extension-providers" % Versions.cxf
  val cxfRtRsExtensionSearch = "org.apache.cxf" % "cxf-rt-rs-extension-search" % Versions.cxf
  val cxfRtRsSecurityCors = "org.apache.cxf" % "cxf-rt-rs-security-cors" % Versions.cxf
  val cxfRtRsSecurityOauth = "org.apache.cxf" % "cxf-rt-rs-security-oauth" % Versions.cxf
  val cxfRtRsSecurityOauth2 = "org.apache.cxf" % "cxf-rt-rs-security-oauth2" % Versions.cxf
  val cxfRtTransportsHttp = "org.apache.cxf" % "cxf-rt-transports-http" % Versions.cxf
  val cxfRtTransportsHttpJetty = "org.apache.cxf" % "cxf-rt-transports-http-jetty" % Versions.cxf
  val cxfRtWsAddr = "org.apache.cxf" % "cxf-rt-ws-addr" % Versions.cxf
  val cxfTestutils = "org.apache.cxf" % "cxf-testutils" % Versions.cxf
  val cxfSystestsJaxrs = "org.apache.cxf.systests" % "cxf-systests-jaxrs" % Versions.cxf
  depOverrides = depOverrides ++ Set(cxfApi, cxfBundle, cxfRtBindingsSoap, cxfRtBindingsXml, cxfRtCore, cxfRtDatabindingJaxb,
    cxfRtFeaturesClustering, cxfRtFrontendJaxrs, cxfRtFrontendJaxws, cxfRtFrontendSimple, cxfRtRsExtensionProviders,
    cxfRtRsExtensionSearch, cxfRtRsSecurityCors, cxfRtRsSecurityOauth, cxfRtRsSecurityOauth2, cxfRtTransportsHttp,
    cxfRtTransportsHttpJetty, cxfRtWsAddr, cxfTestutils, cxfSystestsJaxrs)

  val geronimoAnnotation10Spec = "org.apache.geronimo.specs" % "geronimo-annotation_1.0_spec" % "1.1.1"
  depOverrides = depOverrides ++ Set(geronimoAnnotation10Spec)

  val geronimoJ2ee11Spec = "org.apache.geronimo.specs" % "geronimo-j2ee-management_1.1_spec" % "1.0.1"
  depOverrides = depOverrides ++ Set(geronimoJ2ee11Spec)

  val geronimoJaspic10Spec = "org.apache.geronimo.specs" % "geronimo-jaspic_1.0_spec" % "1.1"
  depOverrides = depOverrides ++ Set(geronimoJaspic10Spec)

  val geronimoJms11Spec = "org.apache.geronimo.specs" % "geronimo-jms_1.1_spec" % "1.1.1"
  depOverrides = depOverrides ++ Set(geronimoJms11Spec)

  val geronimoJta101BSpec = "org.apache.geronimo.specs" % "geronimo-jta_1.0.1B_spec" % "1.1.1"
  depOverrides = depOverrides ++ Set(geronimoJta101BSpec)

  val geronimoJta11Spec = "org.apache.geronimo.specs" % "geronimo-jta_1.1_spec" % "1.1.1"
  depOverrides = depOverrides ++ Set(geronimoJta11Spec)

  val geronimoServlet25Spec = "org.apache.geronimo.specs" % "geronimo-servlet_2.5_spec" % "1.2"
  depOverrides = depOverrides ++ Set(geronimoServlet25Spec)

  val geronimoServlet30Spec = "org.apache.geronimo.specs" % "geronimo-servlet_3.0_spec" % "1.0"
  depOverrides = depOverrides ++ Set(geronimoServlet30Spec)

  val geronimoStaxApi10Spec = "org.apache.geronimo.specs" % "geronimo-stax-api_1.0_spec" % "1.0.1"
  depOverrides = depOverrides ++ Set(geronimoStaxApi10Spec)

  val httpclient = "org.apache.httpcomponents" % "httpclient" % Versions.httpComponents
  val httpclientCache = "org.apache.httpcomponents" % "httpclient-cache" % Versions.httpComponents
  val httpcore = "org.apache.httpcomponents" % "httpcore" % "4.3.2"
  val httpmime = "org.apache.httpcomponents" % "httpmime" % Versions.httpComponents
  depOverrides = depOverrides ++ Set(httpclient, httpclientCache, httpcore, httpmime)

  val log4j2 = "org.apache.logging.log4j" % "log4j" % "2.0-rc1"
  depOverrides = depOverrides ++ Set(log4j2)

  val lucenceAnalyzersCommon = "org.apache.lucene" % "lucene-analyzers-common" % Versions.lucene
  val lucenceCore = "org.apache.lucene" % "lucene-core" % Versions.lucene
  depOverrides = depOverrides ++ Set(lucenceAnalyzersCommon, lucenceCore)

  val tomcat = "org.apache.tomcat" % "tomcat" % Versions.tomcat
  depOverrides = depOverrides ++ Set(tomcat)

  val xbeanSpring = "org.apache.xbean" % "xbean-spring" % "3.16"
  depOverrides = depOverrides ++ Set(xbeanSpring)

  val xmlbeans = "org.apache.xmlbeans" % "xmlbeans" % "2.5.0"
  depOverrides = depOverrides ++ Set(xmlbeans)

  val aspectjrt = "org.aspectj" % "aspectjrt" % Versions.aspectj
  val aspectjtools = "org.aspectj" % "aspectjtools" % Versions.aspectj
  val aspectjweaver = "org.aspectj" % "aspectjweaver" % Versions.aspectj
  depOverrides = depOverrides ++ Set(aspectjrt, aspectjtools, aspectjweaver)

  val bcmailJdk14 = "org.bouncycastle" % "bcmail-jdk14" % Versions.bouncycastle
  val bcmailJdk15on = "org.bouncycastle" % "bcmail-jdk15on" % Versions.bouncycastle
  val bcpgJdk14 = "org.bouncycastle" % "bcpg-jdk14" % Versions.bouncycastle
  val bcpgJdk15on = "org.bouncycastle" % "bcpg-jdk15on" % Versions.bouncycastle
  val bcpkixJdk14 = "org.bouncycastle" % "bcpkix-jdk14" % Versions.bouncycastle
  val bcpkixJdk145on = "org.bouncycastle" % "bcpkix-jdk145on" % Versions.bouncycastle
  val bcprovJdk14 = "org.bouncycastle" % "bcprov-jdk14" % Versions.bouncycastle
  val bcprovJdk15on = "org.bouncycastle" % "bcprov-jdk15on" % Versions.bouncycastle
  val bcprovExtJdk14 = "org.bouncycastle" % "bcprov-ext-jdk14" % Versions.bouncycastle
  val bcprovExtJdk15on = "org.bouncycastle" % "bcprov-ext-jdk15on" % Versions.bouncycastle
  depOverrides = depOverrides ++ Set(bcmailJdk14, bcmailJdk15on, bcpgJdk14, bcpgJdk15on, bcpkixJdk14, bcpkixJdk145on,
    bcprovJdk14, bcprovJdk15on, bcprovExtJdk14, bcprovExtJdk15on)

  val enunciateCoreAnnotations = "org.codehaus.enunciate" % "enunciate-core-annotations" % "1.28"
  depOverrides = depOverrides ++ Set(enunciateCoreAnnotations)

  val groovy = "org.codehaus.groovy" % "groovy" % "2.2.2"
  val groovyAll = "org.codehaus.groovy" % "groovy-all" % "2.2.2"
  depOverrides = depOverrides ++ Set(groovy, groovyAll)

  val jackson1CoreAsl = "org.codehaus.jackson" % "jackson-core-asl" % Versions.jackson1
  val jackson1Jaxrs = "org.codehaus.jackson" % "jackson-jaxrs" % Versions.jackson1
  val jackson1MapperAsl = "org.codehaus.jackson" % "jackson-mapper-asl" % Versions.jackson1
  val jackson1Xc = "org.codehaus.jackson" % "jackson-xc" % Versions.jackson1
  depOverrides = depOverrides ++ Set(jackson1CoreAsl, jackson1Jaxrs, jackson1MapperAsl, jackson1Xc)

  val jettison = "org.codehaus.jettison" % "jettison" % "1.3.5"
  depOverrides = depOverrides ++ Set(jettison)

  val easymock = "org.easymock" % "easymock" % "3.2"
  depOverrides = depOverrides ++ Set(easymock)

  val jettyAnt = "org.eclipse.jetty" % "jetty-ant" % Versions.jetty
  val jettyDistribution = "org.eclipse.jetty" % "jetty-distribution" % Versions.jetty
  val jettyServer = "org.eclipse.jetty" % "jetty-server" % Versions.jetty
  depOverrides = depOverrides ++ Set(jettyAnt, jettyDistribution, jettyServer)

  val eclipseLink = "org.eclipse.persistence" % "eclipselink" % "2.5.1"
  depOverrides = depOverrides ++ Set(eclipseLink)

  val javaxPersistence = "org.eclipse.persistence" % "javax.persistence" % "2.1.0"
  depOverrides = depOverrides ++ Set(javaxPersistence)

  val freemarker = "org.freemarker" % "freemarker" % Versions.freemarker
  val freemarkerGae = "org.freemarker" % "freemarker-gae" % Versions.freemarker
  depOverrides = depOverrides ++ Set(freemarker, freemarkerGae)

  val jerseyJettyConnector = "org.glassfish.jersey.connector" % "jersey-jetty-connector" % Versions.jersey
  depOverrides = depOverrides ++ Set(jerseyJettyConnector)

  val jerseyClient = "org.glassfish.jersey.core" % "jersey-client" % Versions.jersey
  val jerseyCommon = "org.glassfish.jersey.core" % "jersey-common" % Versions.jersey
  val jerseyServer = "org.glassfish.jersey.core" % "jersey-server" % Versions.jersey
  depOverrides = depOverrides ++ Set(jerseyClient, jerseyCommon, jerseyServer)

  val jerseyBeanValidation = "org.glassfish.jersey.ext" % "jersey-bean-validation" % Versions.jersey
  val jerseyDeclarativeLinking = "org.glassfish.jersey.media" % "jersey-declarative-linking" % Versions.jersey
  val jerseySpring3 = "org.glassfish.jersey.media" % "jersey-spring3" % Versions.jersey
  depOverrides = depOverrides ++ Set(jerseyBeanValidation, jerseyDeclarativeLinking, jerseySpring3)

  val jerseyMediaJson = "org.glassfish.jersey.media" % "jersey-media-json" % Versions.jersey
  val jerseyMediaJsonJackson = "org.glassfish.jersey.media" % "jersey-media-json-jackson" % Versions.jersey
  val jerseyMediaJsonJettison = "org.glassfish.jersey.media" % "jersey-media-json-jettison" % Versions.jersey
  val jerseyMediaMultipart = "org.glassfish.jersey.media" % "jersey-media-multipart" % Versions.jersey
  depOverrides = depOverrides ++ Set(jerseyMediaJson, jerseyMediaJsonJackson, jerseyMediaJsonJettison, jerseyMediaMultipart)

  val jerseyOauth2Client = "org.glassfish.jersey.security" % "oauth2-client" % Versions.jersey
  depOverrides = depOverrides ++ Set(jerseyOauth2Client)

  val hibernateC3p0 = "org.hibernate" % "hibernate-c3p0" % Versions.hibernate
  val hibernateCore = "org.hibernate" % "hibernate-core" % Versions.hibernate
  val hibernateEhcache = "org.hibernate" % "hibernate-ehcache" % Versions.hibernate
  val hibernateEntitymanager = "org.hibernate" % "hibernate-entitymanager" % Versions.hibernate
  val hibernateSearch = "org.hibernate" % "hibernate-search" % "4.5.0.Final"
  val hibernateValidator = "org.hibernate" % "hibernate-validator" % "5.1.0.Final"
  depOverrides = depOverrides ++ Set(hibernateC3p0, hibernateCore, hibernateEhcache, hibernateEntitymanager, hibernateSearch,
    hibernateValidator)

  val hsqldb = "org.hsqldb" % "hsqldb" % "2.3.2"
  depOverrides = depOverrides ++ Set(hsqldb)

  val jdom = "org.jdom" % "jdom" % "2.0.2"
  depOverrides = depOverrides ++ Set(jdom)

  val jencks = "org.jencks" % "jencks" % Versions.jencks
  val jencksAmqpool = "org.jencks" % "jencks-amqpool" % Versions.jencks
  depOverrides = depOverrides ++ Set(jencks, jencksAmqpool)

  val json4sJackson = "org.json4s" %% "json4s-jackson" % Versions.json4s
  val json4sNative = "org.json4s" %% "json4s-native" % Versions.json4s
  depOverrides = depOverrides ++ Set(json4sJackson, json4sNative)

  val annox = "org.jvnet.annox" % "annox" % "0.5.1"
  depOverrides = depOverrides ++ Set(annox)

  val jetty6 = "org.mortbay.jetty" % "jetty" % Versions.jetty6
  val jettyManagement6 = "org.mortbay.jetty" % "jetty-management" % Versions.jetty6
  val jettyUtil6 = "org.mortbay.jetty" % "jetty-util" % Versions.jetty6
  depOverrides = depOverrides ++ Set(jetty6, jettyManagement6, jettyUtil6)

  val mybatis = "org.mybatis" % "mybatis" %"3.2.5"
  val mybatisEhcache = "org.mybatis" % "mybatis-ehcache" %"1.0.0"
  val mybatisGuice = "org.mybatis" % "mybatis-guice" %"3.5"
  val mybatisSpring = "org.mybatis" % "mybatis-spring" %"1.2.2"
  depOverrides = depOverrides ++ Set(mybatis, mybatisEhcache, mybatisGuice, mybatisSpring)

  val mockitoAll = "org.mockito" % "mockito-all" % "1.9.5"
  depOverrides = depOverrides ++ Set(mockitoAll)

  val mongoJavaDriver = "org.mongodb" % "mongo-java-driver" % "2.11.4"
  depOverrides = depOverrides ++ Set(mongoJavaDriver)

  val mvel2 = "org.mvel" % "mvel2" % "2.1.9.Final"
  depOverrides = depOverrides ++ Set(mvel2)

  val objenesis = "org.objenesis" % "objenesis" % "2.1"
  depOverrides = depOverrides ++ Set(objenesis)

  val ostermillerUtils = "org.ostermiller" % "utils" % "1.07.00"
  depOverrides = depOverrides ++ Set(ostermillerUtils)

  val asm = "org.ow2.asm" % "asm" % Versions.asm
  val asmAll = "org.ow2.asm" % "asm-all" % Versions.asm
  val asmAnalysis = "org.ow2.asm" % "asm-analysis" % Versions.asm
  val asmCommons = "org.ow2.asm" % "asm-commons" % Versions.asm
  val asmDebugAll = "org.ow2.asm" % "asm-debug-all" % Versions.asm
  val asmTree = "org.ow2.asm" % "asm-tree" % Versions.asm
  val asmUtil = "org.ow2.asm" % "asm-util" % Versions.asm
  val asmXml = "org.ow2.asm" % "asm-xml" % Versions.asm
  depOverrides = depOverrides ++ Set(asm, asmAll, asmAnalysis, asmCommons, asmDebugAll, asmTree, asmUtil, asmXml)

  val powermockApi = "org.powermock" % "powermock-api" % Versions.powermock
  val powermockCore = "org.powermock" % "powermock-core" % Versions.powermock
  val powermockEasymockReleaseFull = "org.powermock" % "powermock-easymock-release-full" % Versions.powermock
  val powermockMockitoReleaseFull = "org.powermock" % "powermock-mockito-release-full" % Versions.powermock
  val powermockModuleJunit4 = "org.powermock" % "powermock-module-junit4" % Versions.powermock
  val powermockModuleJunit4Common = "org.powermock" % "powermock-module-junit4-common" % Versions.powermock
  val powermockModuleTestng = "org.powermock" % "powermock-module-testng" % Versions.powermock
  val powermockModuleTestngCommon = "org.powermock" % "powermock-module-testng-common" % Versions.powermock
  depOverrides = depOverrides ++ Set(powermockApi, powermockCore, powermockEasymockReleaseFull, powermockMockitoReleaseFull,
    powermockModuleJunit4, powermockModuleJunit4Common, powermockModuleTestng, powermockModuleTestngCommon)

  val quartz = "org.quartz-scheduler" % "quartz" % "2.2.1"
  depOverrides = depOverrides ++ Set(quartz)

  val scalaActors = "org.scala-lang" % "scala-actors" % Versions.scala
  val scalaCompiler = "org.scala-lang" % "scala-compiler" % Versions.scala
  val scalaDist = "org.scala-lang" % "scala-dist" % Versions.scala
  val scalaLibrary = "org.scala-lang" % "scala-library" % Versions.scala
  val scalaLibraryAll = "org.scala-lang" % "scala-library-all" % Versions.scala
  val scalaReflect = "org.scala-lang" % "scala-reflect" % Versions.scala
  val scalap = "org.scala-lang" % "scalap" % Versions.scala
  depOverrides = depOverrides ++ Set(scalaActors, scalaCompiler, scalaDist, scalaLibrary, scalaLibraryAll, scalaReflect, scalap)

  val scalaAsync = "org.scala-lang.modules" %% "scala-async" % "0.9.1"
  val scalaPartest = "org.scala-lang.modules" %% "scala-partest" % "1.0.10"
  val scalaPartestInterface = "org.scala-lang.modules" %% "scala-partest-interface" % "0.4.0"
  val scalaSwing = "org.scala-lang.modules" %% "scala-swing" % "1.0.1"
  val scalaXml = "org.scala-lang.modules" %% "scala-xml" % "1.0.1"
  depOverrides = depOverrides ++ Set(scalaAsync, scalaPartest, scalaPartestInterface, scalaSwing, scalaXml)

  val scalastyle = "org.scalastyle" %% "scalastyle" % Versions.scalastyle
  depOverrides = depOverrides ++ Set(scalastyle)

  val jclOverSlf4j = "org.slf4j" % "jcl-over-slf4j" % Versions.slf4j
  depOverrides = depOverrides ++ Set(jclOverSlf4j)

  val slf4jAndroid = "org.slf4j" % "slf4j-android" % Versions.slf4j
  val slf4jApi = "org.slf4j" % "slf4j-api" % Versions.slf4j
  val slf4jExt = "org.slf4j" % "slf4j-ext" % Versions.slf4j
  val slf4jJcl = "org.slf4j" % "slf4j-jcl" % Versions.slf4j
  val slf4jLog4j12 = "org.slf4j" % "slf4j-log4j12" % Versions.slf4j
  val slf4jSimple = "org.slf4j" % "slf4j-simple" % Versions.slf4j
  depOverrides = depOverrides ++ Set(slf4jAndroid, slf4jApi, slf4jExt, slf4jJcl, slf4jLog4j12, slf4jSimple)

  val springAop = "org.springframework" % "spring-aop" % Versions.spring
  val springAsm = "org.springframework" % "spring-asm" % Versions.spring
  val springAspects = "org.springframework" % "spring-aspects" % Versions.spring
  val springBeans = "org.springframework" % "spring-beans" % Versions.spring
  val springContext = "org.springframework" % "spring-context" % Versions.spring
  val springContextSupport = "org.springframework" % "spring-context-support" % Versions.spring
  val springCore = "org.springframework" % "spring-core" % Versions.spring
  val springExpression = "org.springframework" % "spring-expression" % Versions.spring
  val springInstrument = "org.springframework" % "spring-instrument" % Versions.spring
  val springJdbc = "org.springframework" % "spring-jdbc" % Versions.spring
  val springJms = "org.springframework" % "spring-jms" % Versions.spring
  val springOrm = "org.springframework" % "spring-orm" % Versions.spring
  val springOxm = "org.springframework" % "spring-oxm" % Versions.spring
  val springTest = "org.springframework" % "spring-test" % Versions.spring
  val springTx = "org.springframework" % "spring-tx" % Versions.spring
  val springWeb = "org.springframework" % "spring-web" % Versions.spring
  val springWebmvc = "org.springframework" % "spring-webmvc" % Versions.spring
  depOverrides = depOverrides ++ Set(springAop, springAsm, springAspects, springBeans, springContext, springContextSupport,
    springCore, springExpression, springInstrument, springJdbc, springJms, springOrm, springOxm, springTest, springTx,
    springWeb, springWebmvc)

  val springIntegrationCore = "org.springframework.integration" % "spring-integration-core" % Versions.springIntegration
  val springIntegrationEvent = "org.springframework.integration" % "spring-integration-event" % Versions.springIntegration
  val springIntegrationFile = "org.springframework.integration" % "spring-integration-file" % Versions.springIntegration
  val springIntegrationHttp = "org.springframework.integration" % "spring-integration-http" % Versions.springIntegration
  val springIntegrationJms = "org.springframework.integration" % "spring-integration-jms" % Versions.springIntegration
  val springIntegrationMail = "org.springframework.integration" % "spring-integration-mail" % Versions.springIntegration
  val springIntegrationRmi = "org.springframework.integration" % "spring-integration-rmi" % Versions.springIntegration
  val springIntegrationSecurity = "org.springframework.integration" % "spring-integration-security" % Versions.springIntegration
  val springIntegrationStream = "org.springframework.integration" % "spring-integration-stream" % Versions.springIntegration
  val springIntegrationWs = "org.springframework.integration" % "spring-integration-ws" % Versions.springIntegration
  val springIntegrationXml = "org.springframework.integration" % "spring-integration-xml" % Versions.springIntegration
  depOverrides = depOverrides ++ Set(springIntegrationCore, springIntegrationEvent, springIntegrationFile, springIntegrationHttp,
    springIntegrationJms, springIntegrationMail, springIntegrationRmi, springIntegrationSecurity, springIntegrationStream,
    springIntegrationWs, springIntegrationXml)

  val springSecurityAcl = "org.springframework.security" % "spring-security-acl" % Versions.springSecurity
  val springSecurityCas = "org.springframework.security" % "spring-security-cas" % Versions.springSecurity
  val springSecurityConfig = "org.springframework.security" % "spring-security-config" % Versions.springSecurity
  val springSecurityCore = "org.springframework.security" % "spring-security-core" % Versions.springSecurity
  val springSecurityCrypto = "org.springframework.security" % "spring-security-crypto" % Versions.springSecurity
  val springSecurityLdap = "org.springframework.security" % "spring-security-ldap" % Versions.springSecurity
  val springSecurityOpenId = "org.springframework.security" % "spring-security-openid" % Versions.springSecurity
  val springSecurityWeb = "org.springframework.security" % "spring-security-web" % Versions.springSecurity
  depOverrides = depOverrides ++ Set(springSecurityAcl, springSecurityCas, springSecurityConfig, springSecurityCore,
    springSecurityCrypto, springSecurityLdap, springSecurityOpenId, springSecurityWeb)

  val springSecurityOauth2 = "org.springframework.security.oauth" % "spring-security-oauth2" % Versions.springSecurityOauth
  depOverrides = depOverrides ++ Set(springSecurityOauth2)

  val testng = "org.testng" % "testng" % "6.8.8"
  depOverrides = depOverrides ++ Set(testng)

  val snakeYaml = "org.yaml" % "snakeyaml" % "1.13"
  depOverrides = depOverrides ++ Set(snakeYaml)

  val oldStaxApi = "stax" % "stax-api" % "1.0.1"
  depOverrides = depOverrides ++ Set(oldStaxApi)

  val taglibsStandard = "taglibs" % "standard" % "1.1.2"
  depOverrides = depOverrides ++ Set(taglibsStandard)

  val xalan = "xalan" % "xalan" % "2.7.1"
  depOverrides = depOverrides ++ Set(xalan)

  val xerces = "xerces" % "xerces" % "2.4.0"
  val xercesImpl = "xerces" % "xercesImpl" % "2.11.0"
  depOverrides = depOverrides ++ Set(xerces, xercesImpl)

  val xmlApis = "xml-apis" % "xml-apis" % "1.4.01"
  depOverrides = depOverrides ++ Set(xmlApis)

  val xmlunit = "xmlunit" % "xmlunit" % "1.5"
  depOverrides = depOverrides ++ Set(xmlunit)

  val xom = "xom" % "xom" % "1.2.5"
  depOverrides = depOverrides ++ Set(xom)

  val xpp3min = "xpp3_min" % "xpp3_min" % "1.1.4c"
  depOverrides = depOverrides ++ Set(xpp3min)

  val soaRsDependencies = Seq(scalaLibrary, logbackClassic % "runtime", slf4jApi, metricsAnnotation, metricsCore % "runtime",
    metricsHealthchecks % "runtime", metricsJvm % "runtime", metricsLogback % "runtime", metricsServlet % "runtime",
    metricsServlets % "runtime")

  val soaModelDependencies = Seq(scalaLibrary, javaxPersistence, validationApi, hibernateValidator)

  val playDependencies = Seq()
}

object Plugins {
  import Dependencies._

  // IDEs
  val sbtEclipse = "com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.4.0"
  val sbtIdea = "com.github.mpeltonen" % "sbt-idea" % "1.6.0"
  val sbtNetbeans = "org.netbeans" %% "sbt-netbeans-plugin" % "0.1.4"
  val sbtSublime = "com.orrsella" % "sbt-sublime" % "1.0.9"

  // Web
  val sbtWeb = "com.earldouglas" % "xsbt-web-plugin" % "0.9.0"
  val sbtCloudbees = "eu.getintheloop" %% "sbt-cloudbees-plugin" % "0.4.0"

  // Test
  val sbtCucumber = "templemore" % "sbt-cucumber-plugin" % "0.8.0"
  val sbtMultiJvm = "com.typesafe.sbt" % "sbt-multi-jvm" % "0.3.8"
  val sbtTestng = "de.johoop" % "sbt-testng-plugin" % "3.0.0"

  // Static Code Analysis
  val cpd4sbt = "de.johoop" % "cpd4sbt" % "1.1.4"
  val findbugs4sbt = "de.johoop" % "findbugs4sbt" % "1.3.0"
  val scalastyleSbt = "org.scalastyle" %% "scalastyle-sbt-plugin" % "0.4.0"
  val sbtStats = "com.orrsella" % "sbt-stats" % "1.0.5"

  // One Jar
  val sbtAssembly = "com.eed3si9n" % "sbt-assembly" % "0.11.2"
  val sbtAppbundle = "de.sciss" % "sbt-appbundle" % "1.0.1"
  val sbtOnejar = "org.scala-sbt.plugins" % "sbt-onejar" % "0.8"

  // Frontend Development
  val coffescriptSbt = "me.lessis" % "coffeescripted-sbt" % "0.2.3"
  val lessSbt = "me.lessis" % "less-sbt" % "0.2.2"
  val sbtStyles = "com.github.btd" %% "sbt-styles-plugin" % "0.0.3"
  val sbtEmberjs = "com.github.stefri" % "sbt-emberjs" % "0.4"
  val sbtYuiCompressor = "in.drajit.sbt" % "sbt-yui-compressor" % "0.2.0"
  val sbtRequirejs = "org.scalatra.requirejs" % "sbt-requirejs" % "0.0.3"
  val sbtVaadin = "org.vaadin.sbt" % "sbt-vaadin-plugin" % "1.0.0"

  // Release
  val sbtNative = "com.typesafe.sbt" % "sbt-native-packager" % "0.7.0-RC2"
  val sbtStartScript = "com.typesafe.sbt" % "sbt-start-script" % "0.10.0"
  val sbtPack = "org.xerial.sbt" % "sbt-pack" % "0.5.1"
  val sbtRelease = "com.github.gseitz" % "sbt-release" % "0.8.3"
  val aetherDeploy = "no.arktekk.sbt" % "aether-deploy" % "0.11"

  // System
  val sbtGit = "com.typesafe.sbt" % "sbt-git" % "0.6.2"

  // Code Generator
  val sbtXjc = "org.scala-sbt.plugins" % "sbt-xjc" % "0.5"
  val sbtThrift = "com.github.bigtoast" % "sbt-thrift" % "0.6"
  val sbtAntlr = "com.github.stefri" % "sbt-antlr" % "0.5"
  val sbtAntlr4 = "com.simplytyped" % "sbt-antlr4" % "0.7.1"
  val sbtAvro = "com.cavorite" % "sbt-avro" % "0.3.2"
  val sbtProtobuf = "com.github.gseitz" % "sbt-protobuf" % "0.3.2"
  val sbtScalabuff = "com.github.sbt" %% "sbt-scalabuff" % "0.2"
  val sbtFmpp = "com.github.sbt" %% "sbt-fmpp" % "0.3"

  // Database
  val sbtDbdeploy = "mrken" %% "sbt-dbdeploy" % "0.1"
  val sbtLiquibase = "com.github.bigtoast" % "sbt-liquibase" % "0.5"
  val sbtFlyaway = "org.flywaydb" % "flyway-sbt" % "3.0"

  // Documentation
  val sbtSite = "com.typesafe.sbt" % "sbt-site" % "0.7.2"

  // Library Dependency
  val sbtDependencyGraph = "net.virtual-void" % "sbt-dependency-graph" % "0.7.4"
  val sbtLock = "com.github.tkawachi" % "sbt-lock" % "0.1.1"
  val sbtUpdates = "com.timushev.sbt" % "sbt-updates" % "0.1.5"
  val sbtDirtyMoney = "com.eed3si9n" % "sbt-dirty-money" % "0.1.0"
  val lsSbt = "me.lessis" % "ls-sbt" % "0.1.3"

  // Utility
  val sbtAboutPlugins = "com.github.jozic" % "sbt-about-plugins" % "0.1.0"
  val sbtBuildinfo = "com.eed3si9n" % "sbt-buildinfo" % "0.3.1"

  // Code Coverage
  val scct = "ch.craven" %% "scct-plugin" % "0.2"
  val sbtScoverage = "org.scoverage" %% "sbt-scoverage" % "0.98.2"
  val jacoco4sbt = "de.johoop" % "jacoco4sbt" % "2.1.4"

  // Android
  val sbtAndroid = "org.scala-sbt" % "sbt-android-plugin" % "0.6.2"
  val androidSdk = "com.hanhuy.sbt" % "android-sdk-plugin" % "1.2.14"

  // Build Interoperability
  val ant4Sbt = "de.johoop" % "ant4sbt" % "1.1.2"

  // OSGI
  val sbtOsgi = "com.typesafe.sbt" % "sbt-osgi" % "0.7.0"

  // Play
  val play = "com.typesafe.play" % "sbt-plugin" % Versions.play
}

object Settings {

  import Dependencies._
  import Resolvers._

  val commonSettings = Seq(
    organizationName := "Baleio Inc.",
    organizationHomepage := Some(url("http://www.bale.io")),
    scalaVersion := Versions.scala,
    resolvers := allResolvers,
    conflictManager := ConflictManager.strict,
    exportJars := true,
    autoScalaLibrary := false,
    crossPaths := false,
    dependencyOverrides ++= depOverrides,
    scalacOptions ++= Seq("-encoding", "UTF-8", "-deprecation", "-unchecked", "-feature"),
    scalacOptions in(Compile, doc) ++= Seq("-external-urls:scala=http://www.scala-lang.org/api/current/", "-no-link-warnings"),
    javacOptions ++= Seq("-encoding", "UTF-8", "-source", Versions.java, "-target", Versions.java, "-Xlint:all"),
    javacOptions in(Compile, doc) ++= Seq("-external-urls:java=http://www.scala-lang.org/api/current/", "-no-link-warnings"),
    publishMavenStyle := true,
    publishTo <<= version {
      (v: String) =>
        if (v.trim.endsWith("SNAPSHOT"))
          Some(snapshots)
        else
          Some(releases)
    },
    credentials += Credentials(Path.userHome / ".sbt" / ".auth-baleio"))

  def SOAProject(name : String) = (
      Project(name, file(name))
      settings(commonSettings:_*)
  )

}

redpajama_set_name: RedPajamaGithub