You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ace.apache.org by br...@apache.org on 2013/06/25 17:03:19 UTC
svn commit: r1496509 - in /ace/sandbox/bramk/org.apache.ace.cli: ./
src/org/apache/ace/cli/deployment/ test/org/apache/ace/cli/deployment/
Author: bramk
Date: Tue Jun 25 15:03:18 2013
New Revision: 1496509
URL: http://svn.apache.org/r1496509
Log:
[sandbox] Added snapshot diff/uplaod support for non-bundles
Modified:
ace/sandbox/bramk/org.apache.ace.cli/repository.properties
ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/deployment/ContinuousDeployer.java
ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/deployment/DeployerUtil.java
ace/sandbox/bramk/org.apache.ace.cli/test/org/apache/ace/cli/deployment/ContinuousDeployerTest.java
Modified: ace/sandbox/bramk/org.apache.ace.cli/repository.properties
URL: http://svn.apache.org/viewvc/ace/sandbox/bramk/org.apache.ace.cli/repository.properties?rev=1496509&r1=1496508&r2=1496509&view=diff
==============================================================================
--- ace/sandbox/bramk/org.apache.ace.cli/repository.properties (original)
+++ ace/sandbox/bramk/org.apache.ace.cli/repository.properties Tue Jun 25 15:03:18 2013
@@ -16,4 +16,11 @@ source.locations=http://repository.amdat
target.class=org.apache.ace.cli.repository.AceObrRepository
target.type=OBR
-target.locations=http://localhost:8080/obr/repository.xml
\ No newline at end of file
+target.locations=http://localhost:8080/obr/repository.xml
+
+
+# The release repository used for continuous deployment
+
+release.class=org.apache.ace.cli.repository.AceObrRepository
+release.type=OBR
+release.locations=http://localhost:9091/obr/repository.xml
Modified: ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/deployment/ContinuousDeployer.java
URL: http://svn.apache.org/viewvc/ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/deployment/ContinuousDeployer.java?rev=1496509&r1=1496508&r2=1496509&view=diff
==============================================================================
--- ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/deployment/ContinuousDeployer.java (original)
+++ ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/deployment/ContinuousDeployer.java Tue Jun 25 15:03:18 2013
@@ -1,11 +1,12 @@
package org.apache.ace.cli.deployment;
import static org.apache.ace.cli.deployment.DeployerUtil.copyResources;
+import static org.apache.ace.cli.deployment.DeployerUtil.filesDiffer;
import static org.apache.ace.cli.deployment.DeployerUtil.findResources;
+import static org.apache.ace.cli.deployment.DeployerUtil.getBundleWithNewVersion;
import static org.apache.ace.cli.deployment.DeployerUtil.getFileName;
import static org.apache.ace.cli.deployment.DeployerUtil.getIdentity;
import static org.apache.ace.cli.deployment.DeployerUtil.getIdentityVersionRequirement;
-import static org.apache.ace.cli.deployment.DeployerUtil.getBundleWithNewVersion;
import static org.apache.ace.cli.deployment.DeployerUtil.getMimetype;
import static org.apache.ace.cli.deployment.DeployerUtil.getNextSnapshotVersion;
import static org.apache.ace.cli.deployment.DeployerUtil.getString;
@@ -111,13 +112,21 @@ public class ContinuousDeployer {
deploySnapshotResource(resource, getNextSnapshotVersion(releasedBaseVersion));
}
else {
- System.out.println("Found existing snapshot: " + getString(snapshotResource));
+ System.out.println("Found existing snapshot: " + getString(snapshotResource));
File developmentResource = m_developmentRepo.get(getIdentity(resource), getVersion(resource).toString(), Strategy.EXACT, null);
File deployedResource = m_deploymentRepo.get(getIdentity(snapshotResource), getVersion(snapshotResource).toString(), Strategy.EXACT, null);
- File comparableDeployedResource = getBundleWithNewVersion(deployedResource, getVersion(resource).toString());
- if (jarsDiffer(comparableDeployedResource, developmentResource)) {
+ boolean snapshotModified = false;
+ if (getType(resource).equals("osgi.bundle")) {
+ File comparableDeployedResource = getBundleWithNewVersion(deployedResource, getVersion(resource).toString());
+ snapshotModified = jarsDiffer(comparableDeployedResource, developmentResource);
+ }
+ else {
+ snapshotModified = filesDiffer(developmentResource, deployedResource);
+ }
+
+ if (snapshotModified) {
System.out.println("Uploading new snapshot: " + getString(resource) + " -> " + getNextSnapshotVersion(getVersion(snapshotResource)));
deploySnapshotResource(resource, getNextSnapshotVersion(getVersion(snapshotResource)));
}
Modified: ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/deployment/DeployerUtil.java
URL: http://svn.apache.org/viewvc/ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/deployment/DeployerUtil.java?rev=1496509&r1=1496508&r2=1496509&view=diff
==============================================================================
--- ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/deployment/DeployerUtil.java (original)
+++ ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/deployment/DeployerUtil.java Tue Jun 25 15:03:18 2013
@@ -9,7 +9,10 @@ import java.io.InputStream;
import java.io.StringReader;
import java.net.URI;
import java.nio.ByteBuffer;
+import java.security.DigestInputStream;
+import java.security.MessageDigest;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
@@ -106,19 +109,17 @@ public final class DeployerUtil {
* Check if there is a diff between two jar files.
*
* @param first
- * The first Jar file
+ * The first Jar
* @param second
- * The second Jar file
+ * The second Jar
* @return <code>true</code> if there is a difference, otherwise <code>false</code>
* @throws Exception
* On failure
*/
public static boolean jarsDiffer(File first, File second) throws Exception {
-
Differ di = new DiffPluginImpl();
Tree n = di.tree(new Jar(second));
Tree o = di.tree(new Jar(first));
-
Diff diff = n.diff(o);
for (Diff child : diff.getChildren()) {
for (Diff childc : child.getChildren()) {
@@ -132,6 +133,50 @@ public final class DeployerUtil {
}
/**
+ * Check if there is a diff between two arbitrary files.
+ *
+ * @param first
+ * The first file
+ * @param second
+ * The second file
+ * @return <code>true</code> if there is a difference, otherwise <code>false</code>
+ * @throws Exception
+ * On failure
+ */
+ public static boolean filesDiffer(File first, File second) throws Exception {
+
+ if (first.length() != second.length()) {
+ return true;
+ }
+
+ int c;
+ DigestInputStream stream = null;
+ byte[] firstHash = null;
+ byte[] secondHash = null;
+
+ try {
+ stream = new DigestInputStream(new FileInputStream(first), MessageDigest.getInstance("MD5"));
+ while (stream.read() != -1) {
+ }
+ firstHash = stream.getMessageDigest().digest();
+ }
+ finally {
+ stream.close();
+ }
+
+ try {
+ stream = new DigestInputStream(new FileInputStream(second), MessageDigest.getInstance("MD5"));
+ while (stream.read() != -1) {
+ }
+ secondHash = stream.getMessageDigest().digest();
+ }
+ finally {
+ stream.close();
+ }
+ return !Arrays.equals(firstHash, secondHash);
+ }
+
+ /**
* Clones a bundle file while replacing the Bundle-Version in the manifest with the specified value.
*
* @param sourceJar
Modified: ace/sandbox/bramk/org.apache.ace.cli/test/org/apache/ace/cli/deployment/ContinuousDeployerTest.java
URL: http://svn.apache.org/viewvc/ace/sandbox/bramk/org.apache.ace.cli/test/org/apache/ace/cli/deployment/ContinuousDeployerTest.java?rev=1496509&r1=1496508&r2=1496509&view=diff
==============================================================================
--- ace/sandbox/bramk/org.apache.ace.cli/test/org/apache/ace/cli/deployment/ContinuousDeployerTest.java (original)
+++ ace/sandbox/bramk/org.apache.ace.cli/test/org/apache/ace/cli/deployment/ContinuousDeployerTest.java Tue Jun 25 15:03:18 2013
@@ -6,8 +6,6 @@ import static org.apache.ace.cli.deploym
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
-import java.io.PipedInputStream;
-import java.io.PipedOutputStream;
import java.util.HashMap;
import java.util.Map;