Kaydet (Commit) 1fd41f43 authored tarafından David Ostrovsky's avatar David Ostrovsky Kaydeden (comit) Thorsten Behrens

Add build toolchain to upload LibreOffice API to Maven Central

Set up the toolchain to create sources and javadocs artifacts in
addition to JARs created during the build. Use Buck build tool for
that: [1]. This is a fork of Google's build tool Blaze, created by
Xooglers at Facebook. This build tool (like Blaze itself) uses
Python to write build files.

Add needed tools and build files to install LibreOffice API artifacts
to local Maven repository or deploy them to Maven Central.

To build all needed artifacts LibreOffice must be built regularly
with GNU make first. To build the rest of the API (sources and
javadocs):

  $> buck build api

To replace version number with upcoming release version:

  $> solenv/bin/version.py 5.1.0

To install the API to local Maven repository:

  $> buck build api_install

To deploy the API to Maven Central:

  $> buck build api_deploy

Detailed documentation is added to document the prerequisites and
the workflow to upload LibreOffice API to Maven Central.

* [1] https://buckbuild.com

Change-Id: Ibdd552a01110836703bc069abe829b9921491cac
Reviewed-on: https://gerrit.libreoffice.org/20343Reviewed-by: 's avatarThorsten Behrens <Thorsten.Behrens@CIB.de>
Tested-by: 's avatarThorsten Behrens <Thorsten.Behrens@CIB.de>
üst 44286a37
[alias]
api = //:api
api_install = //solenv/maven:api_install
api_deploy = //solenv/maven:api_deploy
[buildfile]
includes = //solenv/buck/build.defs
[project]
ignore = .git,workdir,instdir
[cache]
mode = dir
6659a474fb2ba6e921bb38c1b55d4c9ba6073cfa
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
# #
# where stuff is built # where stuff is built
/buck-out
/instdir /instdir
/instdir_for_build /instdir_for_build
/workdir /workdir
...@@ -75,6 +76,7 @@ ...@@ -75,6 +76,7 @@
\#* \#*
*.kdev4 *.kdev4
.kdev_include_paths .kdev_include_paths
.buckd
.directory .directory
.cproject .cproject
.project .project
......
prebuilt_jar(
name = 'juh',
binary_jar = 'instdir/program/classes/juh.jar',
visibility = ['PUBLIC'],
)
prebuilt_jar(
name = 'jurt',
binary_jar = 'instdir/program/classes/jurt.jar',
visibility = ['PUBLIC'],
)
prebuilt_jar(
name = 'officebean',
binary_jar = 'instdir/program/classes/officebean.jar',
visibility = ['PUBLIC'],
)
prebuilt_jar(
name = 'ridl',
binary_jar = 'instdir/program/classes/ridl.jar',
visibility = ['PUBLIC'],
)
prebuilt_jar(
name = 'unoil',
binary_jar = 'instdir/program/classes/unoil.jar',
visibility = ['PUBLIC'],
)
prebuilt_jar(
name = 'unoloader',
binary_jar = 'instdir/program/classes/unoloader.jar',
visibility = ['PUBLIC'],
)
zip_file(
name = 'api',
srcs = [
':juh',
'//javaunohelper:juh-src',
'//javaunohelper:juh-javadoc',
':jurt',
'//jurt:jurt-src',
'//jurt:jurt-javadoc',
':officebean',
'//bean:officebean-src',
'//bean:officebean-javadoc',
':ridl',
'//ridljar:ridl-src',
'//ridljar:ridl-javadoc',
':unoil',
'//unoil:unoil-src',
'//unoil:unoil-javadoc',
':unoloader',
'//ridljar/source/unoloader:unoloader-src',
'//ridljar/source/unoloader:unoloader-javadoc',
]
)
java_sources(
name = 'officebean-src',
srcs = glob(['com/**']),
visibility = ['PUBLIC'],
)
java_doc(
name = 'officebean-javadoc',
title = 'LibreOffice API',
pkgs = [
'com.sun.star.comp.beans',
],
paths = ['.'],
srcs = glob(['com/**']),
deps = [
'//:juh',
'//:officebean',
'//:unoil',
'//:ridl',
],
visibility = ['PUBLIC'],
)
...@@ -79,7 +79,7 @@ public class LocalOfficeWindow ...@@ -79,7 +79,7 @@ public class LocalOfficeWindow
* Receives a notification about the connection has been closed. * Receives a notification about the connection has been closed.
* This method has to set the connection to <code>null</code>. * This method has to set the connection to <code>null</code>.
* *
* @source The event object. * @param source The event object.
*/ */
public void disposing(EventObject source) public void disposing(EventObject source)
{ {
......
...@@ -23,11 +23,9 @@ import com.sun.star.uno.UnoRuntime; ...@@ -23,11 +23,9 @@ import com.sun.star.uno.UnoRuntime;
// @requirement FUNC.PERF.LRN/0.6 // @requirement FUNC.PERF.LRN/0.6
// @requirement FUNC.PERF.LOC/0.6 // @requirement FUNC.PERF.LOC/0.6
// @requirement FUNC.PERF.FIX/0.6 // @requirement FUNC.PERF.FIX/0.6
// @requirement FUNC.RES.OTH/0.2
// No other resources are needed yet.
/** This is the basic JavaBean for all OOo application modules. /** This is the basic JavaBean for all OOo application modules.
@requirement FUNC.RES.OTH/0.2
No other resources are needed yet.
@since OOo 2.0.0 @since OOo 2.0.0
*/ */
public class OOoBean public class OOoBean
...@@ -80,7 +78,8 @@ public class OOoBean ...@@ -80,7 +78,8 @@ public class OOoBean
} }
// @requirement FUNC.PER/0.2 // @requirement FUNC.PER/0.2
/** @internal // @internal
/**
*/ */
@Deprecated @Deprecated
public void writeExternal( java.io.ObjectOutput aObjOut ) public void writeExternal( java.io.ObjectOutput aObjOut )
...@@ -89,7 +88,8 @@ public class OOoBean ...@@ -89,7 +88,8 @@ public class OOoBean
} }
// @requirement FUNC.PER/0.2 // @requirement FUNC.PER/0.2
/** @internal // @internal
/**
*/ */
@Deprecated @Deprecated
public void readExternal( java.io.ObjectInput aObjIn ) public void readExternal( java.io.ObjectInput aObjIn )
...@@ -155,9 +155,8 @@ public class OOoBean ...@@ -155,9 +155,8 @@ public class OOoBean
nOOoCheckCycle = nMilliSecs; nOOoCheckCycle = nMilliSecs;
} }
// @internal
/** Sets a connection to an OOo instance. /** Sets a connection to an OOo instance.
@internal
*/ */
private synchronized void setOOoConnection(OfficeConnection iNewConnection) private synchronized void setOOoConnection(OfficeConnection iNewConnection)
throws HasConnectionException, NoConnectionException { throws HasConnectionException, NoConnectionException {
...@@ -927,7 +926,7 @@ public class OOoBean ...@@ -927,7 +926,7 @@ public class OOoBean
/** returns the <type scope="com::sun::star::frame">Frame</a> /** returns the <type scope="com::sun::star::frame">Frame</a>
of the bean. of the bean.
@returns @return
a Java class which implements all interfaces which the service a Java class which implements all interfaces which the service
<type scope="com::sun::star::frame">Frame</a> implements. <type scope="com::sun::star::frame">Frame</a> implements.
Thus, methods can be called directly without queryInterface. Thus, methods can be called directly without queryInterface.
...@@ -950,7 +949,7 @@ public class OOoBean ...@@ -950,7 +949,7 @@ public class OOoBean
// @requirement API.SIM.SEAP/0.2 // @requirement API.SIM.SEAP/0.2
/** returns the <type scope="com::sun::star::frame::Controller"> of the bean. /** returns the <type scope="com::sun::star::frame::Controller"> of the bean.
@returns @return
a Java class which implements all interfaces which the service a Java class which implements all interfaces which the service
<type scope="com::sun::star::frame">Controller</a> implements. <type scope="com::sun::star::frame">Controller</a> implements.
Thus, methods can be called directly without queryInterface. Thus, methods can be called directly without queryInterface.
...@@ -978,7 +977,7 @@ public class OOoBean ...@@ -978,7 +977,7 @@ public class OOoBean
/** returns the <type scope="com::sun::star::document::OfficeDocument"> /** returns the <type scope="com::sun::star::document::OfficeDocument">
of the bean. of the bean.
@returns @return
a Java class which implements all interfaces which the service a Java class which implements all interfaces which the service
<type scope="com::sun::star::document">OfficeDocument</a> <type scope="com::sun::star::document">OfficeDocument</a>
implements. implements.
...@@ -1362,10 +1361,9 @@ xLayoutManager.showElement("private:resource/menubar/menubar"); ...@@ -1362,10 +1361,9 @@ xLayoutManager.showElement("private:resource/menubar/menubar");
// Helper Classes // Helper Classes
// @internal
/** Helper class to listen on the connection to learn when it dies. /** Helper class to listen on the connection to learn when it dies.
@internal
*/ */
private class EventListener private class EventListener
extends Thread extends Thread
......
java_sources(
name = 'juh-src',
srcs = glob(['com/**']),
visibility = ['PUBLIC'],
)
java_doc(
name = 'juh-javadoc',
title = 'LibreOffice Makes it easier to use UNO with Java',
pkgs = [
'com.sun.star',
],
paths = ['.'],
srcs = glob(['com/**']),
deps = [
'//:juh',
],
visibility = ['PUBLIC'],
)
java_sources(
name = 'jurt-src',
srcs = glob(['com/**']),
visibility = ['PUBLIC'],
)
java_doc(
name = 'jurt-javadoc',
title = 'LibreOffice Java Uno Runtime',
pkgs = [
'com.sun.star',
],
paths = ['.'],
srcs = glob(['com/**']),
deps = [
'//:jurt',
'//:unoloader',
],
visibility = ['PUBLIC'],
)
java_sources(
name = 'ridl-src',
srcs = glob(['com/**']),
visibility = ['PUBLIC'],
)
java_doc(
name = 'ridl-javadoc',
title = 'LibreOffice types for the Java Uno typesystem',
pkgs = [
'com.sun.star',
],
paths = ['.'],
srcs = glob(['com/**']),
deps = [
'//:ridl',
],
visibility = ['PUBLIC'],
)
java_sources(
name = 'unoloader-src',
srcs = glob(['com/**']),
visibility = ['PUBLIC'],
)
java_doc(
name = 'unoloader-javadoc',
title = 'LibreOffice Uno loader',
pkgs = [
'com.sun.star.lib.unoloader',
],
paths = ['.'],
srcs = glob(['com/**']),
deps = [
'//:ridl',
],
visibility = ['PUBLIC'],
)
#!/usr/bin/env python
from __future__ import print_function
from optparse import OptionParser
import os.path
import re
import sys
M = {
'juh': 'javaunohelper',
'jurt': 'jurt',
'officebean': 'bean',
'ridl': 'ridljar',
'unoil': 'unoil',
'unoloader': 'ridljar',
}
parser = OptionParser()
_, args = parser.parse_args()
if not len(args):
parser.error('not enough arguments')
elif len(args) > 1:
parser.error('too many arguments')
DEST = r'\g<1>%s\g<3>' % args[0]
def replace_in_file(filename, src_pattern):
try:
f = open(filename, "r")
s = f.read()
f.close()
s = re.sub(src_pattern, DEST, s)
f = open(filename, "w")
f.write(s)
f.close()
except IOError as err:
print('error updating %s: %s' % (filename, err), file=sys.stderr)
src_pattern = re.compile(r'^(\s*<version>)([-.@\w]+)(</version>\s*)$',
re.MULTILINE)
for a in ['juh', 'jurt', 'officebean', 'ridl', 'unoil', 'unoloader']:
replace_in_file(os.path.join(M[a], 'pom.%s.xml' % a), src_pattern)
src_pattern = re.compile(r"^(LIBREOFFICE_VERSION = ')([-.@\w]+)(')$",
re.MULTILINE)
replace_in_file('solenv/maven/VERSION', src_pattern)
def java_sources(
name,
srcs,
visibility = []
):
java_library(
name = name,
resources = srcs,
visibility = visibility,
)
def java_doc(
name,
title,
pkgs,
paths,
srcs = [],
deps = [],
visibility = [],
do_it_wrong = False,
):
if do_it_wrong:
sourcepath = paths
else:
sourcepath = ['$SRCDIR/' + n for n in paths]
genrule(
name = name,
cmd = ' '.join([
'while ! test -f .buckconfig; do cd ..; done;',
'javadoc',
'-quiet',
'-protected',
'-encoding UTF-8',
'-charset UTF-8',
'-notimestamp',
'-windowtitle "' + title + '"',
'-link http://docs.oracle.com/javase/7/docs/api',
'-subpackages ',
':'.join(pkgs),
'-sourcepath ',
':'.join(sourcepath),
' -classpath ',
':'.join(['$(location %s)' % n for n in deps]),
'-d $TMP',
]) + ';jar cf $OUT -C $TMP .',
srcs = srcs,
out = name + '.jar',
visibility = visibility,
)
include_defs('//solenv/maven/VERSION')
include_defs('//solenv/maven/package.defs')
URL = 'https://oss.sonatype.org/content/repositories/snapshots' \
if LIBREOFFICE_VERSION.endswith('-SNAPSHOT') else \
'https://oss.sonatype.org/service/local/staging/deploy/maven2'
maven_package(
repository = 'sonatype-nexus-staging',
url = URL,
version = LIBREOFFICE_VERSION,
jar = {
'juh': '//:juh',
'jurt': '//:jurt',
'officebean': '//:officebean',
'ridl': '//:ridl',
'unoil': '//:unoil',
'unoloader': '//:unoloader',
},
src = {
'juh': '//javaunohelper:juh-src',
'jurt': '//jurt:jurt-src',
'officebean': '//bean:officebean-src',
'ridl': '//ridljar:ridl-src',
'unoil': '//unoil:unoil-src',
'unoloader': '//ridljar/source/unoloader:unoloader-src',
},
doc = {
'juh': '//javaunohelper:juh-javadoc',
'jurt': '//jurt:jurt-javadoc',
'officebean': '//bean:officebean-javadoc',
'ridl': '//ridljar:ridl-javadoc',
'unoil': '//unoil:unoil-javadoc',
'unoloader': '//ridljar/source/unoloader:unoloader-javadoc',
},
)
python_binary(
name = 'mvn',
main = 'mvn.py',
)
This diff is collapsed.
# Maven style API version (e.g. '2.x-SNAPSHOT').
#
# Used by :install and :deploy when talking to the destination repository. As
# we currently have no stable releases, we use the "build number" scheme
# described at:
# http://mojo.codehaus.org/versions-maven-plugin/version-rules.html
LIBREOFFICE_VERSION = '@version@'
...@@ -7,19 +7,25 @@ ...@@ -7,19 +7,25 @@
from __future__ import print_function from __future__ import print_function
from optparse import OptionParser from optparse import OptionParser
from os import path from os import path, environ
from subprocess import check_output
from sys import stderr from sys import stderr
try:
from subprocess import check_output M = {
except ImportError: 'juh': 'javaunohelper',
from subprocess import Popen, PIPE 'jurt': 'jurt',
def check_output(*cmd): 'officebean': 'bean',
return Popen(*cmd, stdout=PIPE).communicate()[0] 'ridl': 'ridljar',
'unoil': 'unoil',
'unoloader': 'ridljar',
}
opts = OptionParser() opts = OptionParser()
opts.add_option('--repository', help='maven repository id') opts.add_option('--repository', help='maven repository id')
opts.add_option('--url', help='maven repository url') opts.add_option('--url', help='maven repository url')
opts.add_option('-o')
opts.add_option('-a', help='action (valid actions are: install,deploy)') opts.add_option('-a', help='action (valid actions are: install,deploy)')
opts.add_option('-v', help='libreoffice version') opts.add_option('-v', help='gerrit version')
opts.add_option('-s', action='append', help='triplet of artifactId:type:path') opts.add_option('-s', action='append', help='triplet of artifactId:type:path')
args, ctx = opts.parse_args() args, ctx = opts.parse_args()
...@@ -27,34 +33,45 @@ if not args.v: ...@@ -27,34 +33,45 @@ if not args.v:
print('version is empty', file=stderr) print('version is empty', file=stderr)
exit(1) exit(1)
common = [ root = path.abspath(__file__)
'-DgroupId=org.libreoffice', while not path.exists(path.join(root, '.buckconfig')):
'-Dversion=%s' % args.v, root = path.dirname(root)
]
self = path.dirname(path.abspath(__file__))
mvn = ['mvn', '--file', path.join(self, 'fake_pom.xml')]
if 'install' == args.a: if 'install' == args.a:
cmd = mvn + ['install:install-file'] + common cmd = [
'mvn',
'install:install-file',
'-Dversion=%s' % args.v,
]
elif 'deploy' == args.a: elif 'deploy' == args.a:
cmd = mvn + [ cmd = [
'deploy:deploy-file', 'mvn',
'gpg:sign-and-deploy-file',
'-DrepositoryId=%s' % args.repository, '-DrepositoryId=%s' % args.repository,
'-Durl=%s' % args.url, '-Durl=%s' % args.url,
] + common ]
else: else:
print("unknown action -a %s" % args.a, file=stderr) print("unknown action -a %s" % args.a, file=stderr)
exit(1) exit(1)
for spec in args.s: for spec in args.s:
artifact, packaging_type, src = spec.split(':') artifact, packaging_type, src = spec.split(':')
exe = cmd + [
'-DpomFile=%s' % path.join(root, '%s/pom.%s.xml' % (M[artifact], artifact)),
'-Dpackaging=%s' % packaging_type,
'-Dfile=%s' % src,
]
try: try:
check_output(cmd + [ if environ.get('VERBOSE'):
'-DartifactId=%s' % artifact, print(' '.join(exe), file=stderr)
'-Dpackaging=%s' % packaging_type, check_output(exe)
'-Dfile=%s' % src,
])
except Exception as e: except Exception as e:
print('%s command failed: %s' % (args.a, e), file=stderr) print('%s command failed: %s' % (args.a, e), file=stderr)
exit(1) exit(1)
with open(args.o, 'w') as fd:
if args.repository:
print('Repository: %s' % args.repository, file=fd)
if args.url:
print('URL: %s' % args.url, file=fd)
print('Version: %s' % args.v, file=fd)
def maven_package(
version,
repository = None,
url = None,
jar = {},
src = {},
doc = {}):
cmd = ['$(exe //solenv/maven:mvn)', '-v', version, '-o', '$OUT']
api_cmd = []
for type,d in [('jar', jar), ('java-source', src), ('javadoc', doc)]:
for a,t in d.iteritems():
api_cmd.append('-s %s:%s:$(location %s)' % (a,type,t))
genrule(
name = 'api_install',
cmd = ' '.join(cmd + api_cmd + ['-a', 'install']),
out = 'api_install.info',
)
if repository and url:
genrule(
name = 'api_deploy',
cmd = ' '.join(cmd + api_cmd + [
'-a', 'deploy',
'--repository', repository,
'--url', url]),
out = 'api_deploy.info',
)
genrule(
name = 'unoil-src',
cmd = ' && '.join([
'cd $TMP',
'echo "FAKE SOURCE ARCHIVE" > README',
'zip -qr $OUT *',
]),
out = 'unoil-src.jar',
visibility = ['PUBLIC'],
)
genrule(
name = 'unoil-javadoc',
cmd = ' && '.join([
'cd $TMP',
'echo "FAKE JAVADOC ARCHIVE" > README',
'zip -qr $OUT *',
]),
out = 'unoil-javadoc.jar',
visibility = ['PUBLIC'],
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment