Skip to content

Commit 111645b

Browse files
committed
Update docs/travis build
1 parent e54a85b commit 111645b

File tree

20 files changed

+480
-47
lines changed

20 files changed

+480
-47
lines changed

.travis.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ sudo: false
33
jdk:
44
- oraclejdk8
55
script: ./travis-build.sh
6+
before_cache:
7+
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
8+
cache:
9+
directories:
10+
- $HOME/.gradle/caches/
11+
- $HOME/.gradle/wrapper/
12+
- $HOME/.m2/repositories/
613
env:
714
global:
815
- GIT_NAME="James Kleeh"

build.gradle

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ plugins {
33
id 'org.asciidoctor.gradle.asciidoctor' version '1.5.1'
44
id "nebula.provided-base" version "3.1.0"
55
id 'org.ajoberstar.github-pages' version '1.1.0'
6+
id "com.jfrog.artifactory" version "4.4.0"
67
}
78

89
apply plugin: 'groovy'
@@ -41,9 +42,9 @@ task sourcesJar(type: Jar) {
4142
from sourceSets.main.allSource
4243
}
4344

44-
task javadocJar(type: Jar, dependsOn: javadoc) {
45-
classifier = 'javadoc'
46-
from 'build/docs/javadoc'
45+
task javadocJar(type: Jar, dependsOn: groovydoc) {
46+
classifier = 'groovydoc'
47+
from 'build/docs/groovydoc'
4748
}
4849

4950
bintray {
@@ -103,6 +104,20 @@ publishing {
103104
}
104105
}
105106

107+
artifactory {
108+
contextUrl = 'http://oss.jfrog.org'
109+
publish {
110+
repository {
111+
repoKey = 'oss-snapshot-local'
112+
username = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv("BINTRAY_USER")
113+
password = project.hasProperty('bintrayKey') ? project.property('bintrayKey') : System.getenv('BINTRAY_KEY')
114+
}
115+
defaults {
116+
publications('maven')
117+
}
118+
}
119+
}
120+
106121
asciidoctor {
107122
sourceDir = file('docs')
108123

@@ -112,14 +127,22 @@ asciidoctor {
112127
}
113128
}
114129

115-
attributes 'source-highlighter': 'prettify',
116-
'docinfo1': ['version': project.version],
117-
'imagesdir': 'images',
118-
'stylesdir': 'css',
119-
icons: 'font',
120-
'toc': 'left',
121-
version: project.version,
122-
'projectUrl': project.githubUrl
130+
attributes 'source-highlighter': 'coderay',
131+
'docinfo1': ['version': project.version],
132+
'imagesdir': './images',
133+
'stylesdir': 'css',
134+
'icons': 'font',
135+
'toc': 'left',
136+
'version': project.version,
137+
'groupId': project.group,
138+
'artifactId': project.name,
139+
'sourcedir': "${projectDir}/src/main/groovy",
140+
'projectUrl': project.githubUrl
141+
}
142+
143+
task docs(type:Copy, dependsOn:[groovydoc, asciidoctor]) {
144+
from "$buildDir/asciidoc/html5"
145+
into "$buildDir/docs"
123146
}
124147

125148
githubPages {
@@ -131,11 +154,11 @@ githubPages {
131154
}
132155

133156
pages {
134-
from file(asciidoctor.outputDir.path + '/html5')
157+
from file("build/docs")
135158
}
136159
}
137160

138-
publishGhPages.dependsOn asciidoctor
161+
publishGhPages.dependsOn docs
139162

140163
codenarc {
141164
toolVersion = '0.25.2'

docs/cells.adoc

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
[[cells]]
2+
== Cells
3+
4+
=== Cell Values
5+
6+
This module supports setting basic and custom types to cell values. The following types are supported out of the box:
7+
8+
* String
9+
* Calendar
10+
* Date
11+
* Double
12+
* Boolean
13+
14+
Support for additional types can be easily added without the need to convert your custom objects each time.
15+
16+
=== Custom Renderers
17+
18+
You can register a custom cell renderer to marshal your custom type into a type that is supported by Excel.
19+
20+
[source,groovy]
21+
.MyCustomClass.groovy
22+
----
23+
class MyCustomClass {
24+
String name
25+
}
26+
----
27+
28+
[source,groovy]
29+
----
30+
import com.jameskleeh.excel.Excel
31+
32+
//Register a renderer for your class
33+
Excel.registerCellRenderer(MyCustomClass) { MyCustomClass c ->
34+
c.name
35+
}
36+
----
37+
38+
Now when you are making calls to `cell()`, you can pass your entire `MyCustomClass` instance as the value and it will be converted to just use the name.
39+
40+
[source,groovy]
41+
----
42+
def c = new MyCustomClass(name: "Sally")
43+
44+
ExcelBuilder.build {
45+
sheet {
46+
row(c) //The value "Sally" will be put into cell A1
47+
}
48+
}
49+
----
50+
51+
52+
53+
54+

docs/formulas.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[[formuals]]
2+
== Formulas

docs/gettingStarted.adoc

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
[[gettingStarted]]
2+
== Getting Started
3+
4+
=== Installation
5+
6+
To get started using this great module, include it into your build:
7+
8+
[source,xml,subs=attributes+]
9+
.Maven
10+
----
11+
<dependency>
12+
<groupId>{groupId}</groupId>
13+
<artifactId>{artifactId}</artifactId>
14+
<version>{version}</version>
15+
</dependency>
16+
----
17+
18+
[source,groovy,subs=attributes+]
19+
.Gradle
20+
----
21+
compile '{groupId}:{artifactId}:{version}'
22+
----
23+
24+
=== Creating your first Excel document
25+
26+
Here is the simplest example to create an Excel document
27+
28+
[source,groovy]
29+
----
30+
package demo
31+
32+
import com.jameskleeh.excel.ExcelBuilder
33+
34+
File file = new File('test.xlsx')
35+
36+
ExcelBuilder.output(new FileOutputStream(file)) {
37+
sheet {
38+
row("test")
39+
}
40+
}
41+
----
42+
43+
NOTE: Groovy Excel Builder only supports XLSX documents, not the old XLS format.
44+
45+
As you might imagine from that example, a single sheet will be created with the value of "test" in cell `A1`.
46+
47+
In addition to writing the excel document directly to an output stream, you can also just build the document and do what you want with it afterwards.
48+
49+
[source,groovy]
50+
----
51+
package demo
52+
53+
import com.jameskleeh.excel.ExcelBuilder
54+
import org.apache.poi.xssf.usermodel.XSSFWorkbook
55+
56+
XSSFWorkbook workbook = ExcelBuilder.build {
57+
sheet {
58+
row {
59+
cell("Test 1")
60+
cell("Test 2")
61+
}
62+
}
63+
}
64+
65+
//Modify the workbook further
66+
67+
workbook.write(someOutputStream)
68+
----
69+
70+
The Groovy Excel Builder provides many options and features for creating documents. To learn more, continue on reading this documentation.

docs/index.adoc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
= Groovy Excel Builder
2+
James Kleeh
3+
4+
include::introduction.adoc[]
5+
6+
include::gettingStarted.adoc[]
7+
8+
include::sheets.adoc[]
9+
10+
include::rows.adoc[]
11+
12+
include::cells.adoc[]
13+
14+
include::formulas.adoc[]
15+
16+
include::styles.adoc[]

docs/introduction.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[[introduction]]
2+
== Introduction
3+
4+
This module exposes a Groovy DSL to create real Excel documents using Apache POI under the hood. The goal of this module is to abstract away the most common uses of Apache POI to make creating Excel documents very easy, while providing a hook into the underlying API to allow users to do anything that is not provided automatically.

docs/rows.adoc

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
[[rows]]
2+
== Rows
3+
4+
In addition to creating cells, there are also a few other methods available to you to make documents easier
5+
6+
=== Defaults
7+
8+
You can apply default styling at the row level in addition to the sheet level. Styles that conflict with defaults at the sheet level will override.
9+
10+
[source,groovy]
11+
----
12+
ExcelBuilder.build {
13+
sheet {
14+
defaultStyle [:]
15+
row {
16+
defaultStyle [:]
17+
}
18+
}
19+
}
20+
----
21+
22+
=== Skipping Cells
23+
24+
[source,groovy]
25+
----
26+
ExcelBuilder.build {
27+
sheet {
28+
row {
29+
cell("foo")
30+
skipCells(2)
31+
cell("bar")
32+
}
33+
}
34+
}
35+
----
36+
37+
The previous example will produce a document with "foo" in cell A1 and "bar" in D1
38+
39+
==== Skipping to a column
40+
41+
42+
[source,groovy]
43+
----
44+
ExcelBuilder.build {
45+
sheet {
46+
columns {
47+
column("Foo", "foo")
48+
skipCells(1)
49+
column("Bar", "bar")
50+
}
51+
row {
52+
skipTo("bar")
53+
cell("C2")
54+
}
55+
}
56+
}
57+
----
58+
59+
The example above will put the text "C2" in cell C2.
60+
61+
WARNING: The `skipTo` method will set the cell index so the next cell call will output data into the desired cell. Subsequent cells will start from that index. View the example below
62+
63+
[source,groovy]
64+
----
65+
ExcelBuilder.build {
66+
sheet {
67+
columns {
68+
column("Foo", "foo")
69+
skipCells(1)
70+
column("Bar", "bar")
71+
}
72+
row {
73+
cell("A2")
74+
cell("B2")
75+
skipTo("foo")
76+
cell("replaces A2")
77+
}
78+
}
79+
}
80+
----
81+
82+
The first call to `cell` sets the value to "A2". The `skipTo` call sets the index so the next call will set the cell value to "replaces A2".
83+
84+
[width="50%"]
85+
|=======
86+
| |A |B |C
87+
88+
|*1* |Foo | |Bar
89+
|*2* |replaces A2 |B2 |
90+
|=======

0 commit comments

Comments
 (0)