Skip to content

Commit 0a5fedc

Browse files
committed
Zip: Some deep cleanup and polishing
* Upgrade to Gradle-2.5, SI-4.2.4 * Remove redundant dependencies * Add `slf4j-log4j12` to avoid log noise during testing * Add `settings.gradle` to allow Artifactory Release Management * Move XSD stuff to the proper place - `org\springframework\integration\zip\config` * Get rid of manual `enum` transformation in the `Parser`: - we can't do that there because `property-placeholder` and SpEL are processed later - no reason to do that at all - `enum`s are properly converted by the SF during bean population phase * Fix `UnZipTransformer` to `delete()` file in the `finally` block after closing the `InputStream` on file
1 parent f7b3122 commit 0a5fedc

File tree

21 files changed

+170
-240
lines changed

21 files changed

+170
-240
lines changed

spring-integration-zip/README.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ If the payload is an instance of `File`, this property specifies whether to dele
6161

6262
### workDirectory
6363

64-
Set the work-directory. The work directory is used when the ZipResultType is set to ZipResultType.FILE. By default this property is set to the System temporary directory containing a sub-directory "ziptransformer".
64+
Set the work-directory. The work directory is used when the ZipResultType is set to ZipResultType.FILE.
65+
By default this property is set to the System temporary directory containing a sub-directory "ziptransformer".
6566

6667
### ZipResultType
6768

@@ -120,7 +121,8 @@ To build complete distribution including `-dist` and `-schema` zip files (result
120121

121122
# IDE Support
122123

123-
While your custom Spring Integration Adapter is initially created with SpringSource Tool Suite, you in fact end up with a Gradle-based project. As such, the created project can be imported into other IDEs as well.
124+
While your custom Spring Integration Adapter is initially created with SpringSource Tool Suite, you in fact end up with a Gradle-based project.
125+
As such, the created project can be imported into other IDEs as well.
124126

125127
## Using Spring Tool Suite
126128

@@ -155,17 +157,19 @@ Check out the [spring-integration][spring-integration tag] tag on [Stack Overflo
155157
* [Spring Integration][]
156158
* [Spring Integration Samples][]
157159
* [Spring Integration Templates][]
160+
* [Spring Integration Java DSL][]
158161
* [Spring Integration Dsl Groovy][]
159162
* [Spring Integration Dsl Scala][]
160163

161164
For more information, please also don't forget to visit the [Spring Integration][] website.
162165

163-
[Spring Integration]: https://github.com/SpringSource/spring-integration
166+
[Spring Integration]: https://github.com/spring-projects/spring-integration
164167
[spring-integration tag]: http://stackoverflow.com/questions/tagged/spring-integration
165-
[Spring Integration Samples]: https://github.com/SpringSource/spring-integration-samples
166-
[Spring Integration Templates]: https://github.com/SpringSource/spring-integration-templates/tree/master/si-sts-templates
167-
[Spring Integration Dsl Groovy]: https://github.com/SpringSource/spring-integration-dsl-groovy
168-
[Spring Integration Dsl Scala]: https://github.com/SpringSource/spring-integration-dsl-scala
168+
[Spring Integration Samples]: https://github.com/spring-projects/spring-integration-samples
169+
[Spring Integration Templates]: https://github.com/spring-projects/spring-integration-templates/tree/master/si-sts-templates
170+
[Spring Integration Java DSL]: https://github.com/spring-projects/spring-integration-java-dsl
171+
[Spring Integration Dsl Groovy]: https://github.com/spring-projects/spring-integration-dsl-groovy
172+
[Spring Integration Dsl Scala]: https://github.com/spring-projects/spring-integration-dsl-scala
169173
[Stack Overflow]: http://stackoverflow.com/faq
170174

171-
[Zip]: http://en.wikipedia.org/wiki/Zip_%28file_format%29
175+
[Zip]: http://en.wikipedia.org/wiki/Zip_%28file_format%29

spring-integration-zip/build.gradle

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,24 @@ description = 'Spring Integration Zip Adapter'
22

33
buildscript {
44
repositories {
5-
maven { url 'https://repo.springsource.org/plugins-snapshot' }
5+
maven { url 'https://repo.spring.io/plugins-release' }
66
}
77
}
88

99
apply plugin: 'java'
1010
apply from: "${rootProject.projectDir}/publish-maven.gradle"
1111
apply plugin: 'eclipse'
1212
apply plugin: 'idea'
13+
apply plugin: 'jacoco'
1314

1415
group = 'org.springframework.integration'
1516

1617
repositories {
17-
maven { url 'http://repo.springsource.org/libs-milestone' }
18-
maven { url 'http://repo.springsource.org/plugins-release' }
18+
if (version.endsWith('BUILD-SNAPSHOT')) {
19+
maven { url 'https://repo.spring.io/libs-snapshot' }
20+
}
21+
maven { url 'https://repo.spring.io/libs-milestone' }
22+
mavenCentral()
1923
}
2024

2125
sourceCompatibility=1.6
@@ -30,12 +34,9 @@ ext {
3034
linkScmConnection = 'https://github.com/spring-projects/spring-integration-extensions.git'
3135
linkScmDevConnection = 'git@github.com:spring-projects/spring-integration-extensions.git'
3236

33-
junitVersion = '4.11'
34-
log4jVersion = '1.2.17'
35-
mockitoVersion = '1.9.5'
36-
springVersion = '4.0.7.RELEASE'
37-
springIntegrationVersion = '4.2.0.M1'
38-
ztZipVersion = '1.8'
37+
slf4jVersion = "1.7.13"
38+
springIntegrationVersion = '4.2.4.RELEASE'
39+
ztZipVersion = '1.9'
3940

4041
idPrefix = 'zip'
4142
}
@@ -54,33 +55,40 @@ sourceSets {
5455
}
5556
}
5657

57-
// See http://www.gradle.org/docs/current/userguide/dependency_management.html#sub:configurations
58-
// and http://www.gradle.org/docs/current/dsl/org.gradle.api.artifacts.ConfigurationContainer.html
59-
configurations {
60-
jacoco //Configuration Group used by Sonar to provide Code Coverage using JaCoCo
58+
jacoco {
59+
toolVersion = "0.7.2.201409121644"
6160
}
6261

6362
dependencies {
6463
compile "org.springframework.integration:spring-integration-core:$springIntegrationVersion"
6564
compile "org.springframework.integration:spring-integration-file:$springIntegrationVersion"
6665
compile "org.zeroturnaround:zt-zip:$ztZipVersion"
66+
6767
testCompile "org.springframework.integration:spring-integration-test:$springIntegrationVersion"
68-
testCompile "junit:junit:$junitVersion"
69-
testCompile "log4j:log4j:$log4jVersion"
70-
testCompile "org.mockito:mockito-all:$mockitoVersion"
71-
testCompile "org.springframework:spring-test:$springVersion"
72-
jacoco group: "org.jacoco", name: "org.jacoco.agent", version: "0.7.4.201502262128", classifier: "runtime"
68+
testRuntime "org.slf4j:slf4j-log4j12:$slf4jVersion"
7369
}
7470

7571

7672
// enable all compiler warnings; individual projects may customize further
77-
ext.xLintArg = '-Xlint:all'
73+
ext.xLintArg = '-Xlint:all,-options'
7874
[compileJava, compileTestJava]*.options*.compilerArgs = [xLintArg]
7975

76+
jacocoTestReport {
77+
reports {
78+
xml.enabled false
79+
csv.enabled false
80+
html.destination "${buildDir}/reports/jacoco/html"
81+
}
82+
}
83+
8084
test {
8185
// suppress all console output during testing unless running `gradle -i`
8286
logging.captureStandardOutput(LogLevel.INFO)
83-
jvmArgs "-javaagent:${configurations.jacoco.asPath}=destfile=${buildDir}/jacoco.exec,includes=*"
87+
maxHeapSize = "1024m"
88+
jacoco {
89+
append = false
90+
destinationFile = file("$buildDir/jacoco.exec")
91+
}
8492
}
8593

8694
task sourcesJar(type: Jar) {
@@ -98,6 +106,8 @@ artifacts {
98106
archives javadocJar
99107
}
100108

109+
build.dependsOn jacocoTestReport
110+
101111
apply plugin: 'sonar-runner'
102112

103113
sonarRunner {
@@ -136,19 +146,18 @@ task schemaZip(type: Zip) {
136146
def shortName = idPrefix.replaceFirst("${idPrefix}-", '')
137147

138148
project.sourceSets.main.resources.find {
139-
it.path.endsWith('META-INF/spring.schemas')
149+
it.path.endsWith("META-INF${File.separator}spring.schemas")
140150
}?.withInputStream { schemas.load(it) }
141151

142152
for (def key : schemas.keySet()) {
143153
File xsdFile = project.sourceSets.main.resources.find {
144-
it.path.endsWith(schemas.get(key))
154+
it.path.replaceAll('\\\\', '/').endsWith(schemas.get(key))
145155
}
146156
assert xsdFile != null
147157
into ("integration/${shortName}") {
148158
from xsdFile.path
149159
}
150160
}
151-
152161
}
153162

154163
task docsZip(type: Zip) {
@@ -239,5 +248,6 @@ task dist(dependsOn: assemble) {
239248

240249
task wrapper(type: Wrapper) {
241250
description = 'Generates gradlew[.bat] scripts'
242-
gradleVersion = '2.4'
251+
gradleVersion = '2.5'
252+
distributionUrl = "http://services.gradle.org/distributions/gradle-${gradleVersion}-all.zip"
243253
}
Binary file not shown.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Tue May 12 22:21:08 EDT 2015
1+
#Thu Jan 07 20:03:45 EST 2016
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-2.3-bin.zip
6+
distributionUrl=http\://services.gradle.org/distributions/gradle-2.5-all.zip

spring-integration-zip/publish-maven.gradle

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ def customizePom(pom, gradleProject) {
3131
generatedPom.project {
3232
name = gradleProject.description
3333
description = gradleProject.description
34-
url = 'https://github.com/SpringSource/spring-integration-extensions'
34+
url = 'https://github.com/spring-projects/spring-integration-extensions'
3535
organization {
36-
name = 'SpringSource'
37-
url = 'http://springsource.org'
36+
name = 'SpringIO'
37+
url = 'http://spring.io'
3838
}
3939
licenses {
4040
license {
@@ -44,16 +44,16 @@ def customizePom(pom, gradleProject) {
4444
}
4545
}
4646
scm {
47-
url = 'https://github.com/SpringSource/spring-integration-extensions'
48-
connection = 'scm:git:git://github.com/SpringSource/spring-integration-extensions'
49-
developerConnection = 'scm:git:git://github.com/SpringSource/spring-integration-extensions'
47+
url = 'https://github.com/spring-projects/spring-integration-extensions'
48+
connection = 'scm:git:git://github.com/spring-projects/spring-integration-extensions'
49+
developerConnection = 'scm:git:git://github.com/spring-projects/spring-integration-extensions'
5050
}
5151

5252
developers {
5353
developer {
54-
id = 'not specified'
54+
id = 'ghiller'
5555
name = 'Gunnar Hillert'
56-
email = 'not specified'
56+
email = 'ghiller@pivotal.io'
5757
}
5858
}
5959
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootProject.name = 'spring-integration-zip'

spring-integration-zip/src/main/java/org/springframework/integration/zip/config/xml/AbstractZipTransformerParser.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015 the original author or authors.
2+
* Copyright 2015-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,12 +21,14 @@
2121
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
2222
import org.springframework.beans.factory.xml.ParserContext;
2323
import org.springframework.integration.config.xml.AbstractTransformerParser;
24+
import org.springframework.integration.config.xml.IntegrationNamespaceUtils;
2425
import org.springframework.util.StringUtils;
2526

2627
/**
2728
* Base class for Zip transformer parsers.
2829
*
2930
* @author Gunnar Hillert
31+
* @author Artem Bilan
3032
* @since 1.0
3133
*/
3234
public abstract class AbstractZipTransformerParser extends AbstractTransformerParser {
@@ -42,7 +44,9 @@ protected final void parseTransformer(Element element, ParserContext parserConte
4244
if (StringUtils.hasText(deleteFiles)) {
4345
builder.addPropertyValue("deleteFiles", deleteFiles);
4446
}
45-
this.postProcessTransformer(element, parserContext, builder);
47+
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "charset");
48+
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "result-type", "zipResultType");
49+
postProcessTransformer(element, parserContext, builder);
4650
}
4751

4852
/**
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015 the original author or authors.
2+
* Copyright 2015-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,18 +16,18 @@
1616

1717
package org.springframework.integration.zip.config.xml;
1818

19+
import org.w3c.dom.Element;
20+
1921
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
2022
import org.springframework.beans.factory.xml.ParserContext;
2123
import org.springframework.integration.config.xml.IntegrationNamespaceUtils;
2224
import org.springframework.integration.zip.transformer.UnZipTransformer;
23-
import org.springframework.integration.zip.transformer.ZipResultType;
24-
import org.springframework.util.StringUtils;
25-
import org.w3c.dom.Element;
2625

2726
/**
2827
* Parser for the 'unzip-transformer' element.
2928
*
3029
* @author Gunnar Hillert
30+
* @author Artem Bilan
3131
* @since 1.0
3232
*/
3333
public class UnZipTransformerParser extends AbstractZipTransformerParser {
@@ -39,27 +39,7 @@ protected String getTransformerClassName() {
3939

4040
@Override
4141
protected void postProcessTransformer(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
42-
Object source = parserContext.extractSource(element);
43-
44-
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "charset");
4542
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "expect-single-result");
46-
47-
final String resultType = element.getAttribute("result-type");
48-
49-
if (StringUtils.hasText(resultType)) {
50-
51-
final ZipResultType zipResultType = ZipResultType.convertToZipResultType(resultType);
52-
53-
if (zipResultType != null) {
54-
builder.addPropertyValue("zipResultType", zipResultType);
55-
}
56-
else {
57-
parserContext.getReaderContext().error(
58-
String.format("Unable to convert the provided result-type '%s' " +
59-
"to the respective ZipResultType enum.", resultType), source);
60-
}
61-
62-
}
6343
}
6444

6545
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015 the original author or authors.
2+
* Copyright 2015-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,18 +16,18 @@
1616

1717
package org.springframework.integration.zip.config.xml;
1818

19+
import org.w3c.dom.Element;
20+
1921
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
2022
import org.springframework.beans.factory.xml.ParserContext;
2123
import org.springframework.integration.config.xml.IntegrationNamespaceUtils;
22-
import org.springframework.integration.zip.transformer.ZipResultType;
2324
import org.springframework.integration.zip.transformer.ZipTransformer;
24-
import org.springframework.util.StringUtils;
25-
import org.w3c.dom.Element;
2625

2726
/**
2827
* Parser for the 'zip-transformer' element.
2928
*
3029
* @author Gunnar Hillert
30+
* @author Artem Bilan
3131
* @since 1.0
3232
*/
3333
public class ZipTransformerParser extends AbstractZipTransformerParser {
@@ -39,27 +39,7 @@ protected String getTransformerClassName() {
3939

4040
@Override
4141
protected void postProcessTransformer(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
42-
Object source = parserContext.extractSource(element);
43-
44-
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "charset");
4542
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "compression-level");
46-
47-
final String resultType = element.getAttribute("result-type");
48-
49-
if (StringUtils.hasText(resultType)) {
50-
51-
final ZipResultType zipResultType = ZipResultType.convertToZipResultType(resultType);
52-
53-
if (zipResultType != null) {
54-
builder.addPropertyValue("zipResultType", zipResultType);
55-
}
56-
else {
57-
parserContext.getReaderContext().error(
58-
String.format("Unable to convert the provided result-type '%s' " +
59-
"to the respective ZipResultType enum.", resultType), source);
60-
}
61-
62-
}
6343
}
6444

6545
}

0 commit comments

Comments
 (0)