You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by db...@apache.org on 2012/01/15 19:12:32 UTC
svn commit: r1231717 - in
/openejb/trunk/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release:
Deploy.java Exec.java Files.java Pipe.java Tag.java UpdateTckRepo.java
Author: dblevins
Date: Sun Jan 15 18:12:32 2012
New Revision: 1231717
URL: http://svn.apache.org/viewvc?rev=1231717&view=rev
Log:
More programs for automating release processes
Added:
openejb/trunk/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/Deploy.java (with props)
openejb/trunk/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/Exec.java (with props)
openejb/trunk/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/Files.java (with props)
openejb/trunk/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/Pipe.java (with props)
openejb/trunk/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/Tag.java (with props)
openejb/trunk/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/UpdateTckRepo.java (with props)
Added: openejb/trunk/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/Deploy.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/Deploy.java?rev=1231717&view=auto
==============================================================================
--- openejb/trunk/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/Deploy.java (added)
+++ openejb/trunk/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/Deploy.java Sun Jan 15 18:12:32 2012
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.tools.release;
+
+import java.io.File;
+
+import static java.lang.String.format;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class Deploy {
+
+ public static void main(String... args) throws Exception {
+
+ // TODO Look for gpg on the path, report error if not found
+
+ final String version = "openejb-4.0.0-beta-2";
+ final String tag = "https://svn.apache.org/repos/asf/openejb/tags/" + version;
+
+ final File dir = new File("/tmp/release");
+ Files.mkdir(dir);
+ Exec.cd(dir);
+
+ Exec.exec("svn", "co", tag);
+
+ Exec.cd(new File(dir + "/" + version));
+
+ Exec.export("MAVEN_OPTS", "-Xmx2048m -XX:MaxPermSize=1024m");
+ Exec.exec("mvn",
+ "-Darguments=-Dmaven.test.skip=true -DfailIfNoTests=false",
+ "release:perform",
+ format("-DconnectionUrl=scm:svn:%s", tag)
+ );
+ }
+}
Propchange: openejb/trunk/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/Deploy.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openejb/trunk/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/Exec.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/Exec.java?rev=1231717&view=auto
==============================================================================
--- openejb/trunk/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/Exec.java (added)
+++ openejb/trunk/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/Exec.java Sun Jan 15 18:12:32 2012
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.tools.release;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class Exec {
+
+ public static File dir;
+ public static Map<String, String> env = new HashMap<String, String>();
+
+
+ public static File cd(String string) {
+ final File file = new File(string);
+ return cd(file);
+ }
+
+ public static File cd(File file) {
+ System.out.println("cd " + file);
+
+ System.setProperty("user.dir", file.getAbsolutePath());
+ dir = file;
+ return file;
+ }
+
+ public static void export(String key, String value) {
+ env.put(key, value);
+ }
+
+ public static int exec(String program, String... args) throws RuntimeException {
+ try {
+ final List<String> command = new ArrayList<String>();
+ command.add(program);
+ command.addAll(Arrays.asList(args));
+
+ final ProcessBuilder builder = new ProcessBuilder();
+ builder.directory(new File(dir.getAbsolutePath()));
+ builder.command(command);
+ builder.environment().put("PATH", "/opt/local/bin:/opt/local/sbin:/sw/bin:/sw/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/X11R6/bin:/usr/local/bin:/Users/dblevins/bin");
+ builder.environment().putAll(env);
+ final Process process = builder.start();
+ Pipe.pipe(process);
+
+ return process.waitFor();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ } catch (InterruptedException e) {
+ Thread.interrupted();
+ throw new RuntimeException(e);
+ }
+ }
+
+}
Propchange: openejb/trunk/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/Exec.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openejb/trunk/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/Files.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/Files.java?rev=1231717&view=auto
==============================================================================
--- openejb/trunk/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/Files.java (added)
+++ openejb/trunk/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/Files.java Sun Jan 15 18:12:32 2012
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.tools.release;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.File;
+import java.io.FileFilter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Pattern;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class Files {
+
+ public static List<File> collect(final File dir, final String regex) {
+ return collect(dir, Pattern.compile(regex));
+ }
+
+ public static List<File> collect(final File dir, final Pattern pattern) {
+ return collect(dir, new FileFilter() {
+ @Override
+ public boolean accept(File file) {
+ return pattern.matcher(file.getAbsolutePath()).matches();
+ }
+ });
+ }
+
+
+ public static List<File> collect(File dir, FileFilter filter) {
+ final List<File> accepted = new ArrayList<File>();
+ if (filter.accept(dir)) accepted.add(dir);
+
+ final File[] files = dir.listFiles();
+ if (files != null) for (File file : files) {
+ accepted.addAll(collect(file, filter));
+ }
+
+ return accepted;
+ }
+
+ public static void exists(File file, String s) {
+ if (!file.exists()) throw new RuntimeException(s + " does not exist: " + file.getAbsolutePath());
+ }
+
+ public static void dir(File file) {
+ if (!file.isDirectory()) throw new RuntimeException("Not a directory: " + file.getAbsolutePath());
+ }
+
+ public static void file(File file) {
+ if (!file.isFile()) throw new RuntimeException("Not a file: " + file.getAbsolutePath());
+ }
+
+ public static void writable(File file) {
+ if (!file.canWrite()) throw new RuntimeException("Not writable: " + file.getAbsolutePath());
+ }
+
+ public static void readable(File file) {
+ if (!file.canRead()) throw new RuntimeException("Not readable: " + file.getAbsolutePath());
+ }
+
+ public static void mkdir(File file) {
+ if (file.exists()) return;
+ if (!file.mkdirs()) throw new RuntimeException("Cannot mkdir: " + file.getAbsolutePath());
+ }
+
+ public static File tmpdir() {
+ try {
+ final File file = File.createTempFile("temp", "dir");
+ if (!file.delete()) throw new IllegalStateException("Cannot make temp dir. Delete failed");
+ mkdir(file);
+ return file;
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public static void mkparent(File file) {
+ mkdirs(file.getParentFile());
+ }
+
+ public static void mkdirs(File file) {
+
+ if (!file.exists()) {
+
+ assert file.mkdirs() : "mkdirs " + file;
+
+ return;
+ }
+
+ assert file.isDirectory() : "not a directory" + file;
+ }
+}
Propchange: openejb/trunk/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/Files.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openejb/trunk/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/Pipe.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/Pipe.java?rev=1231717&view=auto
==============================================================================
--- openejb/trunk/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/Pipe.java (added)
+++ openejb/trunk/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/Pipe.java Sun Jan 15 18:12:32 2012
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.tools.release;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public final class Pipe implements Runnable {
+
+ private final InputStream in;
+ private final OutputStream out;
+
+ public Pipe(InputStream in, OutputStream out) {
+ this.in = in;
+ this.out = out;
+ }
+
+ public static void pipe(Process process) {
+ pipe(process.getInputStream(), System.out);
+ pipe(process.getErrorStream(), System.err);
+ pipe(System.in, process.getOutputStream());
+ }
+
+ public static void pipe(InputStream in, OutputStream out) {
+ final Thread thread = new Thread(new Pipe(in, out));
+ thread.setDaemon(true);
+ thread.start();
+ }
+
+ public void run() {
+ try {
+ int i = -1;
+
+ byte[] buf = new byte[1024];
+
+ while ((i = in.read(buf)) != -1) {
+ out.write(buf, 0, i);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
Propchange: openejb/trunk/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/Pipe.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openejb/trunk/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/Tag.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/Tag.java?rev=1231717&view=auto
==============================================================================
--- openejb/trunk/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/Tag.java (added)
+++ openejb/trunk/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/Tag.java Sun Jan 15 18:12:32 2012
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.tools.release;
+
+import static java.lang.String.format;
+import static org.apache.openejb.tools.release.Exec.exec;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class Tag {
+
+ public static void main(String... args) throws Exception {
+
+ final String version = "openejb-4.0.0-beta-2";
+ final String branch = "https://svn.apache.org/repos/asf/openejb/branches/" + version;
+ final String tag = "https://svn.apache.org/repos/asf/openejb/tags/" + version;
+
+ if (exec("svn", "info", tag) == 0) {
+ exec("svn", "-m", format("recreating tag for %s", version), "rm", tag);
+ }
+
+ exec("svn", "-m", format("recreating tag for %s", version), "cp", branch, tag);
+ }
+}
Propchange: openejb/trunk/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/Tag.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openejb/trunk/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/UpdateTckRepo.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/UpdateTckRepo.java?rev=1231717&view=auto
==============================================================================
--- openejb/trunk/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/UpdateTckRepo.java (added)
+++ openejb/trunk/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/UpdateTckRepo.java Sun Jan 15 18:12:32 2012
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.tools.release;
+
+import java.io.File;
+
+import static java.lang.String.format;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class UpdateTckRepo {
+
+ public static void main(String... args) throws Exception {
+
+ // TODO Set repo to Nexus staging repo
+
+ // TODO Kick off TCK run
+ }
+}
Propchange: openejb/trunk/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/UpdateTckRepo.java
------------------------------------------------------------------------------
svn:eol-style = native