PR: MAVEN-458

Fixes for incorrect usage of dependencies instead of artifacts


git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@113862 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
brett 2003-08-20 12:42:37 +00:00
parent b25b571414
commit 7c1e3ca241
3 changed files with 63 additions and 55 deletions

View File

@ -2,6 +2,7 @@
<project <project
xmlns:j="jelly:core" xmlns:j="jelly:core"
xmlns:ant="jelly:ant"
xmlns:u="jelly:util" xmlns:u="jelly:util"
xmlns:def="jelly:define" xmlns:def="jelly:define"
xmlns:m="jelly:maven" xmlns:m="jelly:maven"
@ -44,9 +45,9 @@
</def:tag> </def:tag>
<!-- ================================================================== --> <!-- ================================================================== -->
<!-- jbuilder:generateDependencyLibrary --> <!-- jbuilder:generateArtifactLibrary -->
<!-- ================================================================== --> <!-- ================================================================== -->
<!-- Generate a JBuilder library definition from a dependency. If the --> <!-- Generate a JBuilder library definition from an artifact. If the -->
<!-- dependency is versioned (i.e. is not a snapshot) or if an --> <!-- dependency is versioned (i.e. is not a snapshot) or if an -->
<!-- unversioned library definition has not been created yet from the --> <!-- unversioned library definition has not been created yet from the -->
<!-- corresponding artifact, then a versioned library definition is --> <!-- corresponding artifact, then a versioned library definition is -->
@ -59,10 +60,10 @@
<!-- definition is written. --> <!-- definition is written. -->
<!-- --> <!-- -->
<!-- The following parameters can be used with the --> <!-- The following parameters can be used with the -->
<!-- generateDependencyLibrary tag by setting the appropriate attribute --> <!-- generateArtifactLibrary tag by setting the appropriate attribute -->
<!-- when invoking the tag: --> <!-- when invoking the tag: -->
<!-- --> <!-- -->
<!-- @param dependency The dependency. --> <!-- @param artifact The artifact. -->
<!-- @param userHome The JBuilder user home directory. --> <!-- @param userHome The JBuilder user home directory. -->
<!-- @param libraryList Optional name of the variable that contains a --> <!-- @param libraryList Optional name of the variable that contains a -->
<!-- a semi-colon separated list of library names. --> <!-- a semi-colon separated list of library names. -->
@ -70,14 +71,14 @@
<!-- the generated library will be appended. --> <!-- the generated library will be appended. -->
<!-- @param verbose Optional flag to enable verbose output. --> <!-- @param verbose Optional flag to enable verbose output. -->
<!-- ================================================================== --> <!-- ================================================================== -->
<def:tag name="generateDependencyLibrary"> <def:tag name="generateArtifactLibrary">
<j:set var="libraryId" value="${dependency.artifactId}" /> <j:set var="libraryId" value="${artifact.dependency.artifactId}" />
<j:set var="libraryVersion" value="${dependency.version}" /> <j:set var="libraryVersion" value="${artifact.dependency.version}" />
<!-- The default is to create a versioned library definition that refers <!-- The default is to create a versioned library definition that refers
to the jar in the local repository. --> to the jar in the local repository. -->
<j:set var="libraryName" value="${libraryId}-${libraryVersion}" /> <j:set var="libraryName" value="${libraryId}-${libraryVersion}" />
<j:if test="${verbose}" > <j:if test="${verbose}" >
<echo>Checking dependency ${libraryName} ...</echo> <ant:echo>Checking dependency ${libraryName} ...</ant:echo>
</j:if> </j:if>
<j:if test="${userHome != null and userHome.length() gt 0}" > <j:if test="${userHome != null and userHome.length() gt 0}" >
<j:set var="isSnapshot" value="${libraryVersion.equals('SNAPSHOT')}" /> <j:set var="isSnapshot" value="${libraryVersion.equals('SNAPSHOT')}" />
@ -95,7 +96,7 @@
created yet from the corresponding artifact. --> created yet from the corresponding artifact. -->
<j:when test="${!isSnapshot or !unversionedLibraryExists}" > <j:when test="${!isSnapshot or !unversionedLibraryExists}" >
<j:if test="${verbose and isSnapshot}" > <j:if test="${verbose and isSnapshot}" >
<echo> unversioned library definition not found</echo> <ant:echo> unversioned library definition not found</ant:echo>
</j:if> </j:if>
<j:set var="libraryFile" value="${userHome}/${libraryName}.library" /> <j:set var="libraryFile" value="${userHome}/${libraryName}.library" />
<j:set var="libraryExists" value="false" /> <j:set var="libraryExists" value="false" />
@ -118,10 +119,10 @@
<j:if test="${!libraryExists or (mavenGenerated and libraryType == 'dependency') }" > <j:if test="${!libraryExists or (mavenGenerated and libraryType == 'dependency') }" >
<j:if test="${verbose}" > <j:if test="${verbose}" >
<echo> creating dependent ${libraryFile}</echo> <ant:echo> creating dependent ${libraryFile}</ant:echo>
</j:if> </j:if>
<j:if test="${!verbose}" > <j:if test="${!verbose}" >
<echo>Creating dependent ${libraryFile} ...</echo> <ant:echo>Creating dependent ${libraryFile} ...</ant:echo>
</j:if> </j:if>
<!-- Get optional library source path property. --> <!-- Get optional library source path property. -->
@ -133,7 +134,7 @@
<x:comment>JBuilder Library Definition File</x:comment> <x:comment>JBuilder Library Definition File</x:comment>
<fullname>${libraryName}</fullname> <fullname>${libraryName}</fullname>
<class> <class>
<path><j:expr value="${maven.repo.local}/${dependency.groupId}/jars/${dependency.artifact}"/></path> <path><j:expr value="${artifact.path}"/></path>
</class> </class>
<j:if test="${librarySource != null and librarySource.length() gt 0}" > <j:if test="${librarySource != null and librarySource.length() gt 0}" >
<source> <source>
@ -156,7 +157,7 @@
<j:otherwise> <j:otherwise>
<j:set var="libraryName" value="${unversionedLibraryName}" /> <j:set var="libraryName" value="${unversionedLibraryName}" />
<j:if test="${verbose}" > <j:if test="${verbose}" >
<echo> referencing artifact library ${unversionedLibraryFile}</echo> <ant:echo> referencing artifact library ${unversionedLibraryFile}</ant:echo>
</j:if> </j:if>
</j:otherwise> </j:otherwise>
</j:choose> </j:choose>
@ -187,7 +188,7 @@
<def:tag name="generateProjectLibrary"> <def:tag name="generateProjectLibrary">
<j:set var="libraryName" value="${project.artifactId}" /> <j:set var="libraryName" value="${project.artifactId}" />
<j:set var="libraryFile" value="${userHome}/${libraryName}.library" /> <j:set var="libraryFile" value="${userHome}/${libraryName}.library" />
<echo>Creating ${libraryFile} ...</echo> <ant:echo>Creating ${libraryFile} ...</ant:echo>
<j:file name="${libraryFile}" prettyPrint="true" xmlns="dummy"> <j:file name="${libraryFile}" prettyPrint="true" xmlns="dummy">
<library> <library>
<x:comment>JBuilder Library Definition File</x:comment> <x:comment>JBuilder Library Definition File</x:comment>
@ -261,15 +262,15 @@
<!-- Find and read the JBuilder default project properties. --> <!-- Find and read the JBuilder default project properties. -->
<jbuilder:getDefaultProject project="jbDefaultProject" userHome="jbUserHome" /> <jbuilder:getDefaultProject project="jbDefaultProject" userHome="jbUserHome" />
<j:if test="${jbDefaultProject == null}" > <j:if test="${jbDefaultProject == null}" >
<echo>+------------------------------------------------------------------</echo> <ant:echo>+------------------------------------------------------------------</ant:echo>
<echo>| WARNING!</echo> <ant:echo>| WARNING!</ant:echo>
<echo>|</echo> <ant:echo>|</ant:echo>
<echo>| A JBuilder installation could not be found. The project files</echo> <ant:echo>| A JBuilder installation could not be found. The project files</ant:echo>
<echo>| being created will contain default values.</echo> <ant:echo>| being created will contain default values.</ant:echo>
<echo>+------------------------------------------------------------------</echo> <ant:echo>+------------------------------------------------------------------</ant:echo>
</j:if> </j:if>
<j:if test="${jbDefaultProject != null}" > <j:if test="${jbDefaultProject != null}" >
<echo>Reading default project ${jbDefaultProject}</echo> <ant:echo>Reading default project ${jbDefaultProject}</ant:echo>
<u:properties file="${jbDefaultProject}" var="defaultProps" /> <u:properties file="${jbDefaultProject}" var="defaultProps" />
<j:set var="authorLabel" value="${defaultProps.getProperty('sys[0].AuthorLabel')}" /> <j:set var="authorLabel" value="${defaultProps.getProperty('sys[0].AuthorLabel')}" />
<j:set var="backupPath" value="${defaultProps.getProperty('sys[0].BackupPath')}" /> <j:set var="backupPath" value="${defaultProps.getProperty('sys[0].BackupPath')}" />
@ -282,18 +283,18 @@
<j:set var="versionLabel" value="${defaultProps.getProperty('sys[0].VersionLabel')}" /> <j:set var="versionLabel" value="${defaultProps.getProperty('sys[0].VersionLabel')}" />
<available property="jdkDefPresent" file="${jbUserHome}/${jdk}.library" /> <available property="jdkDefPresent" file="${jbUserHome}/${jdk}.library" />
<j:if test="${!jdkDefPresent}"> <j:if test="${!jdkDefPresent}">
<echo>+------------------------------------------------------------------</echo> <ant:echo>+------------------------------------------------------------------</ant:echo>
<echo>| WARNING!</echo> <ant:echo>| WARNING!</ant:echo>
<echo>|</echo> <ant:echo>|</ant:echo>
<echo>| This project is being configured to use ${jdk}. This</echo> <ant:echo>| This project is being configured to use ${jdk}. This</ant:echo>
<echo>| JDK has not been configured yet in your JBuilder installation.</echo> <ant:echo>| JDK has not been configured yet in your JBuilder installation.</ant:echo>
<echo>| Go to Tools|Configure JDKs.</echo> <ant:echo>| Go to Tools|Configure JDKs.</ant:echo>
<echo>+------------------------------------------------------------------</echo> <ant:echo>+------------------------------------------------------------------</ant:echo>
</j:if> </j:if>
<j:set var="defCompany" value="${defaultProps.getProperty('sys[0].Company')}" /> <j:set var="defCompany" value="${defaultProps.getProperty('sys[0].Company')}" />
</j:if> </j:if>
<echo>Creating ${basedir}/${pom.artifactId}.jpx ...</echo> <ant:echo>Creating ${basedir}/${pom.artifactId}.jpx ...</ant:echo>
<!-- Format the copyright notice. --> <!-- Format the copyright notice. -->
<j:set var="copyright" value="Copyright (c) ${year} ${company} - All Rights Reserved." /> <j:set var="copyright" value="Copyright (c) ${year} ${company} - All Rights Reserved." />
@ -303,7 +304,6 @@
<j:set var="includeTestPath" value="0" /> <j:set var="includeTestPath" value="0" />
<j:set var="sourcePath" value="${pom.build.sourceDirectory}" /> <j:set var="sourcePath" value="${pom.build.sourceDirectory}" />
<j:set var="libraries" value="" /> <j:set var="libraries" value="" />
<j:useList var="testDependencies" />
<!-- If the project has unit tests, add the test source code to the project <!-- If the project has unit tests, add the test source code to the project
path. --> path. -->
<j:if test="${unitTestSourcesPresent}" > <j:if test="${unitTestSourcesPresent}" >
@ -319,37 +319,45 @@
</j:forEach> </j:forEach>
</j:if> </j:if>
<!-- Convert each of the project's dependencies into a required library. --> <!-- Convert each of the project's dependencies into a required library. -->
<j:forEach var="lib" items="${pom.dependencies}"> <j:forEach var="lib" items="${pom.artifacts}">
<!-- If the project has a declared dependency on jUnit, we use the <!-- If the project has a declared dependency on jUnit, we use the
specified version. --> specified version. -->
<j:if test="${lib.artifactId == 'junit'}" > <j:if test="${lib.dependency.artifactId == 'junit'}" >
<j:set var="junitDependency" value="${lib}" /> <j:set var="junitArtifact" value="${lib}" />
</j:if> </j:if>
<jbuilder:generateDependencyLibrary <jbuilder:generateArtifactLibrary
dependency="${lib}" artifact="${lib}"
userHome="${jbUserHome}" userHome="${jbUserHome}"
libraryList="libraries" libraryList="libraries"
verbose="${maven.jbuilder.verbose}" /> verbose="${maven.jbuilder.verbose}" />
</j:forEach> </j:forEach>
<!-- TODO: temporary -->
<j:set var="testDependencies" value="${maven.jbuilder.testDependencies}" />
<j:if test="${testDependencies != null and !testDependencies.isEmpty()}">
<ant:fail>
maven.jbuilder.testDependencies must be replaced with
maven.jbuilder.testArtifacts, using artifacts instead of dependencies
</ant:fail>
</j:if>
<!-- Convert each supplemental test dependency into a required library. --> <!-- Convert each supplemental test dependency into a required library. -->
<j:forEach var="lib" items="${maven.jbuilder.testDependencies}"> <j:forEach var="lib" items="${maven.jbuilder.testArtifacts}">
<!-- If the project has no declared dependency on jUnit, but a <!-- If the project has no declared dependency on jUnit, but a
supplemental test dependency does, we use the version specified by supplemental test dependency does, we use the version specified by
the test dependency. --> the test dependency. -->
<j:choose> <j:choose>
<j:when test="${lib.artifactId == 'junit'}" > <j:when test="${lib.dependency.artifactId == 'junit'}" >
<j:if test="${junitDependency == null}"> <j:if test="${junitArtifact == null}">
<j:set var="junitDependency" value="${lib}" /> <j:set var="junitArtifact" value="${lib}" />
<jbuilder:generateDependencyLibrary <jbuilder:generateArtifactLibrary
dependency="${lib}" artifact="${lib}"
userHome="${jbUserHome}" userHome="${jbUserHome}"
libraryList="libraries" libraryList="libraries"
verbose="${maven.jbuilder.verbose}" /> verbose="${maven.jbuilder.verbose}" />
</j:if> </j:if>
</j:when> </j:when>
<j:otherwise> <j:otherwise>
<jbuilder:generateDependencyLibrary <jbuilder:generateArtifactLibrary
dependency="${lib}" artifact="${lib}"
userHome="${jbUserHome}" userHome="${jbUserHome}"
libraryList="libraries" libraryList="libraries"
verbose="${maven.jbuilder.verbose}" /> verbose="${maven.jbuilder.verbose}" />
@ -358,15 +366,15 @@
</j:forEach> </j:forEach>
<!-- Finally, if there are unit tests and we still do not have a specific <!-- Finally, if there are unit tests and we still do not have a specific
dependency on jUnit, use the version from the test plugin. --> dependency on jUnit, use the version from the test plugin. -->
<j:if test="${unitTestSourcesPresent and junitDependency == null}" > <j:if test="${unitTestSourcesPresent and junitArtifact == null}" >
<!-- This goal forces the test plugin to be loaded. <!-- This goal forces the test plugin to be loaded.
TODO: In Maven beta 9, use the special test:eclipse tag instead. --> TODO: In Maven beta 9, use the special test:eclipse tag instead. -->
<attainGoal name="test:prepare-filesystem" /> <attainGoal name="test:prepare-filesystem" />
<j:set <j:set
var="junitDependency" var="junitArtifact"
value="${pom.getPluginContext('maven-test-plugin').getVariable('plugin').getDependency('junit')}" /> value="${pom.getPluginContext('maven-test-plugin').getVariable('plugin').getArtifact('junit')}" />
<jbuilder:generateDependencyLibrary <jbuilder:generateArtifactLibrary
dependency="${junitDependency}" artifact="${junitArtifact}"
userHome="${jbUserHome}" userHome="${jbUserHome}"
libraryList="libraries" libraryList="libraries"
verbose="${maven.jbuilder.verbose}" /> verbose="${maven.jbuilder.verbose}" />
@ -471,9 +479,9 @@
project="${pom}" project="${pom}"
userHome="${jbUserHome}" /> userHome="${jbUserHome}" />
<j:forEach var="lib" items="${pom.dependencies}"> <j:forEach var="lib" items="${pom.artifacts}">
<jbuilder:generateDependencyLibrary <jbuilder:generateArtifactLibrary
dependency="${lib}" artifact="${lib}"
userHome="${jbUserHome}" userHome="${jbUserHome}"
verbose="${maven.jbuilder.verbose}" /> verbose="${maven.jbuilder.verbose}" />
</j:forEach> </j:forEach>

View File

@ -15,13 +15,13 @@ maven.jbuilder.additionalSources = project.xml,maven.xml,project.properties
# plugin will be used. # plugin will be used.
#maven.jbuilder.docpath = ${maven.build.dir}/jbuilder-doc #maven.jbuilder.docpath = ${maven.build.dir}/jbuilder-doc
# Optional list of test dependencies. The list must be an instance of # Optional list of test artifacts. The list must be an instance of
# java.util.List and each element of the list must be an instance of # java.util.List and each element of the list must be an instance of
# org.apache.maven.project.Dependency. Therefore, this variable technically # org.apache.maven.repository.Artifact. Therefore, this variable technically
# cannot be initialized in a properties file, it must be initialized via jelly # cannot be initialized in a properties file, it must be initialized via jelly
# code. It is listed here for documentation purposes. In general, the test # code. It is listed here for documentation purposes. In general, the test
# dependencies will be project specific and should be initialized in a pre-goal. # dependencies will be project specific and should be initialized in a pre-goal.
#maven.jbuilder.testDependencies = #maven.jbuilder.testArtifacts =
# Optional source paths for libraries that refer to versioned jars in the local # Optional source paths for libraries that refer to versioned jars in the local
# repository. In general, these will be user specific and should go in # repository. In general, these will be user specific and should go in

View File

@ -52,7 +52,7 @@
</j:if> </j:if>
<!-- now iterate through all dependencies --> <!-- now iterate through all dependencies -->
<j:forEach var="lib" items="${pom.artifacts}"> <j:forEach var="lib" items="${pom.artifacts}">
"${maven.repo.local}${lib.urlPath}" <j:whitespace /> "${lib.path}" <j:whitespace />
</j:forEach> </j:forEach>
))))) )))))
</j:file> </j:file>