Skip to content

Commit 0da9088

Browse files
authored
Build empty jars for hamcrest-core and -library. (#236)
Existing maven builds that depend upon either `hamcrest-core-1.3.jar` or `hamcrest-library.jar` will not upgrade their version for a pom-only artifact. This change re-introduces a jar file for -core and -library, but with no real classes. This allows Maven builds to correctly detect the latest version of the jar. The transitive dependency on `hamcrest.jar` brings in the latest version of the classes that were previously in both `hamcrest-core.jar` or `hamcrest-library.jar`.
1 parent 50199a7 commit 0da9088

File tree

164 files changed

+102
-47
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

164 files changed

+102
-47
lines changed

build.gradle

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ version = "2.1-SNAPSHOT"
77

88
subprojects {
99
apply plugin: 'java-library'
10-
apply plugin: 'osgi'
1110

1211
sourceCompatibility = JavaVersion.VERSION_1_7
1312
targetCompatibility = JavaVersion.VERSION_1_7
14-
13+
14+
group = rootProject.group
1515
version = rootProject.version
1616

1717
repositories {
@@ -24,19 +24,6 @@ subprojects {
2424
}
2525
}
2626

27-
jar {
28-
manifest {
29-
attributes 'Implementation-Title': project.name,
30-
'Implementation-Vendor': 'hamcrest.org',
31-
'Implementation-Version': version,
32-
'Automatic-Module-Name': 'org.hamcrest'
33-
instruction 'Import-Package', '''javax.xml.namespace; resolution:=optional,
34-
javax.xml.xpath; resolution:=optional,
35-
org.w3c.dom; resolution:=optional,
36-
*'''
37-
}
38-
}
39-
4027
task sourcesJar(type: Jar) {
4128
classifier = 'sources'
4229
from sourceSets.main.allSource
@@ -83,13 +70,6 @@ def pomConfigurationFor(String pomName, String pomDescription) {
8370
}
8471
}
8572

86-
def appendDependency(Object dependencies, String artifactId) {
87-
def dependency = dependencies.appendNode('dependency')
88-
dependency.appendNode('groupId', 'org.hamcrest')
89-
dependency.appendNode('artifactId', artifactId)
90-
dependency.appendNode('version', rootProject.version)
91-
}
92-
9373
def publishToOssrh = project.hasProperty('ossrhUsername') && project.hasProperty('ossrhPassword')
9474

9575
publishing {
@@ -105,26 +85,26 @@ publishing {
10585
'Core API and libraries of hamcrest matcher framework.')
10686
}
10787

88+
def hamcrestCoreProject = project(':hamcrest-core')
10889
hamcrestCore(MavenPublication) {
109-
artifactId 'hamcrest-core'
90+
from hamcrestCoreProject.components.java
91+
artifactId hamcrestCoreProject.name
92+
artifact hamcrestCoreProject.sourcesJar
93+
artifact hamcrestCoreProject.javadocJar
11094
pom pomConfigurationFor(
11195
'Hamcrest Core',
11296
'Core Hamcrest API - deprecated, please use "hamcrest" instead')
113-
pom.withXml {
114-
def dependencies = asNode().appendNode('dependencies')
115-
appendDependency(dependencies, 'hamcrest')
116-
}
11797
}
11898

99+
def hamcrestLibraryProject = project(':hamcrest-library')
119100
hamcrestLibrary(MavenPublication) {
120-
artifactId 'hamcrest-library'
101+
from hamcrestLibraryProject.components.java
102+
artifactId hamcrestLibraryProject.name
103+
artifact hamcrestLibraryProject.sourcesJar
104+
artifact hamcrestLibraryProject.javadocJar
121105
pom pomConfigurationFor(
122106
'Hamcrest Library',
123107
'A library of Hamcrest matchers - deprecated, please use "hamcrest" instead')
124-
pom.withXml {
125-
def dependencies = asNode().appendNode('dependencies')
126-
appendDependency(dependencies, 'hamcrest-core')
127-
}
128108
}
129109
}
130110
repositories {

hamcrest-core/hamcrest-core.gradle

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
dependencies {
2+
api project(':hamcrest')
3+
}
4+
5+
jar {
6+
manifest {
7+
attributes 'Implementation-Title': project.name,
8+
'Implementation-Vendor': 'hamcrest.org',
9+
'Implementation-Version': version,
10+
'Automatic-Module-Name': 'org.hamcrest'
11+
}
12+
}
13+
14+
javadoc {
15+
title = "Hamcrest Core $version API"
16+
options.showFromPackage()
17+
options.showFromPrivate()
18+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package org.hamcrest;
2+
3+
/**
4+
* All the classes in <code>hamcrest-core.jar</code> have moved to
5+
* <code>hamcrest.jar</code>. Please use that dependency instead.
6+
*/
7+
@Deprecated
8+
class HamcrestCoreIsDeprecated {
9+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/**
2+
* All classes in <code>hamcrest-core.jar</code> have been migrated to
3+
* <code>hamcrest.jar</code>. Please use that dependency instead.
4+
*/
5+
package org.hamcrest;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Hamcrest Core
2+
=============
3+
4+
All the classes in hamcrest-core.jar and hamcrest-library.jar has moved
5+
into hamcrest.jar. Please update your dependencies.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
dependencies {
2+
api project(':hamcrest-core')
3+
}
4+
5+
jar {
6+
manifest {
7+
attributes 'Implementation-Title': project.name,
8+
'Implementation-Vendor': 'hamcrest.org',
9+
'Implementation-Version': version,
10+
'Automatic-Module-Name': 'org.hamcrest'
11+
}
12+
}
13+
14+
javadoc {
15+
title = "Hamcrest Library $version API"
16+
options.showFromPackage()
17+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package org.hamcrest;
2+
3+
/**
4+
* All the classes in <code>hamcrest-library.jar</code> have moved to
5+
* <code>hamcrest.jar</code>. Please use that dependency instead.
6+
*/
7+
@Deprecated
8+
class HamcrestLibraryIsDeprecated {
9+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/**
2+
* All classes in <code>hamcrest-library.jar</code> have been migrated to
3+
* <code>hamcrest.jar</code>. Please use that dependency instead.
4+
*/
5+
package org.hamcrest;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Hamcrest Library
2+
================
3+
4+
All the classes in hamcrest-core.jar and hamcrest-library.jar has moved
5+
into hamcrest.jar. Please update your dependencies.

hamcrest/hamcrest.gradle

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
version = rootProject.version
1+
apply plugin: 'osgi'
22

3-
sourceSets {
4-
main {
5-
java {
6-
srcDirs rootProject.file('hamcrest-core/src/main/java'),
7-
rootProject.file('hamcrest-library/src/main/java')
8-
}
9-
}
10-
test {
11-
java {
12-
srcDirs rootProject.file('hamcrest-core/src/test/java'),
13-
rootProject.file('hamcrest-library/src/test/java')
14-
}
15-
}
16-
}
3+
version = rootProject.version
174

185
dependencies {
196
testImplementation(group: 'junit', name: 'junit', version: '4.12') {
207
transitive = false
218
}
229
}
2310

11+
jar {
12+
manifest {
13+
attributes 'Implementation-Title': project.name,
14+
'Implementation-Vendor': 'hamcrest.org',
15+
'Implementation-Version': version,
16+
'Automatic-Module-Name': 'org.hamcrest'
17+
instruction 'Import-Package', '''javax.xml.namespace; resolution:=optional,
18+
javax.xml.xpath; resolution:=optional,
19+
org.w3c.dom; resolution:=optional,
20+
*'''
21+
}
22+
}
23+
2424
javadoc.title = "Hamcrest $version API"

settings.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
enableFeaturePreview('STABLE_PUBLISHING')
22

33
include 'hamcrest',
4+
'hamcrest-core',
5+
'hamcrest-library',
46
'hamcrest-integration'
57

68
rootProject.name = 'JavaHamcrest'

0 commit comments

Comments
 (0)