All Downloads are FREE. Search and download functionalities are using the official Maven repository.

protoj.lang.internal.ReleaseFeature Maven / Gradle / Ivy

The newest version!
/**
 * Copyright 2009 Ashley Williams
 * 
 * Licensed 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 protoj.lang.internal;

import java.io.File;

import org.apache.commons.io.FileUtils;

import protoj.lang.ArchiveEntry;
import protoj.lang.ArchiveFeature;
import protoj.lang.ClassesArchive;
import protoj.lang.ProjectLayout;
import protoj.lang.PropertyInfo;
import protoj.lang.PublishFeature;
import protoj.lang.StandardProject;

/**
 * Responsible for kicking off a release of the ProtoJ project. The release
 * culminates in a deployment of the java artifacts to the maven repository at
 * source forge and to googlecode.
 * 

* The prerequisites for invoking the {@link #release(String, String, String)} * method is that the protoj code is compiled and the wiki directory is checked * out from source control as a sibling of the protoj project. * * @author Ashley Williams * */ public final class ReleaseFeature { private final ProtoProject project; public ReleaseFeature(ProtoProject project) { this.project = project; } /** * Carries out the steps to release protoj starting from just the compiled * code. * * @param gcUserName * the username for uploading to the googlecode project * @param gcPassword * the password for uploading to the googlecode project * @param sfUserName * the username for uploading to the sourceforge maven repository * */ public void release(String gcUserName, String gcPassword, String sfUserName) { showSummary(); project.getDelegate().getJunitFeature().junit(); extractSite(); createArchives(); uploadToMaven(sfUserName); uploadToGoogleCode(gcUserName, gcPassword); } /** * Just extracts the googlecode website files from the jar and copies to the * checked out wiki directory as a sibling of the protoj project root dir. */ public void extractSite() { ProjectLayout layout = project.getDelegate().getLayout(); File wikiDir = new File(layout.getRootDir().getParentFile(), "wiki"); if (!wikiDir.exists()) { String message = "checked out wiki directory is required: " + wikiDir.getAbsolutePath(); throw new RuntimeException(message); } File dir = project.extractSite(); File srcDir = new File(dir, "protoj/site/wiki"); FileUtils.copyDirectory(srcDir, wikiDir); } /** * Publishes the archives to the sourceforge maven repository. * * @param sfUserName */ public void uploadToMaven(String sfUserName) { PublishFeature publishFeature = project.getDelegate() .getPublishFeature(); publishFeature.deployAll(sfUserName, null, null, null); } /** * Creates the tar and jar files that are to be uploaded to googlecode. */ private void createArchives() { StandardProject delegate = project.getDelegate(); ArchiveFeature archive = delegate.getArchiveFeature(); archive.getClassesArchive().createArchives(); archive.getJavadocArchive().createArchives(); archive.getSourceArchive().createArchives(); } /** * Uploads the project archive, the jar with dependencies and the jar with * no dependencies to google code. * * @param gcUserName * @param gcPassword */ public void uploadToGoogleCode(String gcUserName, String gcPassword) { uploadArtifact(project.getJarTag(), "Merged jar file with maximum dependencies", gcUserName, gcPassword, "Type-Archive, OpSys-All"); uploadArtifact(project.getNoDepJarTag(), "Merged executable jar file with minimum dependencies", gcUserName, gcPassword, "Type-Archive, OpSys-All, Featured"); uploadProjectArchive(gcUserName, gcPassword); } /** * Uploads the project tar archive to the googlecode website. * * @param userName * @param password */ private void uploadProjectArchive(String userName, String password) { StandardProject delegate = project.getDelegate(); String summary = "Build from source with: ./protoj.sh compile archive"; String labels = "Type-Source, OpSys-All"; String googleName = String.format("%s-src.tar.gz", project .getProjectName()); delegate.getUploadGoogleCodeFeature().uploadTar(googleName, labels, summary, userName, password); } /** * Uploads the artifact with the given name to the googlecode website. * * @param name * @param description * @param userName * @param password * @param labels */ private void uploadArtifact(String name, String description, String userName, String password, String labels) { StandardProject delegate = project.getDelegate(); ArchiveFeature archive = delegate.getArchiveFeature(); ClassesArchive classes = archive.getClassesArchive(); ArchiveEntry entry = classes.getEntry(name) .getArchiveEntry(); String googleName = String.format("%s-%s.jar", entry.getName(), project .getVersion()); File artifact = entry.getArtifact(); delegate.getUploadGoogleCodeFeature().uploadArtifact(artifact, googleName, labels, description, userName, password); } /** * The release takes a long time so it's worth knowing whether or not an * upload to google code will take place at the end of it. */ private void showSummary() { StandardProject delegate = project.getDelegate(); PropertyInfo gcskip = delegate.getProperties().getGcskip(); StringBuilder builder = new StringBuilder(); if (gcskip.getBooleanValue() == true) { builder .append("ProtoJ won't be uploaded to google code during this release."); } else { builder .append("ProtoJ will be uploaded to google code during this release."); } builder.append(" See the help for "); builder.append(gcskip.getKey()); builder.append(" for more information."); delegate.getLogger().info(builder.toString()); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy