Skip to content
This repository has been archived by the owner on Jul 22, 2023. It is now read-only.

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Frogbots4634 committed Jul 4, 2019
0 parents commit 694e39e
Show file tree
Hide file tree
Showing 9 changed files with 428 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.idea/
out/
testing/
*.iml
Binary file added libs/jcommander-1.72.jar
Binary file not shown.
23 changes: 23 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
This tool repacks AAR files into a ZIP with the proper folder structure and metadata files for uploading to Bintray without modifying them in any way.

You can download a prebuilt version from the [releases page](https://github.com/OpenFTC/AAR_Repackager/releases).

```
Usage: java -jar AAR_Repackager.jar [options]
Options:
* -a, --artifact
Artifact name
* -g, --group
Group name
* -i, --input
AAR input file
* -o, --output
ZIP Output file
-s, --sources
Sources JAR file (optional)
* -v, --version
Artifact version
-h
Print help
```
9 changes: 9 additions & 0 deletions resources/artifact-pom.pom
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>GROUP_ID_HERE</groupId>
<artifactId>ARTIFACT_ID_HERE</artifactId>
<version>ARTIFACT_VERSION_HERE</version>
<packaging>ARTIFACT_EXTENSION_HERE</packaging>
</project>
12 changes: 12 additions & 0 deletions resources/maven-metadata.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>GROUP_ID_HERE</groupId>
<artifactId>ARTIFACT_ID_HERE</artifactId>
<versioning>
<release>ARTIFACT_VERSION_HERE</release>
<versions>
<version>ARTIFACT_VERSION_HERE</version>
</versions>
<lastUpdated>20190703153327</lastUpdated>
</versioning>
</metadata>
3 changes: 3 additions & 0 deletions src/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: org.openftc.Main

68 changes: 68 additions & 0 deletions src/org/openftc/Checksum.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Original work copyright (C) 2012 The CyanogenMod Project
* Derived work copyright (C) 2019 OpenFTC Team
*
* * Licensed under the GNU GPLv2 license
*
* The text of the license can be found in the LICENSE file
* or at https://www.gnu.org/licenses/gpl-2.0.txt
*/

package org.openftc;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

class Checksum
{
static String calculateMD5(File file) throws NoSuchAlgorithmException, IOException
{
MessageDigest digest = MessageDigest.getInstance("MD5");
InputStream is = new FileInputStream(file);

byte[] buffer = new byte[8192];
int read;

while ((read = is.read(buffer)) > 0)
{
digest.update(buffer, 0, read);
}

is.close();

byte[] md5sum = digest.digest();
BigInteger bigInt = new BigInteger(1, md5sum);
String output = bigInt.toString(16);
// Fill to 32 chars
output = String.format("%32s", output).replace(' ', '0');
return output;
}

static String calculateSHA1(File file) throws NoSuchAlgorithmException, IOException
{
MessageDigest digest = MessageDigest.getInstance("SHA1");
InputStream is = new FileInputStream(file);

byte[] buffer = new byte[8192];
int read;

while ((read = is.read(buffer)) > 0)
{
digest.update(buffer, 0, read);
}

is.close();

byte[] md5sum = digest.digest();
BigInteger bigInt = new BigInteger(1, md5sum);
String output = bigInt.toString(16);
// Fill to 32 chars
output = String.format("%32s", output).replace(' ', '0');
return output;
}
}
86 changes: 86 additions & 0 deletions src/org/openftc/FileUtil.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
* Copyright (c) 2018 OpenFTC Team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package org.openftc;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

class FileUtil
{
static void dumpRawAsciiToDisk(String ascii, File out) throws IOException
{
FileOutputStream fileOutputStream = new FileOutputStream(out.getAbsolutePath());
fileOutputStream.write(ascii.getBytes(Charset.forName("ASCII")));
fileOutputStream.flush();
fileOutputStream.close();
}

static void zipDir(String dirPath) throws IOException
{
Path sourceDir = Paths.get(dirPath);
String zipFileName = dirPath.concat(".zip");

ZipOutputStream outputStream = new ZipOutputStream(new FileOutputStream(zipFileName));
Files.walkFileTree(sourceDir, new SimpleFileVisitor<Path>()
{
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attributes) throws IOException
{
Path targetFile = sourceDir.relativize(file);
outputStream.putNextEntry(new ZipEntry(targetFile.toString()));
byte[] bytes = Files.readAllBytes(file);
outputStream.write(bytes, 0, bytes.length);
outputStream.closeEntry();
return FileVisitResult.CONTINUE;
}
});
outputStream.close();
}

static void deleteFolder(File folder)
{
File[] files = folder.listFiles();

if (files != null)
{
for (File f : files)
{
if (f.isDirectory())
{
deleteFolder(f);
}
else
{
f.delete();
}
}
}

folder.delete();
}
}
Loading

0 comments on commit 694e39e

Please sign in to comment.