Skip to content

Commit

Permalink
remove maven plugin
Browse files Browse the repository at this point in the history
configure publishing with maven-publish plugin
fix artifact name in Readme.md
  • Loading branch information
cstuht committed May 21, 2020
1 parent b752b16 commit 44968f1
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 59 deletions.
8 changes: 4 additions & 4 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ _build.gradle_

```$groovy
dependencies {
testImplementation 'de.neuland-bfi:assertj-logging-log4j2:0.1'
testImplementation 'de.neuland-bfi:assertj-logging-log4j:0.1'
}
```

Expand All @@ -34,7 +34,7 @@ _pom.xml_
```$xml
<dependency>
<groupId>de.neuland-bfi</groupId>
<artifactId>assertj-logging-log4j2</artifactId>
<artifactId>assertj-logging-log4j</artifactId>
<version>0.1</version>
<scope>test</scope>
</dependency>
Expand Down Expand Up @@ -63,13 +63,13 @@ public class LoggingSourceTest {
@Test
public void shouldCaptureLogging() {
// given
String message = "Error Message";
String expectedMessage = "Error Message";

// when
new LoggingSource().doSomethingThatLogsErrorMessage();

// then
assertThat(logging).hasErrorMessage(message);
assertThat(logging).hasErrorMessage(expectedMessage);
}
}
```
Expand Down
120 changes: 65 additions & 55 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import javax.naming.ConfigurationException

ext {
junitVersion = '4.12'
assertjVersion = '3.13.2'
Expand All @@ -6,8 +8,9 @@ ext {
log4j2Version = '2.12.1'
logbackVersion = '1.2.3'

ossrhUsername = 'set via .gradle/gradle.properties'
ossrhPassword = 'set via .gradle/gradle.properties'
isReleaseVersion = !version.endsWith('SNAPSHOT')
sonatypeUsername = project.findProperty('sonatype.username')
sonatypePassword = project.findProperty('sonatype.password')
}

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

apply plugin: 'java-library'
apply plugin: 'maven-publish'
apply plugin: 'maven'
apply plugin: 'signing'

compileJava {
Expand All @@ -45,84 +47,92 @@ subprojects {
testAnnotationProcessor "org.projectlombok:lombok:${lombokVersion}"
}

java {
withSourcesJar()
withJavadocJar()
}
if (it.name != 'assertj-logging-core') {
dependencies {
api project(':assertj-logging-core')

artifacts {
archives javadocJar, sourcesJar
testImplementation project(':assertj-logging-core').sourceSets.test.output
}
}

signing {
sign configurations.archives
java {
withSourcesJar()
withJavadocJar()
}

publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}

uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }

repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}

snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}

pom.project {
name 'AssertJ Logging'
packaging 'jar'
// optionally artifactId can be defined here
description """\
assertj-logging's intention is to provide an easy way to unit test expected logging
for different logging implementations with JUnit 4 AssertJ.""".stripIndent()
url 'http://www.example.com/example-application'

scm {
connection 'https://github.com/neuland/assertj-logging.git'
developerConnection 'https://github.com/neuland/assertj-logging.git'
url 'https://github.com/neuland/assertj-logging'
}

pom {
name = 'AssertJ Logging'
description = 'Logging Assertions for JUnit 4 and AssertJ'
url = 'https://github.com/neuland/assertj-logging'
licenses {
license {
name 'The Apache License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
name = 'Apache License, Version 2.0'
url = 'https://www.apache.org/licenses/LICENSE-2.0.txt'
}
}

developers {
developer {
id 'c.stuht'
name 'Christian Stuht'
email '[email protected]'
id = 'c.stuht'
name = 'Christian Stuht'
email = '[email protected]'
}
developer {
id 'a.grimm'
name 'Achim Grimm'
email '[email protected]'
id = 'a.grimm'
name = 'Achim Grimm'
email = '[email protected]'
}
}
scm {
connection = 'scm:git:https://github.com/neuland/assertj-logging.git'
developerConnection = 'scm:git:https://github.com/neuland/assertj-logging.git'
url = 'scm:git:https://github.com/neuland/assertj-logging.git'
}
issueManagement {
system = 'GitHub'
url = 'https://github.com/neuland/assertj-logging/issues'
}
// distributionManagement {
// downloadUrl = 'https://github.com/neuland/assertj-logging/releases'
// }
}
}
}
repositories {
maven {
name = 'Sonatype'
if (isReleaseVersion) {
url "https://oss.sonatype.org/service/local/staging/deploy/maven2"
} else {
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
credentials {
username sonatypeUsername
password sonatypePassword
}
}
}
}

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

testImplementation project(':assertj-logging-core').sourceSets.test.output
tasks.withType(PublishToMavenRepository) {
doFirst {
if (!sonatypeUsername) {
throw new ConfigurationException(
'Please set the Sonatype username with project property "sonatype.username"')
}
if (!sonatypePassword) {
throw new ConfigurationException(
'Please set the Sonatype password with project property "sonatype.password"')
}
}
}
}
Expand Down

0 comments on commit 44968f1

Please sign in to comment.