Skip to content
Permalink
Browse files
Current work
  • Loading branch information
chtompki committed Jan 7, 2018
1 parent 5d4ab8c commit bcca0ff9ae13761783d406e6fbe9165d1b401144
Showing 3 changed files with 62 additions and 8 deletions.
@@ -24,11 +24,10 @@
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.artifact.AttachedArtifact;
import org.apache.maven.artifact.Artifact;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.*;
@@ -65,7 +64,7 @@ public class CommonsDistributionDetatchmentMojo extends AbstractMojo {
* This list is supposed to hold the maven references to the aformentioned artifacts so that we
* can upload them to svn after they've been detatched from the maven deployment.
*/
private List<AttachedArtifact> detatchedArtifacts = new ArrayList<>();
private List<Artifact> detatchedArtifacts = new ArrayList<>();

/**
* The maven project context injection so that we can get a hold of the variables at hand.
@@ -86,11 +85,11 @@ public class CommonsDistributionDetatchmentMojo extends AbstractMojo {
public void execute() throws MojoExecutionException {
getLog().info("Detatching Assemblies");
for (Object attachedArtifact : project.getAttachedArtifacts()) {
if (ARTIFACT_TYPES_TO_DETATCH.contains(((AttachedArtifact) attachedArtifact).getType())) {
detatchedArtifacts.add((AttachedArtifact) attachedArtifact);
if (ARTIFACT_TYPES_TO_DETATCH.contains(((Artifact) attachedArtifact).getType())) {
detatchedArtifacts.add((Artifact) attachedArtifact);
}
}
for(AttachedArtifact artifactToRemove : detatchedArtifacts) {
for(Artifact artifactToRemove : detatchedArtifacts) {
project.getAttachedArtifacts().remove(artifactToRemove);
}
if (!workingDirectory.exists()) {
@@ -104,7 +103,7 @@ public void execute() throws MojoExecutionException {
private void copyRemovedArtifactsToWorkingDirectory() throws MojoExecutionException {
StringBuffer copiedArtifactAbsolutePath;
getLog().info("Copying detatched artifacts to working directory.");
for (AttachedArtifact artifact: detatchedArtifacts) {
for (Artifact artifact: detatchedArtifacts) {
File artifactFile = artifact.getFile();
copiedArtifactAbsolutePath = new StringBuffer(workingDirectory.getAbsolutePath());
copiedArtifactAbsolutePath.append("/");
@@ -116,7 +115,7 @@ private void copyRemovedArtifactsToWorkingDirectory() throws MojoExecutionExcept
}

private void sha1AndMd5SignArtifacts() throws MojoExecutionException {
for (AttachedArtifact artifact : detatchedArtifacts) {
for (Artifact artifact : detatchedArtifacts) {
if (!artifact.getFile().getName().contains("asc")) {
try {
FileInputStream artifactFileInputStream = new FileInputStream(artifact.getFile());
@@ -0,0 +1,38 @@
/*
* 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.commons.release.plugin.stubs;

import org.apache.commons.release.plugin.mojos.CommonsDistributionDetatchmentMojoTest;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.artifact.AttachedArtifact;

import java.util.List;

/**
* Stub for {@link MavenProject} for the {@link CommonsDistributionDetatchmentMojoTest}.
*
* @author chtompki
*/
public class DistributionDetatchmentProjectStub extends MavenProjectStub {

private List<Artifact> attachedArtifacts;



}
@@ -0,0 +1,17 @@
/*
* 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.commons.release.plugin.stubs;

0 comments on commit bcca0ff

Please sign in to comment.