Skip to content

Commit

Permalink
[SHRINKRES-51][SHRINKRES-60] Refactor the API to clearly delineate se…
Browse files Browse the repository at this point in the history
…ttings configuration as separate from loading POM metadata. Allow configs to only be applied once. Settings, if applicable, are applied before POM metadata is loaded, always.
  • Loading branch information
ALRubinger committed Sep 8, 2012
1 parent db50abc commit abdd4b0
Show file tree
Hide file tree
Showing 63 changed files with 1,604 additions and 603 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,17 @@
*/
package org.jboss.shrinkwrap.resolver.api.archive;

import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.resolver.api.ResolverSystem;
import org.jboss.shrinkwrap.resolver.api.ConfigurableResolverSystem;
import org.jboss.shrinkwrap.resolver.api.Resolvers;
import org.jboss.shrinkwrap.resolver.api.maven.ConfigurableResolveStageBase;
import org.jboss.shrinkwrap.resolver.api.maven.MavenResolveStageBase;

/**
* Entry point of a Maven-based Resolver system capable of formatting results as ShrinkWrap {@link Archive}s. To create
* a new instance, pass in this class reference to {@link Resolvers#use(Class)} or
* {@link Resolvers#use(Class, ClassLoader)}, or instead call upon
* {@link MavenArchiveResolverSystemShortcutImpl#INSTANCE}.
* Entry point of a Maven-based ShrinkWrap Archive Resolver system which supports configuration. To create a new
* instance, pass in this class reference to {@link Resolvers#use(Class)} or {@link Resolvers#use(Class, ClassLoader)},
* or instead call upon {@link ShrinkWrapMaven#configureResolver()}
*
* @author <a href="mailto:alr@jboss.org">Andrew Lee Rubinger</a>
* @author <a href="mailto:kpiwko@redhat.com">Karel Piwko</a>
*/
public interface MavenArchiveResolverSystem
extends
ResolverSystem,
MavenResolveStageBase<MavenConfiguredArchiveResolveStage, MavenArchiveStrategyStage, MavenFormatArchiveStage>,
ConfigurableResolveStageBase<MavenConfiguredArchiveResolveStage, MavenArchiveStrategyStage, MavenFormatArchiveStage> {
public interface ConfigurableMavenShrinkWrapResolverSystem extends
ConfigurableResolverSystem<MavenShrinkWrapResolverSystem>, MavenShrinkWrapResolverSystem {

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*
* @author <a href="mailto:alr@jboss.org">Andrew Lee Rubinger</a>
*/
public interface MavenFormatArchiveStage extends MavenFormatStage {
public interface MavenArchiveFormatStage extends MavenFormatStage {
/**
* Formats the resultant artifacts as an array of {@link Archive}s. If nothing matches resolution, an empty array
* will be returned.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@
* @author <a href="mailto:kpiwko@redhat.com">Karel Piwko</a>
*/
public interface MavenArchiveStrategyStage extends
MavenStrategyStageBase<MavenArchiveStrategyStage, MavenFormatArchiveStage> {
MavenStrategyStageBase<MavenArchiveStrategyStage, MavenArchiveFormatStage> {

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.resolver.api.Resolvers;
import org.jboss.shrinkwrap.resolver.api.maven.ConfiguredResolveStageBase;
import org.jboss.shrinkwrap.resolver.api.maven.MavenResolveStageBase;
import org.jboss.shrinkwrap.resolver.api.maven.PomEquippedResolveStageBase;

/**
* Entry point of a Maven-based Resolver system capable of formatting results as ShrinkWrap {@link Archive}s. To create
Expand All @@ -31,7 +31,7 @@
* @author <a href="mailto:kpiwko@redhat.com">Karel Piwko</a>
*/
public interface MavenConfiguredArchiveResolveStage extends
MavenResolveStageBase<MavenConfiguredArchiveResolveStage, MavenArchiveStrategyStage, MavenFormatArchiveStage>,
ConfiguredResolveStageBase<MavenFormatArchiveStage> {
MavenResolveStageBase<MavenConfiguredArchiveResolveStage, MavenArchiveStrategyStage, MavenArchiveFormatStage>,
PomEquippedResolveStageBase<MavenConfiguredArchiveResolveStage, MavenArchiveStrategyStage, MavenArchiveFormatStage> {

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,16 @@
*/
package org.jboss.shrinkwrap.resolver.api.archive;

import org.jboss.shrinkwrap.resolver.api.ResolverSystem;
import org.jboss.shrinkwrap.resolver.api.Resolvers;

/**
* Shorthand convenience API where the call {@link MavenArchive#resolver()} is analogous to a more longhand, formal call
* to {@link Resolvers#use(Class)}, passing {@link MavenArchiveResolverSystem} as the argument.
* Entry point of a Maven-based Resolver system which does not suppport configuration. To create a new instance, pass in
* this class reference to {@link Resolvers#use(Class)} or {@link Resolvers#use(Class, ClassLoader)}, or instead call
* upon {@link MavenResolverSystemShortcutImpl#INSTANCE}.
*
* @author <a href="mailto:alr@jboss.org">Andrew Lee Rubinger</a>
* @author <a href="mailto:alr@jboss.org">Andrew Lee Rubinger</a>>
*/
public class MavenArchive {

/**
* Creates and returns a new {@link MavenArchiveResolverSystem} instance
*
* @return
*/
public static MavenArchiveResolverSystem resolver() {
return Resolvers.use(MavenArchiveResolverSystem.class);
}
public interface MavenShrinkWrapResolverSystem extends ResolverSystem, PomlessArchiveResolveStage {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2012, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* 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 org.jboss.shrinkwrap.resolver.api.archive;

import org.jboss.shrinkwrap.resolver.api.maven.PomEquippedResolveStageBase;

/**
* Maven-based ShrinkWrap Archive Resolve Stage which has been loaded with POM metadata
*
* @author <a href="mailto:alr@jboss.org">Andrew Lee Rubinger</a>
*/
public interface PomEquippedArchiveResolveStage extends
PomEquippedResolveStageBase<PomEquippedArchiveResolveStage, MavenArchiveStrategyStage, MavenArchiveFormatStage> {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2012, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* 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 org.jboss.shrinkwrap.resolver.api.archive;

import org.jboss.shrinkwrap.resolver.api.maven.PomlessResolveStageBase;

/**
* Maven-based ShrinkWrap Archive Resolve Stage which may be loaded with POM metadata
*
* @author <a href="mailto:alr@jboss.org">Andrew Lee Rubinger</a>
*/
public interface PomlessArchiveResolveStage
extends
PomlessResolveStageBase<PomEquippedArchiveResolveStage, PomlessArchiveResolveStage, MavenArchiveStrategyStage, MavenArchiveFormatStage> {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2012, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* 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 org.jboss.shrinkwrap.resolver.api.archive;

import org.jboss.shrinkwrap.resolver.api.ConfiguredResolverSystemFactory;
import org.jboss.shrinkwrap.resolver.api.Resolvers;
import org.jboss.shrinkwrap.resolver.api.maven.MavenResolverSystem;

/**
* ShrinkWrap Maven Resolver. Shorthand convenience API where the call {@link ShrinkWrapMaven#resolver()} is analogous to a more
* longhand, formal call to {@link Resolvers#use(Class)}, passing {@link MavenResolverSystem} as the argument. Also
* supports configuration via {@link ShrinkWrapMaven#configureResolver()}.
*
* @author <a href="mailto:alr@jboss.org">Andrew Lee Rubinger</a>
*/
public class ShrinkWrapMaven {

/**
* Creates and returns a new {@link MavenShrinkWrapResolverSystem} instance
*
* @return
*/
public static MavenShrinkWrapResolverSystem resolver() {
return Resolvers.use(MavenShrinkWrapResolverSystem.class);
}

/**
* Creates and returns a new {@link ConfiguredResolverSystemFactory} instance which may be used to create new
* {@link MavenShrinkWrapResolverSystem} instances
*
* @return
*/
public static ConfiguredResolverSystemFactory<MavenShrinkWrapResolverSystem, ConfigurableMavenShrinkWrapResolverSystem> configureResolver() {
return Resolvers.configure(ConfigurableMavenShrinkWrapResolverSystem.class);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2012, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* 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 org.jboss.shrinkwrap.resolver.api.maven;

import org.jboss.shrinkwrap.resolver.api.ConfigurableResolverSystem;
import org.jboss.shrinkwrap.resolver.api.Resolvers;

/**
* Entry point of a Maven-based Resolver system which supports configuration. To create a new instance, pass in this
* class reference to {@link Resolvers#use(Class)} or {@link Resolvers#use(Class, ClassLoader)}, or instead call upon
* {@link Maven#configureResolver()}
*
* @author <a href="mailto:alr@jboss.org">Andrew Lee Rubinger</a>
* @author <a href="mailto:kpiwko@redhat.com">Karel Piwko</a>
*/
public interface ConfigurableMavenResolverSystem extends ConfigurableResolverSystem<MavenResolverSystem>,
MavenResolverSystem {

/**
* Configures the current session from POM metadata found via the ShrinkWrap Resolver Maven Plugin; retrieves
* information from the currently-running Maven process.
*
* @return
* @throws InvalidEnvironmentException
* If the currently-executing environment is not under the control of the ShrinkWrap Resolver Maven
* Plugin
*/
PomEquippedResolveStage configureViaPlugin() throws InvalidEnvironmentException;
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
package org.jboss.shrinkwrap.resolver.api.maven;

/**
* Indicates that the current environment does not support {@link ConfigurableResolveStageBase#configureFromPlugin()};
* likely this option has been selected while running outside the control of the ShrinkWrap Resolver Maven Plugin.
* Indicates that the current environment does not support {@link PomlessResolveStageBase#loadPomViaPlugin()}
* ; likely this option has been selected while running outside the control of the ShrinkWrap Resolver Maven Plugin.
*
* @author <a href="mailto:alr@jboss.org">Andrew Lee Rubinger</a>
*/
public class InvalidEnvironmentException extends RuntimeException {
public class InvalidEnvironmentException extends IllegalStateException {

private static final long serialVersionUID = 1L;

Expand Down
Loading

0 comments on commit abdd4b0

Please sign in to comment.