Skip to content

Commit 44968f1

Browse files
committed
remove maven plugin
configure publishing with maven-publish plugin fix artifact name in Readme.md
1 parent b752b16 commit 44968f1

File tree

2 files changed

+69
-59
lines changed

2 files changed

+69
-59
lines changed

Readme.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ _build.gradle_
2323

2424
```$groovy
2525
dependencies {
26-
testImplementation 'de.neuland-bfi:assertj-logging-log4j2:0.1'
26+
testImplementation 'de.neuland-bfi:assertj-logging-log4j:0.1'
2727
}
2828
```
2929

@@ -34,7 +34,7 @@ _pom.xml_
3434
```$xml
3535
<dependency>
3636
<groupId>de.neuland-bfi</groupId>
37-
<artifactId>assertj-logging-log4j2</artifactId>
37+
<artifactId>assertj-logging-log4j</artifactId>
3838
<version>0.1</version>
3939
<scope>test</scope>
4040
</dependency>
@@ -63,13 +63,13 @@ public class LoggingSourceTest {
6363
@Test
6464
public void shouldCaptureLogging() {
6565
// given
66-
String message = "Error Message";
66+
String expectedMessage = "Error Message";
6767

6868
// when
6969
new LoggingSource().doSomethingThatLogsErrorMessage();
7070

7171
// then
72-
assertThat(logging).hasErrorMessage(message);
72+
assertThat(logging).hasErrorMessage(expectedMessage);
7373
}
7474
}
7575
```

build.gradle

Lines changed: 65 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import javax.naming.ConfigurationException
2+
13
ext {
24
junitVersion = '4.12'
35
assertjVersion = '3.13.2'
@@ -6,8 +8,9 @@ ext {
68
log4j2Version = '2.12.1'
79
logbackVersion = '1.2.3'
810

9-
ossrhUsername = 'set via .gradle/gradle.properties'
10-
ossrhPassword = 'set via .gradle/gradle.properties'
11+
isReleaseVersion = !version.endsWith('SNAPSHOT')
12+
sonatypeUsername = project.findProperty('sonatype.username')
13+
sonatypePassword = project.findProperty('sonatype.password')
1114
}
1215

1316
// 'core' must configured first, because the other modules depend on it's test output
@@ -26,7 +29,6 @@ subprojects {
2629

2730
apply plugin: 'java-library'
2831
apply plugin: 'maven-publish'
29-
apply plugin: 'maven'
3032
apply plugin: 'signing'
3133

3234
compileJava {
@@ -45,84 +47,92 @@ subprojects {
4547
testAnnotationProcessor "org.projectlombok:lombok:${lombokVersion}"
4648
}
4749

48-
java {
49-
withSourcesJar()
50-
withJavadocJar()
51-
}
50+
if (it.name != 'assertj-logging-core') {
51+
dependencies {
52+
api project(':assertj-logging-core')
5253

53-
artifacts {
54-
archives javadocJar, sourcesJar
54+
testImplementation project(':assertj-logging-core').sourceSets.test.output
55+
}
5556
}
5657

57-
signing {
58-
sign configurations.archives
58+
java {
59+
withSourcesJar()
60+
withJavadocJar()
5961
}
6062

6163
publishing {
6264
publications {
6365
mavenJava(MavenPublication) {
6466
from components.java
65-
}
66-
}
67-
}
68-
69-
uploadArchives {
70-
repositories {
71-
mavenDeployer {
72-
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
73-
74-
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
75-
authentication(userName: ossrhUsername, password: ossrhPassword)
76-
}
77-
78-
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
79-
authentication(userName: ossrhUsername, password: ossrhPassword)
80-
}
81-
82-
pom.project {
83-
name 'AssertJ Logging'
84-
packaging 'jar'
85-
// optionally artifactId can be defined here
86-
description """\
87-
assertj-logging's intention is to provide an easy way to unit test expected logging
88-
for different logging implementations with JUnit 4 AssertJ.""".stripIndent()
89-
url 'http://www.example.com/example-application'
90-
91-
scm {
92-
connection 'https://github.com/neuland/assertj-logging.git'
93-
developerConnection 'https://github.com/neuland/assertj-logging.git'
94-
url 'https://github.com/neuland/assertj-logging'
95-
}
9667

68+
pom {
69+
name = 'AssertJ Logging'
70+
description = 'Logging Assertions for JUnit 4 and AssertJ'
71+
url = 'https://github.com/neuland/assertj-logging'
9772
licenses {
9873
license {
99-
name 'The Apache License, Version 2.0'
100-
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
74+
name = 'Apache License, Version 2.0'
75+
url = 'https://www.apache.org/licenses/LICENSE-2.0.txt'
10176
}
10277
}
103-
10478
developers {
10579
developer {
106-
id 'c.stuht'
107-
name 'Christian Stuht'
108-
email 'christian.stuht@neuland-bfi.de'
80+
id = 'c.stuht'
81+
name = 'Christian Stuht'
82+
email = 'christian.stuht@neuland-bfi.de'
10983
}
11084
developer {
111-
id 'a.grimm'
112-
name 'Achim Grimm'
113-
email 'achim.grimm@neuland-bfi.de'
85+
id = 'a.grimm'
86+
name = 'Achim Grimm'
87+
email = 'achim.grimm@neuland-bfi.de'
11488
}
11589
}
90+
scm {
91+
connection = 'scm:git:https://github.com/neuland/assertj-logging.git'
92+
developerConnection = 'scm:git:https://github.com/neuland/assertj-logging.git'
93+
url = 'scm:git:https://github.com/neuland/assertj-logging.git'
94+
}
95+
issueManagement {
96+
system = 'GitHub'
97+
url = 'https://github.com/neuland/assertj-logging/issues'
98+
}
99+
// distributionManagement {
100+
// downloadUrl = 'https://github.com/neuland/assertj-logging/releases'
101+
// }
102+
}
103+
}
104+
}
105+
repositories {
106+
maven {
107+
name = 'Sonatype'
108+
if (isReleaseVersion) {
109+
url "https://oss.sonatype.org/service/local/staging/deploy/maven2"
110+
} else {
111+
url 'https://oss.sonatype.org/content/repositories/snapshots/'
112+
}
113+
credentials {
114+
username sonatypeUsername
115+
password sonatypePassword
116116
}
117117
}
118118
}
119119
}
120120

121-
if (it.name != 'assertj-logging-core') {
122-
dependencies {
123-
api project(':assertj-logging-core')
121+
signing {
122+
required { isReleaseVersion && gradle.taskGraph.hasTask('publish') }
123+
sign publishing.publications.mavenJava
124+
}
124125

125-
testImplementation project(':assertj-logging-core').sourceSets.test.output
126+
tasks.withType(PublishToMavenRepository) {
127+
doFirst {
128+
if (!sonatypeUsername) {
129+
throw new ConfigurationException(
130+
'Please set the Sonatype username with project property "sonatype.username"')
131+
}
132+
if (!sonatypePassword) {
133+
throw new ConfigurationException(
134+
'Please set the Sonatype password with project property "sonatype.password"')
135+
}
126136
}
127137
}
128138
}

0 commit comments

Comments
 (0)