Skip to content

Commit

Permalink
Add sample app (fix #1)
Browse files Browse the repository at this point in the history
  • Loading branch information
GladeDiviney committed Apr 15, 2018
1 parent 15218b4 commit cb7c761
Show file tree
Hide file tree
Showing 348 changed files with 220 additions and 77 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ jobs:
key: v1-dependencies-{{ checksum "build.gradle" }}

- store_artifacts:
path: ./build/reports
path: ./jipp-core/build/reports
destination: reports

- store_test_results:
path: ./build/test-results
path: ./jipp-core/build/test-results
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,26 @@ This library supplies a Java-compatible API but is actually implemented in [Kotl

## Usage

In short:

1. Add the current version of JIPP to your project
2. Create an `IppClientTransport` or `IppServerTransport`
3. Use the transport to create, parse and exchange `IppPacket` objects

A very basic use case is demonstrated by the `jclient` sample app. To run it:

```
# build the app
./gradlew jprint:build
# unzip in the current directory
unzip -o ./sample/jprint/build/distributions/jprint-*.zip
# Use IPP to print a file to the supplied HTTP/IPP endpoint.
# (The printer must natively support the file type.)
jprint-*/bin/jprint "ipp://192.168.1.102:631/ipp/print" sample.pdf
```

## Dependencies

`jipp-core`'s only dependencies are JDK 6+ and the current Kotlin runtime.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
67 changes: 30 additions & 37 deletions build.gradle → jipp-core/build.gradle
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
// Global settings
buildscript {
ext.kotlin_version = '1.2.31'
ext.dokka_version = '0.9.16'
ext.sonatypeUsername = ''
ext.sonatypePassword = ''

repositories {
jcenter()
maven {
url = "https://plugins.gradle.org/m2/"
url 'https://plugins.gradle.org/m2/'
}
}

dependencies {
classpath "net.ltgt.gradle:gradle-apt-plugin:0.9"
classpath "gradle.plugin.pl.squirrel:classycle-gradle-plugin:1.2"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version"

classpath "net.ltgt.gradle:gradle-apt-plugin:0.9"
classpath "gradle.plugin.pl.squirrel:classycle-gradle-plugin:1.2"
classpath "gradle.plugin.org.jlleitschuh.gradle:ktlint-gradle:2.1.1"
classpath "gradle.plugin.io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.0.0.RC6-3"
}
}

apply plugin: 'kotlin'
apply plugin: 'idea'
apply plugin: 'net.ltgt.apt'
apply plugin: 'jacoco'
apply plugin: 'org.jetbrains.dokka'
Expand All @@ -35,9 +32,13 @@ apply plugin: 'signing'
repositories {
mavenCentral()
jcenter()
maven() {
url = "https://plugins.gradle.org/m2/"
}
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:2.15.0'
}

version = '0.5.1'
Expand All @@ -46,6 +47,12 @@ group = 'com.hp.jipp'
targetCompatibility = 1.6
sourceCompatibility = 1.6

tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}

compileKotlin.kotlinOptions.allWarningsAsErrors = true

// This hack puts testing resource files where we can get to them
task copyTestResources(type: Copy) {
from "${projectDir}/src/test/resources/printer"
Expand All @@ -57,23 +64,8 @@ task cleanTestResources(type: Delete) {
include '**/*.bin'
}
}
test.finalizedBy cleanTestResources

tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}

compileKotlin.kotlinOptions.allWarningsAsErrors = true

dokka {
outputDirectory = "$buildDir/javadoc"
outputFormat = "javadoc"
externalDocumentationLink {
url = new URL("http://docs.oracle.com/javase/8/docs/api/")
}
}

test.finalizedBy jacocoTestReport
test.finalizedBy cleanTestResources

test {
testLogging {
Expand All @@ -83,6 +75,8 @@ test {
}
}

test.finalizedBy jacocoTestReport

jacocoTestReport {
reports {
xml.enabled = true // coveralls plugin depends on xml format report
Expand Down Expand Up @@ -110,7 +104,7 @@ detekt {
}

// Graph dependencies
task graphDeps(type: Exec) {
task graphDeps(type: Exec, dependsOn: classes) {
commandLine 'bin/graphDeps'
}

Expand All @@ -119,9 +113,15 @@ configure(graphDeps) {
description = "Create a dependency graph"
}

afterEvaluate {
graphDeps.dependsOn classes
dokka {
outputDirectory = "$buildDir/javadoc"
outputFormat = "javadoc"
externalDocumentationLink {
url = new URL("http://docs.oracle.com/javase/8/docs/api/")
}
}

afterEvaluate {
check.dependsOn ktlintCheck
check.dependsOn detektCheck
}
Expand Down Expand Up @@ -190,9 +190,9 @@ publishing {
}
}
}

repositories {
maven {
//url "https://oss.sonatype.org/content/repositories/snapshots"
url "https://oss.sonatype.org/service/local/staging/deploy/maven2"
credentials {
username sonatypeUsername
Expand Down Expand Up @@ -247,7 +247,6 @@ def customizePom(pom) {
}
}


model {
tasks.generatePomFileForMavenJavaPublication {
destination = file("$buildDir/generated-pom.xml")
Expand All @@ -261,9 +260,3 @@ model {
dependsOn project.tasks.signArchives
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:2.15.0'
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,15 @@ data class AttributeGroup(val tag: Tag, val attributes: List<Attribute<*>>) : Pr
}
return groupOf(startTag, attributes)
}
}
}

/** Return a new [AttributeGroup] */
fun groupOf(startTag: Tag, vararg attributes: Attribute<*>) =
AttributeGroup(startTag, attributes.toList())
/** Return a new [AttributeGroup] */
@JvmStatic
fun groupOf(startTag: Tag, vararg attributes: Attribute<*>) =
AttributeGroup(startTag, attributes.toList())

/** Return a new [AttributeGroup] */
fun groupOf(startTag: Tag, attributes: List<Attribute<*>>) =
AttributeGroup(startTag, attributes)
/** Return a new [AttributeGroup] */
@JvmStatic
fun groupOf(startTag: Tag, attributes: List<Attribute<*>>) =
AttributeGroup(startTag, attributes)
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@

package com.hp.jipp.trans

import com.hp.jipp.model.IppPacket
import java.io.IOException
import java.net.URI

/** Transport used to send packets and collect responses from a IPP server */
abstract class IppClientTransport {
interface IppClientTransport {

/**
* Deliver an IPP packet to the specified URL along with any additional data, and return the response
Expand All @@ -17,12 +16,5 @@ abstract class IppClientTransport {
* Note: implementations should check [Thread.interrupted] periodically and fail gracefully.
*/
@Throws(IOException::class)
abstract fun sendData(uri: URI, request: IppPacketData): IppPacketData

/** Shortcut for [sendData] when no additional data is delivered or expected in return */
fun send(uri: URI, ippPacket: IppPacket): IppPacket =
sendData(uri, IppPacketData(ippPacket)).let {
it.close()
it.ippPacket
}
fun sendData(uri: URI, request: IppPacketData): IppPacketData
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.util.Arrays;
import java.util.Collections;

import static com.hp.jipp.encoding.AttributeGroup.groupOf;
import static org.junit.Assert.*;

import com.hp.jipp.model.Types;
Expand All @@ -16,7 +17,6 @@
import com.hp.jipp.util.KotlinTest;
import com.hp.jipp.util.ParseError;

import static com.hp.jipp.encoding.AttributeGroupKt.groupOf;
import static com.hp.jipp.encoding.Cycler.*;

public class AttributeGroupTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.io.IOException;
import java.util.Arrays;

import static com.hp.jipp.encoding.AttributeGroup.groupOf;
import static org.junit.Assert.*;

import com.hp.jipp.model.Status;
Expand All @@ -18,7 +19,6 @@
import com.hp.jipp.model.Types;
import com.hp.jipp.model.Operation;

import static com.hp.jipp.encoding.AttributeGroupKt.groupOf;
import static com.hp.jipp.encoding.Cycler.*;

import kotlin.text.Charsets;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.hp.jipp.encoding

import com.hp.jipp.encoding.AttributeGroup.Companion.groupOf
import org.junit.Test

import org.junit.Assert.* // ktlint-disable no-wildcard-imports
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.hp.jipp.model;

import static com.hp.jipp.encoding.AttributeGroup.groupOf;
import static org.junit.Assert.*;

import org.junit.Rule;
Expand All @@ -14,7 +15,6 @@
import com.hp.jipp.encoding.StringType;
import com.hp.jipp.encoding.Tag;

import static com.hp.jipp.encoding.AttributeGroupKt.groupOf;
import static com.hp.jipp.encoding.Cycler.*;

import java.util.Arrays;
Expand Down
Loading

0 comments on commit cb7c761

Please sign in to comment.