Skip to content

Commit 9dfb2da

Browse files
author
Sergiy Sevastyanov
committed
Updated pom.xml and javadoc in order to publish in maven central repository
1 parent 2c65ff2 commit 9dfb2da

File tree

2 files changed

+195
-30
lines changed

2 files changed

+195
-30
lines changed

pom.xml

100644100755
Lines changed: 151 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,48 @@
1-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
22
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3-
<modelVersion>4.0.0</modelVersion>
4-
5-
<groupId>com.github.snksoft</groupId>
6-
<artifactId>java-crc</artifactId>
7-
<version>1.0-SNAPSHOT</version>
8-
<packaging>jar</packaging>
9-
10-
<name>Generic CRC implementation for java</name>
11-
<url>https://github.com/snksoft/java-crc</url>
12-
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<groupId>com.github.snksoft</groupId>
6+
<artifactId>crc</artifactId>
7+
<version>1.0.1</version>
8+
<packaging>jar</packaging>
9+
10+
<name>${project.groupId}:${project.artifactId}</name>
11+
<description>Generic CRC implementation for java</description>
12+
<url>https://github.com/snksoft/java-crc</url>
13+
14+
<licenses>
15+
<license>
16+
<name>BSD License</name>
17+
<url>https://opensource.org/licenses/BSD-3-Clause</url>
18+
</license>
19+
</licenses>
20+
21+
<developers>
22+
<developer>
23+
<name>snksoft</name>
24+
<organization>S&amp;K Software Development</organization>
25+
<organizationUrl>https://github.com/snksoft</organizationUrl>
26+
</developer>
27+
</developers>
28+
29+
<scm>
30+
<connection>scm:git:git://github.com/snksoft/java-crc.git</connection>
31+
<developerConnection>scm:git:ssh://github.com:snksoft/java-crc.git</developerConnection>
32+
<url>http://github.com/snksoft/java-crc/tree/master</url>
33+
</scm>
34+
35+
<distributionManagement>
36+
<snapshotRepository>
37+
<id>ossrh</id>
38+
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
39+
</snapshotRepository>
40+
<repository>
41+
<id>ossrh</id>
42+
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
43+
</repository>
44+
</distributionManagement>
45+
1346
<properties>
1447
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1548
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
@@ -53,26 +86,118 @@
5386
<skip>true</skip>
5487
</configuration>
5588
</plugin>
89+
90+
<!-- java doc plugin -->
91+
<plugin>
92+
<groupId>org.apache.maven.plugins</groupId>
93+
<artifactId>maven-javadoc-plugin</artifactId>
94+
<version>3.0.0-M1</version>
95+
<configuration>
96+
<show>public</show>
97+
<nohelp>true</nohelp>
98+
</configuration>
99+
</plugin>
100+
101+
<!-- maven deployment -->
102+
<plugin>
103+
<groupId>org.sonatype.plugins</groupId>
104+
<artifactId>nexus-staging-maven-plugin</artifactId>
105+
<version>1.6.7</version>
106+
<extensions>true</extensions>
107+
<configuration>
108+
<serverId>ossrh</serverId>
109+
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
110+
<autoReleaseAfterClose>true</autoReleaseAfterClose>
111+
</configuration>
112+
</plugin>
113+
114+
<plugin>
115+
<groupId>org.apache.maven.plugins</groupId>
116+
<artifactId>maven-source-plugin</artifactId>
117+
<version>2.2.1</version>
118+
<executions>
119+
<execution>
120+
<id>attach-sources</id>
121+
<goals>
122+
<goal>jar-no-fork</goal>
123+
</goals>
124+
</execution>
125+
</executions>
126+
</plugin>
127+
128+
<plugin>
129+
<groupId>org.apache.maven.plugins</groupId>
130+
<artifactId>maven-javadoc-plugin</artifactId>
131+
<version>2.9.1</version>
132+
<executions>
133+
<execution>
134+
<id>attach-javadocs</id>
135+
<goals>
136+
<goal>jar</goal>
137+
</goals>
138+
</execution>
139+
</executions>
140+
</plugin>
141+
142+
<plugin>
143+
<groupId>org.apache.maven.plugins</groupId>
144+
<artifactId>maven-gpg-plugin</artifactId>
145+
<version>1.5</version>
146+
<executions>
147+
<execution>
148+
<id>sign-artifacts</id>
149+
<phase>verify</phase>
150+
<goals>
151+
<goal>sign</goal>
152+
</goals>
153+
</execution>
154+
</executions>
155+
</plugin>
156+
157+
<plugin>
158+
<groupId>org.sonatype.plugins</groupId>
159+
<artifactId>nexus-staging-maven-plugin</artifactId>
160+
<version>1.6.7</version>
161+
<extensions>true</extensions>
162+
<configuration>
163+
<serverId>ossrh</serverId>
164+
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
165+
<autoReleaseAfterClose>true</autoReleaseAfterClose>
166+
</configuration>
167+
</plugin>
168+
169+
<plugin>
170+
<groupId>org.apache.maven.plugins</groupId>
171+
<artifactId>maven-release-plugin</artifactId>
172+
<version>2.5.3</version>
173+
<configuration>
174+
<autoVersionSubmodules>true</autoVersionSubmodules>
175+
<useReleaseProfile>false</useReleaseProfile>
176+
<releaseProfiles>release</releaseProfiles>
177+
<goals>deploy</goals>
178+
</configuration>
179+
</plugin>
180+
56181
</plugins>
57182
</build>
58183

59-
<dependencies>
184+
<dependencies>
60185

61-
<dependency>
62-
<groupId>org.codehaus.groovy</groupId>
63-
<artifactId>groovy-all</artifactId>
64-
<version>2.4.1</version>
65-
<scope>compile</scope>
66-
</dependency>
186+
<dependency>
187+
<groupId>org.codehaus.groovy</groupId>
188+
<artifactId>groovy-all</artifactId>
189+
<version>2.4.1</version>
190+
<scope>test</scope>
191+
</dependency>
67192

68-
<dependency>
69-
<groupId>org.spockframework</groupId>
70-
<artifactId>spock-core</artifactId>
71-
<version>1.0-groovy-2.4</version>
72-
<scope>compile</scope>
73-
</dependency>
193+
<dependency>
194+
<groupId>org.spockframework</groupId>
195+
<artifactId>spock-core</artifactId>
196+
<version>1.0-groovy-2.4</version>
197+
<scope>test</scope>
198+
</dependency>
74199

75-
</dependencies>
200+
</dependencies>
76201

77-
</project>
202+
</project>
78203

src/main/java/com/github/snksoft/crc/CRC.java

100644100755
Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,50 @@
1313
// A good list of parameter sets for various CRC algorithms can be found at http://reveng.sourceforge.net/crc-catalogue/.
1414

1515
/**
16-
* This class provides utility functions for CRC calculation using either canonical straight forward approach
17-
* or using "fast" table-driven implementation. Note, that even though table-driven implementation is much faster
18-
* for processing large amounts of data and is commonly referred as fast algorithm, sometimes it might be quicker to
19-
* calculate CRC using canonical algorithm then to prepare the table for table-driven implementation.
16+
This class provides utility functions for CRC calculation using either canonical straight forward approach
17+
or using "fast" table-driven implementation. Note, that even though table-driven implementation is much faster
18+
for processing large amounts of data and is commonly referred as fast algorithm, sometimes it might be quicker to
19+
calculate CRC using canonical algorithm then to prepare the table for table-driven implementation.
20+
21+
<p>
22+
Using src is easy. Here is an example of calculating CCITT crc in one call using canonical approach.
23+
<pre>
24+
{@code
25+
String data = "123456789";
26+
long ccittCrc = CRC.calculateCRC(CRC.Parameters.CCITT, data.getBytes());
27+
System.out.printf("CRC is 0x%04X\n", ccittCrc); // prints "CRC is 0x29B1"
28+
}
29+
</pre>
30+
31+
<p>
32+
For larger data, table driven implementation is faster. Here is how to use it.
33+
34+
<pre>
35+
{@code
36+
String data = "123456789";
37+
CRC tableDriven = new CRC(CRC.Parameters.XMODEM);
38+
long xmodemCrc = tableDriven.calculateCRC(data.getBytes());
39+
System.out.printf("CRC is 0x%04X\n", xmodemCrc); // prints "CRC is 0x31C3"
40+
}
41+
</pre>
42+
43+
<p>
44+
You can also reuse CRC object instance for another crc calculation.
45+
<p>
46+
Given that the only state for a CRC calculation is the "intermediate value"
47+
and it is stored in your code, you can even use same CRC instance to calculate CRC
48+
of multiple data sets in parallel.
49+
And if data is too big, you may feed it in chunks
50+
<pre>
51+
{@code
52+
long curValue = tableDriven.init(); // initialize intermediate value
53+
curValue = tableDriven.update(curValue, "123456789".getBytes()); // feed first chunk
54+
curValue = tableDriven.update(curValue, "01234567890".getBytes()); // feed next chunk
55+
long xmodemCrc2 = tableDriven.finalCRC(curValue); // gets CRC of whole data ("12345678901234567890")
56+
System.out.printf("CRC is 0x%04X\n", xmodemCrc2); // prints "CRC is 0x2C89"
57+
}
58+
</pre>
59+
2060
* */
2161
public class CRC
2262
{

0 commit comments

Comments
 (0)