attempt to produce an I2P plugin

pull/11/head
Zlatin Balevsky 2019-07-11 19:49:04 +01:00
parent 0de84e704b
commit fa6aea1abe
5 changed files with 152 additions and 0 deletions

View File

@ -8,3 +8,13 @@ gorm.version=7.0.2.RELEASE
sourceCompatibility=1.8
targetCompatibility=1.8
# plugin properties
author = zab@mail.i2p
signer = zab@mail.i2p
i2pVersion=0.9.41
keystorePassword=changeit
websiteURL=http://muwire.i2p
updateURLsu3=http://muwire.i2p/MuWire.su3
pack200=true

122
plug/build.gradle 100644
View File

@ -0,0 +1,122 @@
buildscript {
repositories { mavenCentral() }
dependencies {
classpath fileTree("../i2pjars") { include '*.jar' }
classpath 'gnu.getopt:java-getopt:1.0.13'
}
}
apply plugin : 'java'
dependencies {
compile project(":webui")
}
def buildDir = new File("$buildDir")
def zipDir = new File(buildDir, "zip")
def libDir = new File(zipDir, "lib")
def consoleDir = new File(zipDir, "console")
def webAppDir = new File(consoleDir, "webapps")
def keystore = new File(System.getProperty("user.home")+"/.i2p-plugin-keys/plugin-su3-keystore.ks")
String libDirPath() {
def libDir = new File("$buildDir/zip/lib")
libDir.listFiles().stream().map({
"\$PLUGIN/lib/" + it.getName()
}).collect(java.util.stream.Collectors.joining(','))
}
task pluginConfig {
doLast {
def binding = [ "version" : project.version + "-b" + project.buildNumber,
"author" : project.author,
"signer" : project.signer,
"websiteURL" : project.websiteURL,
"updateURLsu3" : project.updateURLsu3,
"i2pVersion" : project.i2pVersion ]
def templateFile = new File("$projectDir/templates/plugin.config.template")
def engine = new groovy.text.SimpleTemplateEngine()
def output = engine.createTemplate(templateFile).make(binding)
zipDir.mkdirs()
def outputFile = new File(zipDir,"plugin.config")
outputFile.text = output
}
}
task pluginDir {
dependsOn ':webui:assemble'
doLast { task ->
libDir.mkdirs()
def webapp = project(":webui")
def i2pjars = task.project.fileTree("../i2pjars").getFiles()
webapp.configurations.runtime.each {
if (!i2pjars.contains(it)) {
def dest = new File(libDir, it.getName())
java.nio.file.Files.copy(it.toPath(), dest.toPath())
}
}
webAppDir.mkdirs()
def warFile = webapp.configurations.warArtifact.getAllArtifacts().file[0]
def dest = new File(webAppDir, "MuWire.war")
java.nio.file.Files.copy(warFile.toPath(), dest.toPath())
"zip -d ${dest.toString()} *.jar".execute()
}
}
task webappConfig {
doLast {
def cPath = "webapps.MuWire.classpath=" + libDirPath()
def webappConfig = new File(consoleDir, "webapps.config")
webappConfig.text = cPath
}
}
task pack {
doLast {
if (project.pack200 == "true") {
libDir.listFiles().stream().filter( { it.getName().endsWith(".jar") } ).forEach {
println "packing $it"
def name = it.toString()
println "pack200 --no-gzip ${name}.pack $name".execute().text
it.delete()
}
} else {
println "pack200 disabled"
}
}
}
task pluginZip(type: Zip) {
archiveFileName = "MuWire.zip"
destinationDirectory = buildDir
from zipDir
}
task sign {
doLast {
def password = project.keystorePassword
if (password == "") {
println "enter your keystore password:"
def reader = new BufferedReader(new InputStreamReader(System.in))
password = reader.readLine()
}
def su3args = []
def version = project.version + "-b" + project.buildNumber
su3args << 'sign' << '-t' << '6' << '-c' << 'PLUGIN' << '-f' << '0' << '-p' << password << \
"$buildDir/MuWire.zip".toString() << "$buildDir/MuWire.su3".toString() << \
keystore.getAbsoluteFile().toString() << version << project.signer
println "now enter private key password for signer $project.signer"
net.i2p.crypto.SU3File.main(su3args.toArray(new String[0]))
}
}
webappConfig.dependsOn pluginDir
pack.dependsOn webappConfig
pluginZip.dependsOn(webappConfig,pluginConfig,pack)
sign.dependsOn pluginZip
assemble.dependsOn sign

View File

@ -0,0 +1,14 @@
name=MuWire
description=Easy Anonymous File-Sharing
license=GPLv3
version=${version}
author=${author}
signer=${signer}
websiteURL=${websiteURL}
updateURL.su3=${updateURLsu3}
min-i2p-version=${i2pVersion}
min-java-version=1.8
consoleLinkName=MuWire
consoleLinkTooltip=Anonymous File Sharing
consoleLinkURL=/MuWire
<% println "date="+System.currentTimeMillis() %>

View File

@ -5,3 +5,4 @@ include 'core'
include 'gui'
include 'cli'
include 'webui'
include 'plug'

View File

@ -30,6 +30,7 @@ configurations {
runtimeClasspath {
extendsFrom developmentOnly
}
warArtifact
}
dependencies {
@ -102,3 +103,7 @@ assets {
minifyJs = true
minifyCss = true
}
artifacts {
warArtifact war
}