Skip to content

Migrate from maven plugin to 'maven-publish' #74

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# createsend-java history

## v8.0.0 - 4 March 2022

* Migrated from deprecated gradle plugin 'Maven' to 'Maven-publish'
* Set sourceComptability to Java 1.9
* Updated sourceComptability syntax
* Replaced gradle compile dependency with 'implementation'
* Replaced all instances of deprecated ``$buildDir`` with ``layout.buildDirectory``
* Replaced ``uploadArchives`` with new ``publishing`` method
* Updated ``writePom``

## v7.0.1 - 2 December 2022

* Added support for rate limiting errors
Expand Down
136 changes: 77 additions & 59 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'eclipse'
apply plugin: 'idea'

install.dependsOn ':build'
defaultTasks 'clean', 'install'

sourceCompatibility = 1.7
version = '7.0.1'
java {
sourceCompatibility = JavaVersion.VERSION_1_9
}
version = '8.0.0-SNAPSHOT'
group = 'com.createsend'

def localMavenRepo = 'file://' + new File(System.getProperty('user.home'), '.m2/repository').absolutePath
Expand All @@ -17,14 +16,14 @@ repositories {
}

dependencies {
compile group: 'com.sun.jersey', name: 'jersey-client', version: '1.17.1'
compile group: 'com.sun.jersey', name: 'jersey-json', version: '1.17.1'
compile group: 'com.sun.jersey', 'name': 'jersey-core', version: '1.17.1'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.10.2'
compile group: 'com.fasterxml.jackson.jaxrs', name: 'jackson-jaxrs-json-provider', version: '2.10.2'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.10.2'
compile group: 'commons-codec', name: 'commons-codec', version: '1.10'
compile group: 'commons-io', name: 'commons-io', version: '2.7'
implementation group: 'com.sun.jersey', name: 'jersey-client', version: '1.17.1'
implementation group: 'com.sun.jersey', name: 'jersey-json', version: '1.17.1'
implementation group: 'com.sun.jersey', 'name': 'jersey-core', version: '1.17.1'
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.10.2'
implementation group: 'com.fasterxml.jackson.jaxrs', name: 'jackson-jaxrs-json-provider', version: '2.10.2'
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.13.4.2'
implementation group: 'commons-codec', name: 'commons-codec', version: '1.10'
implementation group: 'commons-io', name: 'commons-io', version: '2.7'
}

sourceSets {
Expand All @@ -44,63 +43,82 @@ sourceSets {
}

task copyToLib(type: Copy) {
into "$buildDir/libs"
from configurations.runtime
into layout.buildDirectory.dir("libs")
from configurations.runtimeClasspath
}

task doc(type: Javadoc) {
source = sourceSets.main.allJava
title = "createsend-java $version"
classpath = sourceSets.main.compileClasspath
destinationDir = new File(new File(buildDir, 'doc'), version)
options.version = true
source = sourceSets.main.allJava
title = "createsend-java $version"
classpath = sourceSets.main.compileClasspath
destinationDir = layout.buildDirectory.dir("doc/$version").get().asFile
options.version = true
}

uploadArchives {
repositories {
mavenDeployer {
snapshotRepository(
url: 'https://oss.sonatype.org/content/repositories/snapshots',
id: 'sonatype-nexus-snapshots') {
authentication(getAuth('sonatype-nexus-snapshots'))
}
repository(
url: 'https://oss.sonatype.org/service/local/staging/deploy/maven2/',
id: 'sonatype-nexus-staging') {
authentication(getAuth('sonatype-nexus-staging'))
}

pom {
project {
name 'createsend-java'
description 'A Java library which implements the complete functionality of the Campaign Monitor API.'
url 'http://campaignmonitor.github.io/createsend-java/'
licenses {
license {
name 'The MIT License'
url 'https://raw.github.com/campaignmonitor/createsend-java/master/LICENSE'
distribution 'repo'
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
pom {
name = 'createsend-java'
description = 'A Java library which implements the complete functionality of the Campaign Monitor API.'
url = 'http://campaignmonitor.github.io/createsend-java/'
licenses {
license {
name = 'The MIT License'
url = 'https://raw.github.com/campaignmonitor/createsend-java/master/LICENSE'
distribution = 'repo'
}
}
withXml {
def pomInclude = new XmlParser().parse(new File("pom-include.xml"))
pomInclude.children().each { child ->
asNode().append(child)
}
}
}
}
}
withXml { xml ->
new XmlParser().parse(new File("pom-include.xml")).children().each { kid -> xml.asNode().append(kid) }
}

repositories {
maven {
name = "sonatypeSnapshots"
url = "https://oss.sonatype.org/content/repositories/snapshots"
credentials {
username = getAuth('sonatype-nexus-snapshots').userName ?: ""
password = getAuth('sonatype-nexus-snapshots').password ?: ""
}
}
}

maven {
name = "sonatypeStaging"
url = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
credentials {
username = getAuth('sonatype-nexus-staging').userName ?: ""
password = getAuth('sonatype-nexus-staging').password ?: ""
}
}
mavenLocal()
}
}
}

task writePom << {
uploadArchives.repositories.mavenDeployer().getPom().writeTo("pom.xml")
def getAuth(repo_id) {
def m2_settings = new File("${System.getProperty('user.home')}/.m2/settings.xml")
if (m2_settings.exists()) {
def settings = new XmlSlurper().parse(m2_settings)
def repo = settings.servers.server.find { it.id.text() == repo_id }
if (repo != null) return [userName: repo.username.text(), password: repo.password.text()]
}
[:]
}

def getAuth(repo_id) {
def m2_settings = new File("${System.getProperty('user.home')}/.m2/settings.xml")
if (m2_settings.exists()) {
def settings = new XmlSlurper().parse(m2_settings)
def repo = settings.servers.server.find { it.id.text() == repo_id }
if (repo != null) return [userName: repo.username.text(), password: repo.password.text()]
}
[:]
task writePom(dependsOn: generatePomFileForMavenJavaPublication) {
doLast {
copy {
from layout.buildDirectory.file("generated-pom.xml")
into projectDir
rename { String fileName -> "pom.xml" }
}
}
}
57 changes: 22 additions & 35 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<!-- This module was also published with a richer model, Gradle metadata, -->
<!-- which should be used instead. Do not delete the following line which -->
<!-- is to indicate to Gradle or any Gradle module metadata file consumer -->
<!-- that they should prefer consuming it instead. -->
<!-- do_not_remove: published-with-gradle-metadata -->
<modelVersion>4.0.0</modelVersion>
<groupId>com.createsend</groupId>
<artifactId>createsend-java</artifactId>
<version>7.0.2-SNAPSHOT</version>
<version>8.0.0-SNAPSHOT</version>
<name>createsend-java</name>
<description>A Java library which implements the complete functionality of the Campaign Monitor API.</description>
<url>http://campaignmonitor.github.io/createsend-java/</url>
Expand All @@ -14,63 +19,61 @@
<distribution>repo</distribution>
</license>
</licenses>
<repositories />
<dependencies>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-json</artifactId>
<artifactId>jersey-client</artifactId>
<version>1.17.1</version>
<scope>compile</scope>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<artifactId>jersey-json</artifactId>
<version>1.17.1</version>
<scope>compile</scope>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
<version>1.17.1</version>
<scope>compile</scope>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.10.2</version>
<scope>compile</scope>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>2.10.2</version>
<scope>compile</scope>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.10.5.1</version>
<scope>compile</scope>
<version>2.13.4.2</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.10</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.7</version>
<scope>runtime</scope>
</dependency>
</dependencies>

<scm>
<connection>scm:git:git@github.com:campaignmonitor/createsend-java.git</connection>
<developerConnection>scm:git:git@github.com:campaignmonitor/createsend-java.git</developerConnection>
<connection>scm:git:https://github.com/campaignmonitor/createsend-java.git</connection>
<developerConnection>scm:git:https://github.com/campaignmonitor/createsend-java.git</developerConnection>
<url>https://github.com/campaignmonitor/createsend-java.git</url>
<tag>HEAD</tag>
</scm>

<developers>
<developer>
<id>jdennes</id>
Expand All @@ -83,14 +86,12 @@
<email>[email protected]</email>
</developer>
</developers>

<distributionManagement>
<repository>
<id>sonatype-nexus-staging</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>

<build>
<sourceDirectory>src</sourceDirectory>
<resources>
Expand All @@ -106,29 +107,16 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.4</version>
<configuration>
<failOnError>false</failOnError>
</configuration>
</plugin>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<version>2.1</version>
<configuration>
<goals>deploy</goals>
</configuration>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>release-sign-artifacts</id>
Expand All @@ -143,7 +131,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<version>1.1</version>
<executions>
<execution>
<phase>install</phase>
Expand All @@ -157,5 +145,4 @@
</build>
</profile>
</profiles>

</project>
4 changes: 2 additions & 2 deletions src/com/createsend/Clients.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,10 @@ public PagedResult<SentCampaign> sentCampaigns(

/**
* Gets a paged list of campaigns sent by the current client
* @param sentFromDate Campaigns sent on or after the <code>sentFromDate/code> value specified will be returned.
* @param sentFromDate Campaigns sent on or after the <code>sentFromDate</code> value specified will be returned.
* Must be in the format YYYY-MM-DD. If not provided, results will go back to the beginning of the client’s history.
* Use <code>null</code> for the default
* @param sentToDate Campaigns sent on or before the <code>sentToDate/code> value specified will be returned.
* @param sentToDate Campaigns sent on or before the <code>sentToDate</code> value specified will be returned.
* Must be in the format YYYY-MM-DD. If not provided, results will include the most recent sent campaigns.
* Use <code>null</code> for the default
* @param tags An array of tags to filter sent campaigns.
Expand Down