Skip to content

Commit e585a1e

Browse files
committed
Initial implementation, no tests yet. supports maven
0 parents  commit e585a1e

File tree

11 files changed

+423
-0
lines changed

11 files changed

+423
-0
lines changed

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
*.class
2+
3+
target/**
4+
build/**
5+
dist/**
6+
.idea/**
7+
8+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
9+
hs_err_pid*

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2015 Ian Preston
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# java-cid
2+
3+
[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io)
4+
[![](https://img.shields.io/badge/project-multiformats-blue.svg?style=flat-square)](http://github.com/multiformats/multiformats)
5+
[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs)
6+
7+
> A Java implementation of Content Id
8+
9+
This is the [cid](https://github.com/ipld/cid) implementation in Java.
10+
11+
## Usage
12+
13+
```
14+
Cid cid = Cid.decode("zdpuAyvkgEDQm9TenwGkd5eNaosSxjgEYd8QatfPetgB1CdEZ");
15+
```
16+
## Dependency
17+
You can use this project by building the JAR file as specified below, or by using [JitPack](https://jitpack.io/#ipld/java-cid/) (also supporting Gradle, SBT, etc).
18+
19+
for Maven, you can add the follwing sections to your POM.XML:
20+
```
21+
<repositories>
22+
<repository>
23+
<id>jitpack.io</id>
24+
<url>https://jitpack.io</url>
25+
</repository>
26+
</repositories>
27+
28+
<dependencies>
29+
<dependency>
30+
<groupId>com.github.ipld</groupId>
31+
<artifactId>java-cid</artifactId>
32+
<version>v1.0.0</version>
33+
</dependency>
34+
</dependencies>
35+
```
36+
37+
## Testing
38+
39+
### Ant
40+
`ant test`
41+
42+
### Maven
43+
`mvn test`
44+
45+
## Building
46+
47+
### Ant
48+
`ant dist` will build a JAR file in the `./dist` suitable for manual inclusion in a project. Dependent libraries are included in `./dist/lib`.
49+
50+
### Maven
51+
`mvn package` will build a JAR file with Maven dependency information.
52+
53+
## Releasing
54+
The version number is specified in `build.xml` and `pom.xml` and must be changed in both places in order to be accurately reflected in the JAR file manifest. A git tag must be added in the format "vx.x.x" for JitPack to work.
55+
56+
## Maintainers
57+
58+
Captain: [@ianopolous](https://github.com/ianopolous).
59+
60+
## Contribute
61+
62+
Contributions welcome. Please check out [the issues](https://github.com/ipld/java-cid/issues).
63+
64+
Check out our [contributing document](https://github.com/multiformats/multiformats/blob/master/contributing.md) for more information on how we work, and about contributing in general. Please be aware that all interactions related to multiformats are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md).
65+
66+
Small note: If editing the Readme, please conform to the [standard-readme](https://github.com/RichardLitt/standard-readme) specification.
67+
68+
## License
69+
70+
[MIT](LICENSE) © Ian Preston

build.xml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<project name="java-multihash" default="dist" basedir=".">
2+
<description>
3+
Java Content ID
4+
</description>
5+
6+
<property name="src" location="src"/>
7+
<property name="build" location="build"/>
8+
<property name="dist" location="dist"/>
9+
10+
<path id="dep.runtime">
11+
<fileset dir="./lib">
12+
<include name="**/*.jar" />
13+
</fileset>
14+
</path>
15+
16+
<target name="init">
17+
<mkdir dir="${build}"/>
18+
</target>
19+
20+
<target name="compile" depends="init" description="compile the source">
21+
<javac includeantruntime="false" srcdir="${src}" destdir="${build}" debug="true" debuglevel="lines,vars,source">
22+
<classpath>
23+
<fileset dir="lib">
24+
<include name="**/*.jar" />
25+
</fileset>
26+
</classpath>
27+
</javac>
28+
</target>
29+
30+
<target name="dist" depends="compile" description="generate the distribution">
31+
<mkdir dir="${dist}/lib"/>
32+
<copy todir="${dist}/lib">
33+
<fileset dir="lib"/>
34+
</copy>
35+
<manifestclasspath property="manifest_cp" jarfile="myjar.jar">
36+
<classpath refid="dep.runtime" />
37+
</manifestclasspath>
38+
<jar jarfile="${dist}/cid.jar" basedir="${build}">
39+
<manifest>
40+
<attribute name="Class-Path" value="${manifest_cp}"/>
41+
<attribute name="Implementation-Vendor" value="io.ipfs"/>
42+
<attribute name="Implementation-Title" value="multihash"/>
43+
<attribute name="Implementation-Version" value="1.0.0"/>
44+
</manifest>
45+
</jar>
46+
</target>
47+
48+
<target name="test" depends="compile,dist">
49+
<junit printsummary="yes" fork="true" haltonfailure="yes">
50+
<jvmarg value="-Xmx1g"/>
51+
<classpath>
52+
<pathelement location="lib/junit-4.11.jar" />
53+
<pathelement location="lib/hamcrest-core-1.3.jar" />
54+
<pathelement location="dist/cid.jar" />
55+
</classpath>
56+
<test name="io.ipfs.cid.CidTest" haltonfailure="yes">
57+
<formatter type="plain"/>
58+
<formatter type="xml"/>
59+
</test>
60+
</junit>
61+
</target>
62+
63+
<target name="clean" description="clean up">
64+
<delete dir="${build}"/>
65+
<delete dir="${dist}"/>
66+
</target>
67+
</project>

lib/hamcrest-core-1.3.jar

44 KB
Binary file not shown.

lib/junit-4.12.jar

308 KB
Binary file not shown.

lib/multibase.jar

7.32 KB
Binary file not shown.

lib/multihash.jar

5.18 KB
Binary file not shown.

pom.xml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
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>io.ipfs</groupId>
6+
<artifactId>cid</artifactId>
7+
<version>1.0.0</version>
8+
<packaging>jar</packaging>
9+
10+
<name>cid</name>
11+
<url>https://github.com/ipld/java-cid</url>
12+
13+
<issueManagement>
14+
<url>https://github.com/ipld/java-cid/issues</url>
15+
<system>GitHub Issues</system>
16+
</issueManagement>
17+
18+
<scm>
19+
<url>https://github.com/ipld/java-cid</url>
20+
<connection>scm:git:git://github.com/ipld/java-cid.git</connection>
21+
<developerConnection>scm:git:[email protected]:ipld/java-cid.git</developerConnection>
22+
</scm>
23+
24+
<licenses>
25+
<license>
26+
<name>MIT License</name>
27+
<url>https://github.com/ipld/java-cid/blob/master/LICENSE</url>
28+
<distribution>repo</distribution>
29+
</license>
30+
</licenses>
31+
32+
<properties>
33+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
34+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
35+
<junit.version>4.12</junit.version>
36+
<hamcrest.version>1.3</hamcrest.version>
37+
</properties>
38+
39+
<dependencies>
40+
<dependency>
41+
<groupId>junit</groupId>
42+
<artifactId>junit</artifactId>
43+
<version>${junit.version}</version>
44+
<scope>test</scope>
45+
</dependency>
46+
<dependency>
47+
<groupId>org.hamcrest</groupId>
48+
<artifactId>hamcrest-core</artifactId>
49+
<version>${hamcrest.version}</version>
50+
<scope>test</scope>
51+
</dependency>
52+
</dependencies>
53+
54+
<build>
55+
<plugins>
56+
<plugin>
57+
<groupId>org.apache.maven.plugins</groupId>
58+
<artifactId>maven-compiler-plugin</artifactId>
59+
<version>3.1</version>
60+
<configuration>
61+
<source>1.8</source>
62+
<target>1.8</target>
63+
</configuration>
64+
</plugin>
65+
<plugin>
66+
<groupId>org.apache.maven.plugins</groupId>
67+
<artifactId>maven-surefire-plugin</artifactId>
68+
<version>2.19.1</version>
69+
</plugin>
70+
<plugin>
71+
<groupId>org.apache.maven.plugins</groupId>
72+
<artifactId>maven-jar-plugin</artifactId>
73+
<version>3.0.2</version>
74+
<configuration>
75+
<archive>
76+
<manifest>
77+
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
78+
</manifest>
79+
</archive>
80+
</configuration>
81+
</plugin>
82+
</plugins>
83+
</build>
84+
</project>

0 commit comments

Comments
 (0)