Skip to content

Pull in Shrinkwrap 2.2.x #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
1a4f2b7
[SHRINKRES-255] Update versions for 2.2.X maintenance branch
ALRubinger Sep 2, 2016
85b2e0a
Validate.isReadable should be tested on the absolute file path
gastaldi Aug 15, 2016
4ac782d
[SHRINKRES-252] Remove reliance on nonexistant (which now was registe…
ALRubinger Aug 29, 2016
8fbd312
[maven-release-plugin] prepare release 2.2.4
ALRubinger Sep 2, 2016
e2b4378
[maven-release-plugin] prepare for next development iteration
ALRubinger Sep 2, 2016
47a1873
SHRINKRES-259: No longer add directories to zip, added test that asse…
Dec 13, 2016
2457508
SHRINKRES-261 When multiple settings.xml files are merged then all
MatousJobanek Jan 3, 2017
dcfa22b
SHRINKRES-260 Shrinkwrap updated to 1.2.6
MatousJobanek Jan 4, 2017
1480ef7
SHRINKRES-262 Renamed tests that didn't contain TestCase in their nam…
MatousJobanek Jan 4, 2017
57a21c7
[maven-release-plugin] prepare release 2.2.5
MatousJobanek Jan 4, 2017
b99d19d
[maven-release-plugin] prepare for next development iteration
MatousJobanek Jan 4, 2017
16c21f2
SHRINKRES-263: When resolving a .war dependency, search for output fr…
Jan 12, 2017
773ec70
[maven-release-plugin] prepare release 2.2.6
MatousJobanek Jan 26, 2017
5a9fde6
[maven-release-plugin] prepare for next development iteration
MatousJobanek Jan 26, 2017
f5eda4a
removed Java 6 from travis configuration as the travis environment for
MatousJobanek Jan 27, 2017
c9a4d3e
SHRINKRES-265 fixed scope in test dependencies
MatousJobanek Feb 20, 2017
033e32b
fix(SHRINKRES-269,SHRINKRES-268): use HTTPS for Maven Central & new j…
Ladicek Feb 4, 2020
b986c10
[maven-release-plugin] prepare release 2.2.7
bartoszmajsak Feb 5, 2020
cb6dce5
[maven-release-plugin] prepare for next development iteration
bartoszmajsak Feb 5, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ build
atlassian-ide-plugin.xml

!impl-maven/src/test/resources/repository/org/jboss/shrinkwrap/test/test-pom/1.0.0/target
!impl-maven/src/test/resources/repository/org/jboss/shrinkwrap/test/test-war-with-resources/1.0.0/target
12 changes: 2 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
language: java
jdk:
- oraclejdk8
- oraclejdk7
- openjdk6
- openjdk7
dist: trusty
branches:
except:
- /^([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?$/
#before_install:
# # until SHRINKRES-203 is fixed, we need to build on older Maven
# - wget http://www.us.apache.org/dist/maven/maven-3/3.2.5/binaries/apache-maven-3.2.5-bin.tar.gz
# - tar xf apache-maven-3.2.5-bin.tar.gz
# - export M2_HOME=$PWD/apache-maven-3.2.5
# - export PATH=$M2_HOME/bin/:$PATH
# - export MAVEN_SKIP_RC=true
# - mvn --version
install:
- true
script:
Expand Down
2 changes: 1 addition & 1 deletion api-gradle-embedded-archive/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-parent</artifactId>
<version>3.0.0-SNAPSHOT</version>
<version>2.2.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion api-maven-archive/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-parent</artifactId>
<version>3.0.0-SNAPSHOT</version>
<version>2.2.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion api-maven/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-parent</artifactId>
<version>3.0.0-SNAPSHOT</version>
<version>2.2.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-parent</artifactId>
<version>3.0.0-SNAPSHOT</version>
<version>2.2.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<!-- Artifact Configuration -->
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-bom</artifactId>
<version>3.0.0-SNAPSHOT</version>
<version>2.2.8-SNAPSHOT</version>
<packaging>pom</packaging>
<name>ShrinkWrap Resolver Bill of Materials</name>
<description>Centralized dependencyManagement for the ShrinkWrap Resolver Project</description>
Expand Down
2 changes: 1 addition & 1 deletion build-resources/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-parent</artifactId>
<version>3.0.0-SNAPSHOT</version>
<version>2.2.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion depchain-gradle/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-parent</artifactId>
<version>3.0.0-SNAPSHOT</version>
<version>2.2.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion depchain/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-parent</artifactId>
<version>3.0.0-SNAPSHOT</version>
<version>2.2.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
6 changes: 4 additions & 2 deletions impl-gradle-embedded-archive/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-parent</artifactId>
<version>3.0.0-SNAPSHOT</version>
<version>2.2.8-SNAPSHOT</version>
</parent>

<artifactId>shrinkwrap-resolver-impl-gradle-embedded-archive</artifactId>
Expand Down Expand Up @@ -33,11 +33,13 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.easytesting</groupId>
<artifactId>fest-assert</artifactId>
<scope>test</scope>
</dependency>

<dependency>
Expand Down Expand Up @@ -73,7 +75,7 @@
<repository>
<id>jfrog</id>
<name>jfrog</name>
<url>http://repo.jfrog.org/artifactory/repo</url>
<url>https://repo.jfrog.org/artifactory/gradle</url>
</repository>
</repositories>
</project>
Expand Down
2 changes: 1 addition & 1 deletion impl-maven-archive/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-parent</artifactId>
<version>3.0.0-SNAPSHOT</version>
<version>2.2.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
*
*/
@RunWith(Parameterized.class)
public class JarGenerator {
public class JarGeneratorTestCase {
private String name;
private Class<?>[] content;

Expand Down Expand Up @@ -94,7 +94,7 @@ public static Collection<Object[]> jars() {
return Arrays.asList(data);
}

public JarGenerator(String name, Class<?>[] content) {
public JarGeneratorTestCase(String name, Class<?>[] content) {
this.name = name;
this.content = content;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
*
*/
@RunWith(Parameterized.class)
public class WarGenerator {
public class WarGeneratorTestCase {
private String name;
private Class<?>[] classes;
private String[] directories;
Expand All @@ -50,7 +50,7 @@ public static Collection<Object[]> jars() {
return Arrays.asList(data);
}

public WarGenerator(String name, Class<?>[] classes, String[] directories) {
public WarGeneratorTestCase(String name, Class<?>[] classes, String[] directories) {
this.name = name;
this.classes = classes;
this.directories = directories;
Expand Down
2 changes: 1 addition & 1 deletion impl-maven/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-parent</artifactId>
<version>3.0.0-SNAPSHOT</version>
<version>2.2.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import java.util.zip.ZipOutputStream;

import org.eclipse.aether.artifact.Artifact;
import org.eclipse.aether.artifact.ArtifactProperties;
import org.eclipse.aether.graph.DependencyNode;
import org.eclipse.aether.resolution.ArtifactResult;
import org.jboss.shrinkwrap.resolver.api.maven.MavenArtifactInfo;
Expand Down Expand Up @@ -140,11 +141,15 @@ private static File artifactToFile(final Artifact artifact) throws IllegalArgume
String extension = artifact.getExtension();
String classifier = artifact.getClassifier();

// SHRINKRES-102, allow test classes to be packaged as well
File root = new File(artifact.getFile().getParentFile(), "target/classes");
if (!Validate.isNullOrEmpty(classifier) && "tests".equals(classifier)) {
// SHRINKRES-102, allow test classes to be packaged as well
root = new File(artifact.getFile().getParentFile(), "target/test-classes");
} else if ("war".equals(artifact.getProperty(ArtifactProperties.TYPE, null))) {
// SHRINKRES-263, allow .war files to be packaged as well
root = new File(artifact.getFile().getParentFile(), "target/" + artifactId + "-" + artifact.getVersion());
}

try {
File archive = File.createTempFile(artifactId + "-", "." + extension);
archive.deleteOnExit();
Expand All @@ -165,7 +170,7 @@ private static File artifactToFile(final Artifact artifact) throws IllegalArgume
*
* @author <a href="mailto:[email protected]">Andrew Lee Rubinger</a>
*/
private static class PackageDirHelper {
static class PackageDirHelper {

private PackageDirHelper() {
throw new UnsupportedOperationException("No instances should be created; stateless class");
Expand Down Expand Up @@ -195,11 +200,8 @@ static void packageDirectories(final File outputFile, final File... directories)
FileInputStream fis = null;
try {
File fileEntry = new File(directory, entry);

if (fileEntry.isDirectory()) {
zipFile.putNextEntry(new ZipEntry(entry));
}
else {
//Do not add zip entries for directories
if (fileEntry.isFile()) {
fis = new FileInputStream(fileEntry);
zipFile.putNextEntry(new ZipEntry(entry));
IOUtil.copy(fis, zipFile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public class MavenWorkingSessionImpl extends ConfigurableMavenWorkingSessionImpl
private static final String MAVEN_CENTRAL_NAME = "central";
// creates a link to Maven Central Repository
private static final RemoteRepository MAVEN_CENTRAL = new RemoteRepository.Builder(MAVEN_CENTRAL_NAME, "default",
"http://repo1.maven.org/maven2").build();
"https://repo1.maven.org/maven2").build();

private Model model;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,12 @@ public List<Profile> getActiveProfiles(Collection<Profile> profiles, ProfileActi
if (p.getId() != null && context.getActiveProfileIds().contains(id)
&& !context.getInactiveProfileIds().contains(id)) {
activeProfiles.add(p);
continue;
}
if (p.getActivation() != null && p.getActivation().isActiveByDefault()
&& !context.getInactiveProfileIds().contains(p.getId())) {
activeProfiles.add(p);
break;
continue;
}
for (ProfileActivator activator : activators) {
if (activator.isActive(p, context, problems)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public MavenSecurityDispatcher(File securitySettings) throws InvalidConfiguratio
this.securitySettingsPath = securitySettings;
// settings-security is loaded only if it exists
// error is raised later only in case that it is missing but needed
if (Validate.isReadable(securitySettings)) {
if (Validate.isReadable(securitySettings.getAbsoluteFile())) {
try {
this.securitySettings = SecUtil.read(securitySettings.getAbsolutePath(), true);
} catch (SecDispatcherException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*
* @author <a href="mailto:[email protected]">Michal Matloka</a>
*/
public class MavenModelResolverTest {
public class MavenModelResolverTestCase {

/**
* Tests if newCopy() gives independent instances.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
package org.jboss.shrinkwrap.resolver.impl.maven;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

import org.apache.commons.io.FileUtils;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;

import static org.junit.Assert.assertTrue;

/**
* @author Florian Besser
*/
public class PackageDirHelperTestCase {

@Rule
public TemporaryFolder tempFolder = new TemporaryFolder();

@Test
public void packageDirectories_empty_canUnzip() throws Exception {
File output = tempFolder.newFile("output.zip");

MavenResolvedArtifactImpl.PackageDirHelper.packageDirectories(output);

File outputFolder = tempFolder.newFolder("outputFolder");
assertTrue(canUnzip(output, outputFolder));
}

@Test
public void packageDirectories_singleEntry_canUnzip() throws Exception {
File output = tempFolder.newFile("output.zip");

File inputFolder = tempFolder.newFolder("inputFolder");
FileUtils.forceMkdir(inputFolder);
File inputFile = new File(inputFolder, "exampleInput.foo");
FileUtils.write(inputFile, "some data");

MavenResolvedArtifactImpl.PackageDirHelper.packageDirectories(output, inputFolder);

File outputFolder = tempFolder.newFolder("outputFolder");
assertTrue(canUnzip(output, outputFolder));
}

@Test
public void packageDirectories_singleEntryWithSubEntries_canUnzip() throws Exception {
File output = tempFolder.newFile("output.zip");

File inputRootFolder = tempFolder.newFolder("inputRootFolder");
File inputSubFolder = new File(inputRootFolder, "inputSubFolder");
FileUtils.forceMkdir(inputSubFolder);

File inputFile = new File(inputSubFolder, "exampleInput.foo");
FileUtils.write(inputFile, "some data");

MavenResolvedArtifactImpl.PackageDirHelper.packageDirectories(output, inputRootFolder);

File outputFolder = tempFolder.newFolder("outputFolder");
assertTrue(canUnzip(output, outputFolder));
}

private boolean canUnzip(File zipFile, File outputFolder) {

byte[] buffer = new byte[1024];

ZipInputStream zis = null;
FileOutputStream fos = null;
try {
zis = new ZipInputStream(new FileInputStream(zipFile));
//get the zipped file list entry
ZipEntry ze = zis.getNextEntry();

while (ze != null) {
String fileName = ze.getName();
File newFile = new File(outputFolder, fileName);

//create all non exists folders
//else you will hit FileNotFoundException for compressed folder
FileUtils.forceMkdir(newFile.getParentFile());

fos = new FileOutputStream(newFile);
int len;
while ((len = zis.read(buffer)) > 0) {
fos.write(buffer, 0, len);
}
ze = zis.getNextEntry();
}

return true;
} catch (IOException ex) {
return false;
} finally {
if (zis != null) {
try {
zis.close();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (fos != null){
try {
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
}

}
Loading