-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathbuild.gradle
More file actions
115 lines (101 loc) · 2.98 KB
/
build.gradle
File metadata and controls
115 lines (101 loc) · 2.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
buildscript {
dependencies {
classpath files('gradle/gradle-witness.jar')
}
}
apply plugin: 'java'
apply plugin: 'witness'
apply plugin: 'maven-publish'
compileJava {
sourceCompatibility = 1.7
targetCompatibility = 1.7
}
version = "0.5.3"
repositories {
mavenLocal()
maven { url "http://4thline.org/m2" }
maven { url 'https://mvn.freenetproject.org' }
jcenter()
}
configurations {
extraLibs
}
dependencies {
compile group: 'org.freenetproject', name: 'fred', version: 'build+'
}
def gitrev
task buildInfo {
try {
def cmd = "git describe --always --abbrev=4 --dirty"
def proc = cmd.execute()
gitrev = proc.text.trim()
} catch (java.io.IOException e) {
gitrev = "@unknown@"
}
}
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.BasicFileAttributes;
Date getMTime(String file) {
return new Date(Files.readAttributes(Paths.get(file), BasicFileAttributes.class).lastModifiedTime().toMillis());
}
jar {
manifest {
attributes 'Plugin-Main-Class': 'plugins.KeyUtils.KeyUtilsPlugin',
'Required-Node-Version': '1486',
'Implementation-Version': version,
'Built-By': System.getProperty('user.name'),
'Built-Date': getMTime("src/main/java/plugins/KeyUtils/Version.java"),
'Built-JDK': System.getProperty('java.version')
}
from (configurations.extraLibs.collect { it.isDirectory() ? it : zipTree(it) }) {
exclude "META-INF/*.SF"
exclude "META-INF/*.DSA"
exclude "META-INF/*.RSA"
}
preserveFileTimestamps = false
reproducibleFileOrder = true
duplicatesStrategy = "exclude"
archiveName = 'freenet-KeyUtils.jar'
}
def jars = []
gradle.addListener(new TaskExecutionListener() {
void afterExecute(Task task, TaskState state) {
if(task in AbstractArchiveTask) {
jars << task.outputs.files.singleFile
}
}
void beforeExecute(Task task) { }
})
gradle.addBuildListener(new BuildAdapter() {
void buildFinished(BuildResult result) {
if(jars) {
def hash = {
File file -> def sha256 = java.security.MessageDigest.getInstance('SHA-256')
file.eachByte(1024 * 4) { buffer, len -> sha256.update(buffer, 0, len) }
println "SHA-256 of ${file.name}: ${sha256.digest().encodeHex().toString()}"
}
jars.each { hash(it) }
}
}
})
publishing {
publications {
mavenJava(MavenPublication) {
groupId 'org.freenetproject.plugins'
artifactId "KeyUtils"
version version
from components.java
}
}
repositories {
maven {
url "s3://mvn.freenetproject.org/"
credentials(AwsCredentials) {
accessKey System.getenv('AWS_ACCESS_KEY_ID')
secretKey System.getenv('AWS_SECRET_ACCESS_KEY')
}
}
}
}