Skip to content

Instantly share code, notes, and snippets.

@Unh0lyTigg
Created July 20, 2014 11:25
Show Gist options
  • Save Unh0lyTigg/cb5f6d43e303b1da4adc to your computer and use it in GitHub Desktop.
Save Unh0lyTigg/cb5f6d43e303b1da4adc to your computer and use it in GitHub Desktop.
custom source attachment for CBs mods
configurations {
attachThisSource
}
dependencies {
compile 'codechicken:CodeChickenCore:1.7.10-1.0.2.11:dev'
compile 'codechicken:CodeChickenLib:1.7.10-1.1.1.95:dev'
compile 'codechicken:ForgeMultipart:1.7.10-1.1.0.297:dev'
compile 'codechicken:NotEnoughItems:1.7.10-1.0.2.28:dev'
attachThisSource 'codechicken:CodeChickenCore:1.7.10-1.0.2.11:src'
attachThisSource 'codechicken:CodeChickenLib:1.7.10-1.1.1.95:src'
attachThisSource 'codechicken:ForgeMultipart:1.7.10-1.1.0.297:src'
attachThisSource 'codechicken:NotEnoughItems:1.7.10-1.0.2.28:src'
}
def loadSourcePaths() {
def result = new HashMap<String, String>()
configurations.attachThisSource.each {
def depFile = file(it)
def filename = depFile.getName()
def depName = filename.substring(0, filename.indexOf('-'))
println depName
result.put(depName, it)
}
result
}
eclipse.classpath.file {
withXml {
def sourcePaths = loadSourcePaths()
def root = it.asNode()
root.children().each { child ->
def attr = child.attributes()
if ('lib'.equals(attr.get('kind'))) {
def path = attr.get('path')
def isChicken = path.contains('codechicken') // modify this for what you need!
if (isChicken) {
def pathFile = file(path)
def filename = pathFile.getName()
def dep = filename.substring(0, filename.indexOf('-'))
def srcPath = sourcePaths.get(dep)
attr.put('sourcepath', srcPath)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment