You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by jb...@apache.org on 2007/02/22 23:36:17 UTC
svn commit: r510696 - in
/incubator/tuscany/java/sca/runtime/webapp/plugin.war: pom.xml
src/main/java/org/apache/tuscany/plugin/war/Dependency.java
src/main/java/org/apache/tuscany/plugin/war/TuscanyWarMojo.java
Author: jboynes
Date: Thu Feb 22 14:36:16 2007
New Revision: 510696
URL: http://svn.apache.org/viewvc?view=rev&rev=510696
Log:
avoid hardcoding runtimeVersion by reading it from the version of this plugin
Modified:
incubator/tuscany/java/sca/runtime/webapp/plugin.war/pom.xml
incubator/tuscany/java/sca/runtime/webapp/plugin.war/src/main/java/org/apache/tuscany/plugin/war/Dependency.java
incubator/tuscany/java/sca/runtime/webapp/plugin.war/src/main/java/org/apache/tuscany/plugin/war/TuscanyWarMojo.java
Modified: incubator/tuscany/java/sca/runtime/webapp/plugin.war/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/webapp/plugin.war/pom.xml?view=diff&rev=510696&r1=510695&r2=510696
==============================================================================
--- incubator/tuscany/java/sca/runtime/webapp/plugin.war/pom.xml (original)
+++ incubator/tuscany/java/sca/runtime/webapp/plugin.war/pom.xml Thu Feb 22 14:36:16 2007
@@ -55,11 +55,22 @@
</site>
</distributionManagement>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-plugin-plugin</artifactId>
+ <version>2.2</version>
+ </plugin>
+ </plugins>
+ </build>
+
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
+ <version>2.2</version>
</plugin>
</plugins>
</reporting>
Modified: incubator/tuscany/java/sca/runtime/webapp/plugin.war/src/main/java/org/apache/tuscany/plugin/war/Dependency.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/webapp/plugin.war/src/main/java/org/apache/tuscany/plugin/war/Dependency.java?view=diff&rev=510696&r1=510695&r2=510696
==============================================================================
--- incubator/tuscany/java/sca/runtime/webapp/plugin.war/src/main/java/org/apache/tuscany/plugin/war/Dependency.java (original)
+++ incubator/tuscany/java/sca/runtime/webapp/plugin.war/src/main/java/org/apache/tuscany/plugin/war/Dependency.java Thu Feb 22 14:36:16 2007
@@ -34,11 +34,6 @@
private static final String TYPE_JAR = "jar";
/**
- * Default boot libraries. TODO Decide on whether to get snapshot version rather than hardcoded version..
- */
- private static final Dependency[] DEFAULT_BOOT_LIBS = new Dependency[] { new WebappHostDependency() };
-
- /**
* Group Id that is injected in from configuration.
*/
private String groupId;
@@ -89,15 +84,6 @@
}
/**
- * Returns the default boot libraries.
- *
- * @return Default boot libraries.
- */
- public static Dependency[] getDefaultBootLibs() {
- return DEFAULT_BOOT_LIBS;
- }
-
- /**
* Checks whether the specified artifact has the same artifact id.
*
* @param artifact
@@ -108,15 +94,4 @@
// TODO Auto-generated method stub
return artifact.getArtifactId().equals(artifactId);
}
-
- /**
- * Webapp host depndency.
- */
- private static class WebappHostDependency extends Dependency {
- // TODO Decide on whether to get snapshot version rather than hardcoded version
- private WebappHostDependency() {
- super("org.apache.tuscany.sca.runtime.webapp", "webapp-host", "1.0-alpha-incubating-SNAPSHOT");
- }
- }
-
}
Modified: incubator/tuscany/java/sca/runtime/webapp/plugin.war/src/main/java/org/apache/tuscany/plugin/war/TuscanyWarMojo.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/webapp/plugin.war/src/main/java/org/apache/tuscany/plugin/war/TuscanyWarMojo.java?view=diff&rev=510696&r1=510695&r2=510696
==============================================================================
--- incubator/tuscany/java/sca/runtime/webapp/plugin.war/src/main/java/org/apache/tuscany/plugin/war/TuscanyWarMojo.java (original)
+++ incubator/tuscany/java/sca/runtime/webapp/plugin.war/src/main/java/org/apache/tuscany/plugin/war/TuscanyWarMojo.java Thu Feb 22 14:36:16 2007
@@ -30,6 +30,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.Properties;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.jar.JarOutputStream;
@@ -97,7 +98,7 @@
*
* @component
*/
- private ArtifactMetadataSource metadataSource;
+ public ArtifactMetadataSource metadataSource;
/**
* Used to look up Artifacts in the remote repository.
@@ -106,7 +107,7 @@
* @required
* @readonly
*/
- private ArtifactFactory artifactFactory;
+ public ArtifactFactory artifactFactory;
/**
* Used to look up Artifacts in the remote repository.
@@ -115,7 +116,7 @@
* @required
* @readonly
*/
- protected ArtifactResolver resolver;
+ public ArtifactResolver resolver;
/**
* Location of the local repository.
@@ -124,7 +125,7 @@
* @readonly
* @required
*/
- private ArtifactRepository localRepository;
+ public ArtifactRepository localRepository;
/**
* List of Remote Repositories used by the resolver
@@ -133,7 +134,7 @@
* @readonly
* @required
*/
- private List remoteRepositories;
+ public List remoteRepositories;
/**
* The directory for the generated WAR.
@@ -141,28 +142,28 @@
* @parameter expression="${project.build.directory}"
* @required
*/
- private String outputDirectory;
+ public String outputDirectory;
/**
* The directory for the generated WAR.
*
* @parameter
*/
- private Dependency[] bootLibs = Dependency.getDefaultBootLibs();
+ public Dependency[] bootLibs;
/**
* The directory for the generated WAR.
*
* @parameter
*/
- private Dependency[] extensions = new Dependency[0];
+ public Dependency[] extensions = new Dependency[0];
/**
* The directory for the generated WAR.
*
* @parameter
*/
- private Dependency[] dependencies = new Dependency[0];
+ public Dependency[] dependencies = new Dependency[0];
/**
* The name of the generated WAR.
@@ -170,54 +171,60 @@
* @parameter expression="${project.build.finalName}"
* @required
*/
- private String warName;
+ public String warName;
/**
* A flag to indicate whether extension dependencies should be resolved transitively.
*
* @parameter
*/
- private boolean loadExtensionDependencies;
+ public boolean loadExtensionDependencies;
/**
- * The default version of boot dependany jar files
+ * The default version of the runtime to use.
*
* @parameter
*/
- private String runTimeVersion = null;
+ public String runTimeVersion;
/**
* WEB-INF jar files.
*/
- private Set<String> packagedLibs = new HashSet<String>();
+ public Set<String> packagedLibs = new HashSet<String>();
/**
* Transitive dependencies for extensions.
*/
- private Map transDepenedencyMap = new HashMap();
+ public Map<String, Set<String>> transDepenedencyMap = new HashMap<String, Set<String>>();
/**
* Executes the MOJO.
*/
public void execute() throws MojoExecutionException {
- JarFile originalWar = null;
+ JarFile originalWar;
JarOutputStream newWar = null;
File originalWarFile = null;
File newWarFile = null;
boolean success = false;
- try {
+ if (runTimeVersion == null) {
+ try {
+ runTimeVersion = getPluginVersion();
+ } catch (IOException e) {
+ throw new MojoExecutionException(e.getMessage(), e);
+ }
+ }
+
+ if (bootLibs == null) {
+ Dependency dependancy = new Dependency("org.apache.tuscany.sca.runtime.webapp",
+ "webapp-host",
+ runTimeVersion);
+ bootLibs = new Dependency[] {dependancy};
+ }
- // if there is a runtime version specified and no bootLib dependancies,
- // modify the bootLibs to have the runtime version.
- if (runTimeVersion != null && bootLibs == Dependency.getDefaultBootLibs()) {
- Dependency dependancy = new Dependency("org.apache.tuscany.sca.runtime.webapp",
- "webapp-host", runTimeVersion);
- bootLibs = new Dependency[] {dependancy};
- }
-
+ try {
originalWarFile = new File(outputDirectory, warName + ".war");
originalWar = new JarFile(originalWarFile);
@@ -381,7 +388,7 @@
// Resolve the artifact
resolver.resolve(artifact, remoteRepositories, localRepository);
- resolvedArtifacts.add((Artifact) artifact);
+ resolvedArtifacts.add(artifact);
if (!transitive) {
return resolvedArtifacts;
@@ -407,6 +414,7 @@
* @param path Path within the war file where artifact is added.
* @param artifact Artifact to be added.
* @throws IOException In case of an unexpected IO error.
+ * @return true if the artifact was added
*/
private boolean addArtifact(JarOutputStream newWar, String path, Artifact artifact) throws IOException {
@@ -486,4 +494,15 @@
}
+ private String getPluginVersion() throws IOException {
+ Properties pomProperties = new Properties();
+ String propFile = "/META-INF/maven/org.apache.tuscany/tuscany-war-plugin/pom.properties";
+ InputStream is = getClass().getResourceAsStream(propFile);
+ try {
+ pomProperties.load(is);
+ return pomProperties.getProperty("version");
+ } finally {
+ IOUtils.closeQuietly(is);
+ }
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org