[opencms-dev] We have setup a public OpenCms Maven2 Repository

Shi Yusen shiys at langhua.cn
Thu Jul 2 15:10:17 CEST 2009


Hi Achim,

Great to know Alkacon is also moving to a Maven/Ivy style development
procedure. 

We haven't try Ivy before, we just follow JBoss and CAS to use maven2. I
hope the repository can also be used for Ivy. 

Unfortunately, I haven't set the dependencies in the poms. I posted the
changes I made, I wish I can get some suggestion on how to improve the
dependence configuration.

1. Add the following in ${opencms-7.5.0}/build.xml:
    <target name="maven2dist" depends="setup-jar, uploadjar"
        description="Creates sources jars and upload them to maven2
repository">
        
        <property name="opencms.output.sources.jars"
location="${opencms.output}/build/sources-jars" />
        <property name="mvn"
location="/opt/maven/bin/mvn" />

        <!-- make directory for sources-jars -->
        <mkdir dir="${opencms.output.sources.jars}" />
        
        <!-- read list of all available modules -->
        <property
file="${opencms.input}/modules/all-modules.properties" />
        
        <!-- remove org.opencms.workplace.demos modules -->
        <var name="modules.common.selection" unset="true" />
        <for list="${modules.common.all}" param="module" trim="yes">
            <sequential>
                <propertyregex property="pack.name" input="@{module}"
regexp="org\.opencms\.workplace\.demos([^\.]*)" select="\1"
casesensitive="false" />
                <if>
                    <not>
                        <isset property="pack.name" />
                    </not>
                    <then>
                        <if>
                          <isset property="modules.common.selection"/>
                          <then>
                            <var name="modules.common.selection"
value="${modules.common.selection},@{module}" />
                          </then>
                          <else>
                            <var name="modules.common.selection"
value="@{module}" />
                          </else>
                        </if>
                    </then>
                </if>
                <var name="pack.name" unset="true" />
            </sequential>
        </for>
        <echo>${modules.common.selection}</echo>
        <!-- build war with selected modules -->
        <ant antfile="${opencms.input}/modules/build.xml"
target="maven2dist" inheritAll="false" >
            <property name="modules.common.selection"
value="${modules.common.selection}" />
            <property name="modules.selection.mode" value="selection" />
            <property name="app.name" value="${app.name}" />
        </ant>      
        
        <!-- build opencms-sources.jar -->
        <jar
jarfile="${opencms.output.sources.jars}/opencms-sources.jar">
            <fileset dir="${opencms.input}/src" />
            <zipfileset dir="${opencms.input}" prefix="META-INF"
includes="license.txt" />
        </jar>

        <!-- build opencms-setup-sources.jar -->
        <jar
jarfile="${opencms.output.sources.jars}/opencms-setup-sources.jar">
            <fileset dir="${opencms.input}/src-setup" />
            <zipfileset dir="${opencms.input}" prefix="META-INF"
includes="license.txt" />
        </jar>

        <!-- build upload-sources.jar -->
        <jar
jarfile="${opencms.output.sources.jars}/upload-sources.jar">
            <fileset dir="${opencms.input}/src-components">
                <include name="**/applet/*.java"/>
            </fileset>
            <zipfileset dir="${opencms.input}" prefix="META-INF"
includes="license.txt" />
        </jar>

        <!-- upload opencms.jar and opencms-sources.jar -->
        <exec executable="${mvn}">
            <arg value="deploy:deploy-file" />
            <arg value="-Dfile=
${opencms.output.sources.jars}/opencms-sources.jar" />
            <arg value="-DrepositoryId=langhua.public" />
            <arg
value="-Durl=http://maven2.langhua.org/archiva/repository/public/" />
            <arg value="-DgroupId=opencms" />
            <arg value="-DartifactId=opencms" />
            <arg value="-Dversion=${version.number}" />
            <arg value="-Dpackaging=sources.jar" />
        </exec>
        <exec executable="${mvn}">
            <arg value="deploy:deploy-file" />
            <arg value="-Dfile=${opencms.output.jars}/opencms.jar" />
            <arg value="-DrepositoryId=langhua.public" />
            <arg
value="-Durl=http://maven2.langhua.org/archiva/repository/public/" />
            <arg value="-DgroupId=opencms" />
            <arg value="-DartifactId=opencms" />
            <arg value="-Dversion=${version.number}" />
            <arg value="-Dpackaging=jar" />
        </exec>

        <!-- upload opencms-setup.jar and opencms-setup-sources.jar -->
        <exec executable="${mvn}">
            <arg value="deploy:deploy-file" />
            <arg value="-Dfile=
${opencms.output.sources.jars}/opencms-setup-sources.jar" />
            <arg value="-DrepositoryId=langhua.public" />
            <arg
value="-Durl=http://maven2.langhua.org/archiva/repository/public/" />
            <arg value="-DgroupId=opencms" />
            <arg value="-DartifactId=opencms-setup" />
            <arg value="-Dversion=${version.number}" />
            <arg value="-Dpackaging=sources.jar" />
        </exec>
        <exec executable="${mvn}">
            <arg value="deploy:deploy-file" />
            <arg value="-Dfile=
${opencms.output.jars}/opencms-setup.jar" />
            <arg value="-DrepositoryId=langhua.public" />
            <arg
value="-Durl=http://maven2.langhua.org/archiva/repository/public/" />
            <arg value="-DgroupId=opencms" />
            <arg value="-DartifactId=opencms-setup" />
            <arg value="-Dversion=${version.number}" />
            <arg value="-Dpackaging=jar" />
        </exec>

        <!-- upload upload.jar and upload-sources.jar -->
        <exec executable="${mvn}">
            <arg value="deploy:deploy-file" />
            <arg value="-Dfile=
${opencms.output.sources.jars}/upload-sources.jar" />
            <arg value="-DrepositoryId=langhua.public" />
            <arg
value="-Durl=http://maven2.langhua.org/archiva/repository/public/" />
            <arg value="-DgroupId=opencms" />
            <arg value="-DartifactId=opencms-upload" />
            <arg value="-Dversion=${version.number}" />
            <arg value="-Dpackaging=sources.jar" />
        </exec>
        <exec executable="${mvn}">
            <arg value="deploy:deploy-file" />
            <arg value="-Dfile=${opencms.output}/upload/upload.jar" />
            <arg value="-DrepositoryId=langhua.public" />
            <arg
value="-Durl=http://maven2.langhua.org/archiva/repository/public/" />
            <arg value="-DgroupId=opencms" />
            <arg value="-DartifactId=opencms-upload" />
            <arg value="-Dversion=${version.number}" />
            <arg value="-Dpackaging=jar" />
        </exec>
    </target>


2. Add the following in ${opencms-7.5.0}/modules/build.xml:
    <target name="maven2dist" 
        depends="init" description="Generates the given .jar and
sources.jar files">
    
        <ant antfile="${opencms.input}/build.xml" dir="${opencms.input}"
inheritall="false" target="jar"/>
        <for list="${modules.var}" param="module" trim="yes">
          <sequential>
            <ant antfile="${basedir}/build-single.xml"
target="maven2dist" inheritAll="false" >
                <property name="module.name" value="@{module}" />
            </ant>
          </sequential>
        </for>
    </target>


3. Add the following in ${opencms-7.5.0}/modules/build-single.xml:
	<property name="opencms.output.sources.jars"
		location="${opencms.output}/build/sources-jars" />

	<target name="sources.jar" depends="init, builddeps"
		description="Build sources.jar">

		<if>
			<not>
				<equals arg1="${src.mode}" arg2="none" />
			</not>
			<then>
				<mkdir dir="${module.output.classes}" />

				<var name="module.dependencies.path" value="." />
				<for list="${module.dependencies}" param="dependency"
					trim="true">
					<sequential>
						<if>
							<available
								file="${@{dependency}.output.jar}" />
							<then>
								<for param="archive">
									<fileset
										dir="${@{dependency}.output.jar}">
										<include name="**/*.jar" />
									</fileset>
									<sequential>
										<var
											name="module.dependencies.path"
											value="${module.dependencies.path}:@{archive}" />
									</sequential>
								</for>
							</then>
						</if>
					</sequential>
				</for>
				<!--echo message="${module.dependencies.path}" /-->

				<var name="module.libs.path" value="." />
				<if>
					<available file="${module.input.lib}" />
					<then>
						<for param="archive">
							<path>
								<fileset dir="${module.input.lib}"
									includes="*.jar" />
							</path>
							<sequential>
								<var name="module.libs.path"
									value="${module.libs.path}:@{archive}" />
							</sequential>
						</for>
					</then>
				</if>
				<!--echo message="${module.libs.path}" /-->

				<if>
					<equals arg1="${src.mode}" arg2="shared" />
					<then>
						<jar

jarfile="${opencms.output.sources.jars}/${module.name}-sources.jar">
							<fileset dir="${module.input.src.shared}"
								includes="${module.package}/*.java" />
							<zipfileset dir="${opencms.input}"
								prefix="META-INF" includes="license.txt" />
						</jar>
					</then>
					<else>
						<if>
							<equals arg1="${src.mode}"
								arg2="multishared" />
							<then>
								<for list="${module.packages}"
									param="mpackage" trim="true">
									<sequential>
										<var name="package.dir"
											value="" />
										<for list="@{mpackage}"
											param="package" delimiter="." trim="true">
											<sequential>
												<var
													name="module.input.src.test"
													value="${module.input.src.test}/@{package}" />
												<var name="package.dir"
													value="${package.dir}@{package}/" />
											</sequential>
										</for>
										<jar

jarfile="${opencms.output.sources.jars}/${module.name}-sources.jar">
											<fileset
												dir="${module.input.src.shared}"
												includes="${package.dir}/*.java" />
											<zipfileset
												dir="${opencms.input}" prefix="META-INF"
												includes="license.txt" />
										</jar>
									</sequential>
								</for>
							</then>
							<else>
								<jar

jarfile="${opencms.output.sources.jars}/${module.name}-sources.jar">
									<fileset
										dir="${module.input.src.single}" includes="**/*.java" />
									<zipfileset dir="${opencms.input}"
										prefix="META-INF" includes="license.txt" />
								</jar>
							</else>
						</if>
					</else>
				</if>
			</then>
		</if>
	</target>

	<target name="maven2dist" depends="jar, sources.jar"
		description="Creates jar and sources.jar and upload them to maven2
repository">

		<property name="mvn" location="/opt/maven/bin/mvn" />
		<if>
			<available file="${module.output.jar}" />
			<then>
				<!-- upload jar to maven2 repository -->
				<exec executable="${mvn}">
					<arg value="deploy:deploy-file" />
					<arg
						value="-Dfile=${module.output.jar}/${module.name}.jar" />
					<arg value="-DrepositoryId=langhua.public" />
					<arg

value="-Durl=http://maven2.langhua.org/archiva/repository/public/" />
					<arg value="-DgroupId=opencms" />
					<arg value="-DartifactId=${module.name}" />
					<arg value="-Dversion=${version.number}" />
					<arg value="-Dpackaging=jar" />
				</exec>
			</then>
		</if>
		<if>
			<available
file="${opencms.output.sources.jars}/${module.name}-sources.jar" />
			<then>
				<!-- upload sources.jar to maven2 repository -->
				<exec executable="${mvn}">
					<arg value="deploy:deploy-file" />
					<arg
						value="-Dfile=
${opencms.output.sources.jars}/${module.name}-sources.jar" />
					<arg value="-DrepositoryId=langhua.public" />
					<arg

value="-Durl=http://maven2.langhua.org/archiva/repository/public/" />
					<arg value="-DgroupId=opencms" />
					<arg value="-DartifactId=${module.name}" />
					<arg value="-Dversion=${version.number}" />
					<arg value="-Dpackaging=sources.jar" />
				</exec>
			</then>
		</if>
	</target>

Regards,

Shi Yusen/Beijing Langhua Ltd.


在 2009-07-02四的 10:49 +0100,Achim Westermann写道:
> Hi Shi,
> 
> thanks a lot! I currently work in a project where we get our 
> dependencies via ANT / Eclipse -> Ivy... and opencms had to be put to a 
> local repository.
> 
> 
> Kind Regards,
> Achim.
> 
> -------------------
> Achim Westermann
> 
> Alkacon Software GmbH  - The OpenCms Experts
> http://www.alkacon.com - http://www.opencms.org
> 
> 
> 
> Shi Yusen schrieb:
> > Hi list,
> > 
> > We have setup a public OpenCms Maven2 Repository using Apache Archiva.
> > The repository is here:
> > http://maven2.langhua.org/public/opencms/
> > 
> > You can use Archiva to browse it:
> > http://langhua.org/portal/portal/default/iframe?pageurl=http://maven2.langhua.org/archiva/browse/opencms
> >         
> > Currently, there are OpenCms 7.0.5 and 7.5.0 in the repository. If you
> > find anything wrong or missing, please feed back to me.
> > 
> > Have fun,
> > 
> > Shi Yusen/Beijing Langhua Ltd.
> > 
> > 
> > _______________________________________________
> > This mail is sent to you from the opencms-dev mailing list
> > To change your list options, or to unsubscribe from the list, please visit
> > http://lists.opencms.org/mailman/listinfo/opencms-dev
> 
> 
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://lists.opencms.org/mailman/listinfo/opencms-dev




More information about the opencms-dev mailing list