mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-14 20:17:25 +00:00
Merge branch 'master' into extensionmethod
Conflicts: build.xml
This commit is contained in:
commit
82ac8aad1d
217 files changed
+5704
-2418
No files matched your search
@@ -9,6 +9,7 @@ Christian Sterzl <christian.sterzl@gmail.com>
|
||||
DaveLaw <project.lombok@apconsult.de>
|
||||
Dave Brosius <dbrosius@mebigfatguy.com>
|
||||
Dawid Rusin <dawidrusin90@gmail.com>
|
||||
Denis Stepanov <denis.stepanov@gmail.com>
|
||||
Emil Lundberg <emil@yubico.com>
|
||||
Enrique da Costa Cambio <enrique.dacostacambio@gmail.com>
|
||||
Jacob Middag <jacob@gaddim.nl>
|
||||
@@ -34,6 +35,8 @@ Robbert Jan Grootjans <grootjans@gmail.com>
|
||||
Robert Wertman <robert.wertman@gmail.com>
|
||||
Roel Spilker <r.spilker@gmail.com>
|
||||
Roland Praml <pram@gmx.de>
|
||||
Rostislav Krasny <45571812+rosti-il@users.noreply.github.com>
|
||||
Samuel Pereira <samuel.p.araujo@gmail.com>
|
||||
Sander Koning <askoning@gmail.com>
|
||||
Szymon Pacanowski <spacanowski@gmail.com>
|
||||
Taiki Sugawara <buzz.taiki@gmail.com>
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
<!--
|
||||
Copyright (C) 2010-2020 The Project Lombok Authors.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
-->
|
||||
<project name="lombok.build-support" default="dist" xmlns:ivy="antlib:com.zwitserloot.ivyplusplus" basedir="..">
|
||||
<description>
|
||||
This buildfile is part of projectlombok.org. It is responsible for tasks that help with setting up the build infrastructure.
|
||||
None of these tasks are normally needed, unless modifying how the build works, such as updating dependencies.
|
||||
</description>
|
||||
|
||||
<condition property="executable.suffix" value=".exe" else="">
|
||||
<os family="windows" />
|
||||
</condition>
|
||||
|
||||
<condition property="java_home.exe" value="/usr/libexec/java_home">
|
||||
<os family="mac" />
|
||||
</condition>
|
||||
|
||||
<target name="-ask.target-jdk.via-javahome" if="java_home.exe" unless="target.jdk">
|
||||
<input addproperty="target.jdk.ver">You need to specify the JDK9+ jdk whose jdk.compiler and java.compiler modules are to be converted. Use -Dtarget.jdk.ver=14 to automate this, or type a version in now (for example: 11):</input>
|
||||
<condition property="target.jdk.ver.missing" value="true">
|
||||
<equals arg1="${target.jdk.ver}" arg2="" trim="true" />
|
||||
</condition>
|
||||
<fail if="target.jdk.ver.missing">Aborted (no version entered)</fail>
|
||||
<exec executable="${java_home.exe}" outputproperty="target.jdk" failonerror="true">
|
||||
<arg value="-v" />
|
||||
<arg value="${target.jdk.ver}" />
|
||||
</exec>
|
||||
<echo>Using VM at: ${target.jdk}</echo>
|
||||
</target>
|
||||
|
||||
<target name="-ask.target-jdk" depends="-ask.target-jdk.via-javahome" unless="target.jdk">
|
||||
<input addproperty="target.jdk">You need to specify the JDK9+ jdk whose jdk.compiler and java.compiler modules are to be converted. Run ant with -Dtarget.jdk=/full/path/here to automate this, or type the path in now (for example: /Library/JavaVirtualMachines/jdk-14.jdk/Contents/Home):</input>
|
||||
</target>
|
||||
|
||||
<target name="make.javac-patch-jar" depends="-ask.target-jdk" description="to test javac13 on JDK14, for example, you need a jar (not a jmod), to use with --patch-modules. This task makes those.">
|
||||
<exec executable="${target.jdk}/bin/java${executable.suffix}" outputproperty="target.javac.version.full" errorproperty="target.javac.version.err">
|
||||
<arg value="--version" />
|
||||
</exec>
|
||||
<condition property="target.javac.tooearly" >
|
||||
<contains string="${target.javac.version.err}" substring="Unrecognized option" />
|
||||
</condition>
|
||||
<fail if="target.javac.tooearly">This tool converts javac as stored in jmods of JDK distributions; JDK8 and below doesn't ship like that, and you don't need this for 8 and below.</fail>
|
||||
|
||||
<delete dir="build/jdk-compiler-jar" quiet="true" />
|
||||
<mkdir dir="build/jdk-compiler-jar" />
|
||||
<echo file="build/jdk-compiler-jar/version.txt">${target.javac.version.full}</echo>
|
||||
<copy file="build/jdk-compiler-jar/version.txt" tofile="build/jdk-compiler-jar/shortversion.txt" />
|
||||
<replaceregexp file="build/jdk-compiler-jar/version.txt" match="^openjdk ([^ ]+) (\d{4}-\d{2}-\d{2}).*$" replace="\1_\2" flags="si" />
|
||||
<replaceregexp file="build/jdk-compiler-jar/shortversion.txt" match="^openjdk ([^ ]+) (\d{4}-\d{2}-\d{2}).*$" replace="\1" flags="si" />
|
||||
<loadfile property="target.javac.version" srcfile="build/jdk-compiler-jar/version.txt" />
|
||||
<loadfile property="target.javac.shortversion" srcfile="build/jdk-compiler-jar/shortversion.txt" />
|
||||
|
||||
<mkdir dir="build/jdk-compiler-jar/java.compiler" />
|
||||
<exec executable="${target.jdk}/bin/jmod${executable.suffix}">
|
||||
<arg value="--dir" />
|
||||
<arg file="build/jdk-compiler-jar/java.compiler" />
|
||||
<arg value="extract" />
|
||||
<arg file="${target.jdk}/jmods/java.compiler.jmod" />
|
||||
</exec>
|
||||
<jar destfile="build/javac${target.javac.version}-java.compiler.jar" index="true">
|
||||
<fileset dir="build/jdk-compiler-jar/java.compiler/classes" />
|
||||
<fileset dir="build/jdk-compiler-jar/java.compiler/legal" />
|
||||
</jar>
|
||||
|
||||
<mkdir dir="build/jdk-compiler-jar/jdk.compiler" />
|
||||
<exec executable="${target.jdk}/bin/jmod${executable.suffix}">
|
||||
<arg value="--dir" />
|
||||
<arg file="build/jdk-compiler-jar/jdk.compiler" />
|
||||
<arg value="extract" />
|
||||
<arg file="${target.jdk}/jmods/jdk.compiler.jmod" />
|
||||
</exec>
|
||||
<jar destfile="build/javac${target.javac.version}-jdk.compiler.jar" index="true">
|
||||
<fileset dir="build/jdk-compiler-jar/jdk.compiler/classes" />
|
||||
<fileset dir="build/jdk-compiler-jar/jdk.compiler/legal" />
|
||||
</jar>
|
||||
|
||||
<tstamp>
|
||||
<format property="target.javac.pubstamp" pattern="yyyyMMddHHmmss" />
|
||||
</tstamp>
|
||||
<echo file="buildScripts/ivy-repo/net.java.openjdk.custom-javac${target.javac.shortversion}-${target.javac.version}.xml"><ivy-module version="2.0">
|
||||
<info organisation="net.java.openjdk.custom" module="javac${target.javac.shortversion}" revision="${target.javac.version}" publication="${target.javac.pubstamp}">
|
||||
<license name="GNU General Public License v2 with Classpath Exception" url="https://openjdk.java.net/legal/gplv2+ce.html" />
|
||||
<description homepage="https://openjdk.java.net" />
|
||||
</info>
|
||||
<configurations>
|
||||
<conf name="runtime" />
|
||||
</configurations>
|
||||
<publications>
|
||||
<artifact name="javac${target.javac.shortversion}-java.compiler" conf="runtime" url="https://projectlombok.org/ivyrepo/langtools/javac${target.javac.version}-java.compiler.jar" />
|
||||
<artifact name="javac${target.javac.shortversion}-jdk.compiler" conf="runtime" url="https://projectlombok.org/ivyrepo/langtools/javac${target.javac.version}-jdk.compiler.jar" />
|
||||
</publications>
|
||||
</ivy-module></echo>
|
||||
<echo>File build/javac${target.javac.version}-java.compiler.jar and build/javac${target.javac.version}-jdk.compiler.jar are available for upload; custom ivy target made as GAV net.java.openjdk.custom::javac${target.javac.shortversion}::${target.javac.version}</echo>
|
||||
</target>
|
||||
</project>
|
||||
@@ -0,0 +1,309 @@
|
||||
<!--
|
||||
Copyright (C) 2020 The Project Lombok Authors.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
-->
|
||||
<project name="lombok.compile" default="dist" xmlns:ivy="antlib:com.zwitserloot.ivyplusplus" basedir="..">
|
||||
<description>
|
||||
This buildfile is part of projectlombok.org. It takes care of compiling and building lombok itself.
|
||||
</description>
|
||||
|
||||
<property name="mapstruct-binding.version" value="0.1.0" />
|
||||
|
||||
<!-- compiles just 'version.java' and runs the produced class file, setting up the various version properties -->
|
||||
<target name="version" depends="ipp.setup, deps.jdk-runtime" description="Shows the version number" unless="lombok.version">
|
||||
<mkdir dir="build/lombok" />
|
||||
<ivy:compile destdir="build/lombok" source="1.5" target="1.5" ecj="true" nowarn="true">
|
||||
<bootclasspath path="${jdk6-rt.loc}" />
|
||||
<src path="src/core" />
|
||||
<include name="lombok/core/Version.java" />
|
||||
</ivy:compile>
|
||||
<java
|
||||
classname="lombok.core.Version"
|
||||
classpath="build/lombok"
|
||||
failonerror="true"
|
||||
output="build/version.txt">
|
||||
<arg value="full" />
|
||||
</java>
|
||||
<ivy:loadversion property="lombok.fullversion" file="build/version.txt" />
|
||||
<java
|
||||
classname="lombok.core.Version"
|
||||
classpath="build/lombok"
|
||||
failonerror="true"
|
||||
output="build/version.txt" />
|
||||
<ivy:loadversion property="lombok.version" file="build/version.txt" />
|
||||
<echo level="info">Lombok version: ${lombok.version} (${lombok.fullversion})</echo>
|
||||
</target>
|
||||
|
||||
<target name="compile" depends="version, deps" description="Compiles the code">
|
||||
<!--
|
||||
1. Compile stubs.
|
||||
2. Compile lombok-utils.
|
||||
3. Compile transplants.
|
||||
4. Compile lombok.
|
||||
5. Run SPI processor.
|
||||
6. Create other manifest entries. -->
|
||||
|
||||
<!--
|
||||
ant includes the destination dir on the classpath (and there are good reasons to do this), but that also means
|
||||
the bleeding edge lombok from the previous build is run (as lombok is an annotation processor), which means if
|
||||
there are bugs in it, you can't compile anymore until you 'ant clean'. That's very undesirable. so we kill the processor,
|
||||
which stops lombok from running. We re-create the file at the end of this target. -->
|
||||
<delete file="build/lombok/META-INF/services/javax.annotation.processing.Processor" quiet="true" />
|
||||
|
||||
<!--
|
||||
first, compile stubs. Lombok needs to produce class files that run in a wide variety of JDK, javac, and ecj/eclipse versions.
|
||||
Instead of depending on conflicting versions, we write stub files; just enough for compilation to succeed.
|
||||
|
||||
However, the stubs themselves also have a ton of dependencies; to avoid _that_, we have stubs for stubs, too! -->
|
||||
<ivy:compile destdir="build/stubsstubs" source="1.5" target="1.5" ecj="true">
|
||||
<bootclasspath path="${jdk6-rt.loc}" />
|
||||
<src path="src/stubsstubs" />
|
||||
</ivy:compile>
|
||||
<ivy:compile destdir="build/stubs" source="1.5" target="1.5" ecj="true">
|
||||
<bootclasspath path="${jdk6-rt.loc}" />
|
||||
<src path="src/stubs" />
|
||||
<src path="src/javac-only-stubs" />
|
||||
<classpath location="build/stubsstubs" />
|
||||
<classpath location="build/stubs" />
|
||||
</ivy:compile>
|
||||
|
||||
<!--
|
||||
compile the eclipse agent's transplant sources.
|
||||
This is code that is not actually run within lombok; it is bytecode that the eclipse agent extracts from the class file
|
||||
within its own jar and injects it into the eclipse classes as a patch.
|
||||
|
||||
To keep the project clean of warnings, a few SuppressWarnings have been added, but we don't want them there during compilation,
|
||||
so remove them first.
|
||||
|
||||
For legacy eclipse support we include them in both class file format 48 (java 1.4) and 50 (java 1.6), though in practice
|
||||
we don't support eclipses that run on anything below java 1.8 anymore. -->
|
||||
<mkdir dir="build/transformedSources" />
|
||||
<copy todir="build/transformedSources">
|
||||
<fileset dir="src/eclipseAgent">
|
||||
<include name="**/*Transplants.java" />
|
||||
</fileset>
|
||||
<filterchain>
|
||||
<lineContainsRegExp negate="true">
|
||||
<regexp pattern="^\s*@SuppressWarnings.*$" />
|
||||
</lineContainsRegExp>
|
||||
</filterchain>
|
||||
</copy>
|
||||
|
||||
<ivy:compile destdir="build/lombok" source="1.4" target="1.4" ecj="true">
|
||||
<bootclasspath location="build/stubs" />
|
||||
<bootclasspath path="${jdk6-rt.loc}" />
|
||||
<src path="build/transformedSources" />
|
||||
</ivy:compile>
|
||||
|
||||
<ivy:compile destdir="build/lombok/Class50" source="1.4" target="1.6" ecj="true">
|
||||
<bootclasspath location="build/stubs" />
|
||||
<bootclasspath path="${jdk6-rt.loc}" />
|
||||
<src path="build/transformedSources" />
|
||||
</ivy:compile>
|
||||
|
||||
<ivy:compile destdir="build/lombok" source="1.5" target="1.5" ecj="true">
|
||||
<bootclasspath location="build/stubs" />
|
||||
<bootclasspath path="${jdk6-rt.loc}" />
|
||||
<src path="src/utils" />
|
||||
<exclude name="lombok/javac/**" />
|
||||
<classpath path="build/lombok" />
|
||||
<classpath refid="cp.javac6" />
|
||||
<classpath refid="cp.ecj8" />
|
||||
</ivy:compile>
|
||||
<ivy:compile destdir="build/lombok" source="1.6" target="1.6" ecj="true">
|
||||
<bootclasspath location="build/stubs" />
|
||||
<bootclasspath path="${jdk6-rt.loc}" />
|
||||
<src path="src/utils" />
|
||||
<include name="lombok/javac/**" />
|
||||
<classpath location="build/lombok" />
|
||||
<classpath refid="cp.javac6" />
|
||||
</ivy:compile>
|
||||
|
||||
<!--
|
||||
compile lombok proper. We target java 1.6 to be as compatible with older releases as we can, using a JDK6 boot rt to ensure we don't
|
||||
use API that didn't exist in those versions yet. -->
|
||||
<ivy:compile destdir="build/lombok" source="1.6" target="1.6" ecj="true" nowarn="true">
|
||||
<bootclasspath location="build/stubs" />
|
||||
<bootclasspath path="${jdk6-rt.loc}" />
|
||||
<src path="src/launch" />
|
||||
<src path="src/core" />
|
||||
<src path="src/installer" />
|
||||
<src path="src/eclipseAgent" />
|
||||
<src path="src/delombok" />
|
||||
<exclude name="**/*Transplants.java" />
|
||||
<classpath location="build/lombok" />
|
||||
<classpath refid="cp.build" />
|
||||
<classpath refid="cp.eclipse-oxygen" />
|
||||
<classpath refid="cp.javac6" />
|
||||
</ivy:compile>
|
||||
|
||||
<!-- This is really part of the eclipse agent, but references lombok, so that had to be compiled first -->
|
||||
<ivy:compile destdir="build/lombok/Class50" source="1.5" target="1.6" ecj="true">
|
||||
<bootclasspath location="build/stubs" />
|
||||
<bootclasspath path="${jdk6-rt.loc}" />
|
||||
<src path="src/eclipseAgent" />
|
||||
<include name="lombok/launch/PatchFixesHider.java" />
|
||||
<classpath location="build/lombok" />
|
||||
<classpath refid="cp.build" />
|
||||
<classpath refid="cp.eclipse-oxygen" />
|
||||
</ivy:compile>
|
||||
|
||||
<!--
|
||||
a couple of classes to cater to the bits of javac8+ that require j8 language constructs/API types; the main lombok
|
||||
compile refers to these via reflection -->
|
||||
<ivy:compile destdir="build/lombok" source="1.8" target="1.8" ecj="true" nowarn="true" includesystembootclasspath="true">
|
||||
<bootclasspath location="build/stubs" />
|
||||
<src path="src/core8" />
|
||||
<classpath location="build/lombok" />
|
||||
<classpath refid="cp.javac8" />
|
||||
</ivy:compile>
|
||||
|
||||
<!--
|
||||
We also act as a jigsaw module so that module-based compile runs can use module-style dependency management. Obviously,
|
||||
that bit we can only compile with jdk9+. -->
|
||||
<ivy:compile destdir="build/lombok" release="9">
|
||||
<src path="src/core9" />
|
||||
<compilerarg value="-Xlint:none" />
|
||||
<classpath location="build/lombok" />
|
||||
<classpath refid="cp.build" />
|
||||
</ivy:compile>
|
||||
|
||||
<!-- Run the SPI processor to create the services files listing all lombok handlers -->
|
||||
<delete dir="build/lombok-proc-result" quiet="true" />
|
||||
<ivy:compile destdir="build/lombok-proc-result" release="9" nowarn="true">
|
||||
<classpath location="build/stubs" />
|
||||
<compilerarg value="-proc:only" />
|
||||
<compilerarg value="-processor" />
|
||||
<compilerarg value="org.mangosdk.spi.processor.SpiProcessor" />
|
||||
<src path="src/core" />
|
||||
<src path="src/installer" />
|
||||
<src path="src/eclipseAgent" />
|
||||
<src path="src/delombok" />
|
||||
<classpath location="build/lombok" />
|
||||
<classpath refid="cp.build" />
|
||||
<classpath refid="cp.javac6" />
|
||||
<classpath refid="cp.eclipse-oxygen" />
|
||||
</ivy:compile>
|
||||
|
||||
<copy todir="build/lombok">
|
||||
<fileset dir="build/lombok-proc-result">
|
||||
<include name="META-INF/services/*" />
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<mkdir dir="build/lombok/META-INF" />
|
||||
<mkdir dir="build/lombok/META-INF/services" />
|
||||
<echo file="build/lombok/META-INF/services/javax.annotation.processing.Processor">lombok.launch.AnnotationProcessorHider$AnnotationProcessor
|
||||
lombok.launch.AnnotationProcessorHider$ClaimingProcessor</echo>
|
||||
<mkdir dir="build/lombok/META-INF/gradle" />
|
||||
<echo file="build/lombok/META-INF/gradle/incremental.annotation.processors">lombok.launch.AnnotationProcessorHider$AnnotationProcessor,isolating
|
||||
lombok.launch.AnnotationProcessorHider$ClaimingProcessor,isolating</echo>
|
||||
</target>
|
||||
|
||||
<!-- compiles the bit of API from mapstruct that lombok compiles against. -->
|
||||
<target name="mapstruct.compile">
|
||||
<mkdir dir="build/mapstruct" />
|
||||
<ivy:compile destdir="build/mapstruct" release="9">
|
||||
<src path="src/j9stubs" />
|
||||
</ivy:compile>
|
||||
<mkdir dir="build/lombok/secondaryLoading.SCL.lombok/org/mapstruct/ap/spi" />
|
||||
<move
|
||||
file="build/mapstruct/org/mapstruct/ap/spi/AstModifyingAnnotationProcessor.class"
|
||||
tofile="build/lombok/secondaryLoading.SCL.lombok/org/mapstruct/ap/spi/AstModifyingAnnotationProcessor.SCL.lombok" />
|
||||
</target>
|
||||
|
||||
<target name="-deps.unpack" depends="deps">
|
||||
<ivy:cachedunjar dest="build/lombok" marker="build/unpackDeps.marker">
|
||||
<path refid="cp.stripe" />
|
||||
</ivy:cachedunjar>
|
||||
</target>
|
||||
|
||||
<target name="dist" depends="version, compile, latest-changes.build, mapstruct.compile, -deps.unpack" description="Builds the 'everything' lombok.jar">
|
||||
<mkdir dir="dist" />
|
||||
<copy file="doc/changelog.markdown" tofile="build/changelog.txt" />
|
||||
<tstamp><format property="release.timestamp" pattern="yyyy-MM-dd" /></tstamp>
|
||||
<echo file="release-timestamp.txt">${release.timestamp}</echo>
|
||||
|
||||
<!-- the ant jar task doesn't quite let us do all we need to, so build with zip, then do the jar bits afterwards -->
|
||||
<zip destfile="dist/lombok-${lombok.version}.jar">
|
||||
<fileset dir="build" includes="changelog.txt, latestchanges.html" />
|
||||
<fileset dir="." includes="README.md, LICENSE, AUTHORS, release-timestamp.txt" />
|
||||
|
||||
<!--
|
||||
most class files that need to be in the lombok distro are loaded in a separate class loader;
|
||||
we want any project that includes lombok.jar as a dependency to NOT get a bunch of otherwise public
|
||||
lombok classes served up in autocomplete dialogs, amongst other reasons.
|
||||
|
||||
Thus, we list here only the few class files that serve as 'entry points'. -->
|
||||
<fileset dir="build/lombok">
|
||||
<include name="module-info.class" />
|
||||
<include name="lombok/*.class" />
|
||||
<include name="lombok/experimental/**" />
|
||||
<include name="lombok/extern/**" />
|
||||
<include name="lombok/launch/**" />
|
||||
<include name="lombok/delombok/ant/Tasks*" />
|
||||
<include name="lombok/javac/apt/Processor.class" />
|
||||
<include name="lombok/META-INF/**" />
|
||||
</fileset>
|
||||
|
||||
<!-- now include everything else but renamed for the shadowloader system, to make these clsases invisible to other projects. -->
|
||||
<mappedresources>
|
||||
<fileset dir="build/lombok">
|
||||
<exclude name="com/sun/tools/javac/**" />
|
||||
<exclude name="module-info.class" />
|
||||
<exclude name="lombok/*.class" />
|
||||
<exclude name="lombok/experimental/**" />
|
||||
<exclude name="lombok/extern/**" />
|
||||
<exclude name="lombok/launch/**" />
|
||||
<exclude name="lombok/delombok/ant/Tasks*" />
|
||||
<exclude name="lombok/javac/apt/Processor.class" />
|
||||
<exclude name="lombok/META-INF/**" />
|
||||
</fileset>
|
||||
<firstmatchmapper>
|
||||
<globmapper from="*.class" to="*.SCL.lombok" />
|
||||
<identitymapper />
|
||||
</firstmatchmapper>
|
||||
</mappedresources>
|
||||
</zip>
|
||||
|
||||
<!-- ... but manifest is not part of the ant zip task, so do that with the jar task -->
|
||||
<jar destfile="dist/lombok-${lombok.version}.jar" update="true">
|
||||
<manifest>
|
||||
<attribute name="Premain-Class" value="lombok.launch.Agent" />
|
||||
<attribute name="Agent-Class" value="lombok.launch.Agent" />
|
||||
<attribute name="Can-Redefine-Classes" value="true" />
|
||||
<attribute name="Main-Class" value="lombok.launch.Main" />
|
||||
<attribute name="Lombok-Version" value="${lombok.version}" />
|
||||
</manifest>
|
||||
</jar>
|
||||
<delete file="release-timestamp.txt" />
|
||||
<copy overwrite="true" tofile="dist/lombok.jar" file="dist/lombok-${lombok.version}.jar" />
|
||||
<property name="lombok.dist.built" value="true" />
|
||||
</target>
|
||||
|
||||
<target name="compile.support" depends="ipp.setup, deps" description="Compiles code that is used solely by the build, such as website and IDE project creation">
|
||||
<ivy:compile includeDestClasses="false" includeantruntime="false" destdir="build/support" debug="on" source="1.8" target="1.8">
|
||||
<compilerarg value="-proc:none" />
|
||||
<compilerarg value="-Xlint:-options" />
|
||||
<classpath refid="cp.buildtools" />
|
||||
<src path="src/support" />
|
||||
</ivy:compile>
|
||||
</target>
|
||||
</project>
|
||||
@@ -0,0 +1,212 @@
|
||||
<!--
|
||||
Copyright (C) 2010-2020 The Project Lombok Authors.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
-->
|
||||
<project name="lombok.create-eclipse-project" default="" xmlns:ivy="antlib:com.zwitserloot.ivyplusplus" basedir="..">
|
||||
<description>
|
||||
This buildfile is part of projectlombok.org. It creates the infrastructure needed to develop lombok on eclipse.
|
||||
</description>
|
||||
|
||||
<target name="eclipse" depends="eclipse.projectfiles, eclipse.testtarget.default" description="Downloads dependencies, create eclipse project files, as well as debug/run test targets. Open this directory as project in eclipse (via import... existing projects)" />
|
||||
|
||||
<target name="eclipse.projectfiles" depends="deps">
|
||||
<ivy:eclipsegen source="1.6">
|
||||
<srcdir dir="src/core" />
|
||||
<srcdir dir="src/core8" />
|
||||
<srcdir dir="src/launch" />
|
||||
<srcdir dir="src/utils" />
|
||||
<srcdir dir="src/eclipseAgent" />
|
||||
<srcdir dir="src/installer" />
|
||||
<srcdir dir="src/delombok" />
|
||||
<srcdir dir="src/stubs" />
|
||||
<srcdir dir="src/support" />
|
||||
<srcdir dir="experimental/src" />
|
||||
<srcdir dir="test/transform/src" />
|
||||
<srcdir dir="test/core/src" />
|
||||
<srcdir dir="test/bytecode/src" />
|
||||
<srcdir dir="test/configuration/src" />
|
||||
<srcdir dir="test/stubs" />
|
||||
<conf name="build" sources="sources" />
|
||||
<conf name="javac6" sources="sources" />
|
||||
<conf name="eclipse-oxygen" sources="sources" />
|
||||
<conf name="test" sources="sources" />
|
||||
<conf name="buildtools" sources="sources" />
|
||||
<local org="org.projectlombok" name="lombok.patcher" dir="../lombok.patcher" />
|
||||
<settings>
|
||||
<url url="https://projectlombok.org/downloads/lombok.eclipse.settings" />
|
||||
</settings>
|
||||
<apt location="lib/build/projectlombok.org-spi.jar" />
|
||||
</ivy:eclipsegen>
|
||||
</target>
|
||||
|
||||
<target name="eclipse.testtarget.default" depends="deps, compile.support">
|
||||
<property name="cp.test" refid="cp.test" />
|
||||
<property name="cp.stripe" refid="cp.stripe" />
|
||||
|
||||
<java classname="lombok.eclipseCreate.CreateEclipseDebugTarget" failonerror="true">
|
||||
<classpath>
|
||||
<path refid="cp.buildtools" />
|
||||
<pathelement location="build/support" />
|
||||
</classpath>
|
||||
<arg value="name=Lombok-test Base" />
|
||||
<arg value="testType=lombok.TestBase" />
|
||||
<arg value="jvmTarget=1.8" />
|
||||
<arg value="bootpath=${jdk8-rt.loc}" />
|
||||
<arg value="conf.test=${cp.test}" />
|
||||
<arg value="conf.stripe=${cp.stripe}" />
|
||||
<arg value="favorite" />
|
||||
</java>
|
||||
|
||||
<fetchdep.eclipse version="202006" />
|
||||
<java classname="lombok.eclipseCreate.CreateEclipseDebugTarget" failonerror="true">
|
||||
<classpath>
|
||||
<path refid="cp.buildtools" />
|
||||
<pathelement location="build/support" />
|
||||
</classpath>
|
||||
<arg value="name=Lombok-test Eclipse-202006" />
|
||||
<arg value="testType=lombok.TestEclipse" />
|
||||
<arg value="shadowLoaderBased" />
|
||||
<arg value="jvmTarget=1.8" />
|
||||
<arg value="bootpath=${jdk8-rt.loc}" />
|
||||
<arg value="conf.test=${cp.test}" />
|
||||
<arg value="conf.stripe=${cp.stripe}" />
|
||||
<arg value="conf.eclipse-202006=${cp.eclipse-202006}" />
|
||||
<arg value="favorite" />
|
||||
</java>
|
||||
|
||||
<java classname="lombok.eclipseCreate.CreateEclipseDebugTarget" failonerror="true">
|
||||
<classpath>
|
||||
<path refid="cp.buildtools" />
|
||||
<pathelement location="build/support" />
|
||||
</classpath>
|
||||
<arg value="name=Lombok-test Javac14" />
|
||||
<arg value="testType=lombok.TestJavac" />
|
||||
<arg value="jvmTarget=14" />
|
||||
<arg value="conf.test=${cp.test}" />
|
||||
<arg value="conf.stripe=${cp.stripe}" />
|
||||
<arg value="favorite" />
|
||||
</java>
|
||||
</target>
|
||||
|
||||
<macrodef name="eclipse.testtarget.conf.jvmtarget">
|
||||
<attribute name="question" default="Which JDK do you want to target? Enter a version, such as '11'. Suggested (default): 8" />
|
||||
<attribute name="validargs" default="6,8,11,14" />
|
||||
<sequential>
|
||||
<property name="cp.test" refid="cp.test" />
|
||||
<property name="cp.stripe" refid="cp.stripe" />
|
||||
|
||||
<input message="@{question}" validargs="@{validargs}" defaultvalue="8" addproperty="inputs.jvmtarget.raw" />
|
||||
|
||||
<condition property="inputs.jvmtarget" value="1.6"><equals arg1="${inputs.jvmtarget.raw}" arg2="6" /></condition>
|
||||
<condition property="inputs.jvmtarget" value="1.8"><equals arg1="${inputs.jvmtarget.raw}" arg2="8" /></condition>
|
||||
<property name="inputs" value="${inputs.jvmtarget.raw}" />
|
||||
|
||||
<condition property="inputs.bootpath" value="${jdk6-rt.loc}"><equals arg1="${inputs.jvmtarget.raw}" arg2="6" /></condition>
|
||||
<condition property="inputs.bootpath" value="${jdk8-rt.loc}"><equals arg1="${inputs.jvmtarget.raw}" arg2="8" /></condition>
|
||||
<property name="inputs.bootpath" value="0" />
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
<target name="eclipse.testtarget.javac" depends="compile.support" description="Makes an eclipse launch target for running the tests for javac">
|
||||
<eclipse.testtarget.conf.jvmtarget question="Which javac do you want to target? Enter a version, such as '11'." validargs="8,11,13,14,15" />
|
||||
|
||||
<java classname="lombok.eclipseCreate.CreateEclipseDebugTarget" failonerror="true">
|
||||
<classpath>
|
||||
<path refid="cp.buildtools" />
|
||||
<pathelement location="build/support" />
|
||||
</classpath>
|
||||
<arg value="name=Lombok-test Javac ${inputs.jvmtarget.raw}" />
|
||||
<arg value="testType=lombok.TestJavac" />
|
||||
<arg value="jvmTarget=${inputs.jvmtarget}" />
|
||||
<arg value="bootpath=${inputs.bootpath}" />
|
||||
<arg value="conf.test=${cp.test}" />
|
||||
<arg value="conf.stripe=${cp.stripe}" />
|
||||
<arg value="conf.${inputs.confname}=${inputs.confcp}" />
|
||||
<arg value="favorite" />
|
||||
</java>
|
||||
</target>
|
||||
|
||||
<target name="eclipse.testtarget.eclipse" depends="compile.support" description="Makes an eclipse launch target for running the tests for eclipse support">
|
||||
<eclipse.testtarget.conf.jvmtarget />
|
||||
|
||||
<local name="inputs.eclipsetarget" />
|
||||
<input message="Which eclipse do you want to target? Enter a version, such as 'oxygen'." validargs="oxygen" addproperty="inputs.eclipsetarget" />
|
||||
|
||||
<local name="inputs.confname" />
|
||||
<property name="inputs.confname" value="eclipse-${inputs.eclipsetarget}" />
|
||||
|
||||
<local name="inputs.confcp" />
|
||||
<property name="inputs.confcp" refid="cp.eclipse-${inputs.eclipsetarget}" />
|
||||
|
||||
<fetchdep.eclipse version="${inputs.eclipsetarget}" />
|
||||
|
||||
<java classname="lombok.eclipseCreate.CreateEclipseDebugTarget" failonerror="true">
|
||||
<classpath>
|
||||
<path refid="cp.buildtools" />
|
||||
<pathelement location="build/support" />
|
||||
</classpath>
|
||||
<arg value="name=Lombok-test Eclipse-${inputs.eclipsetarget}" />
|
||||
<arg value="testType=lombok.TestEclipse" />
|
||||
<arg value="shadowLoaderBased" />
|
||||
<arg value="jvmTarget=${inputs.jvmtarget}" />
|
||||
<arg value="bootpath=${inputs.bootpath}" />
|
||||
<arg value="conf.test=${cp.test}" />
|
||||
<arg value="conf.stripe=${cp.stripe}" />
|
||||
<arg value="conf.${inputs.confname}=${inputs.confcp}" />
|
||||
<arg value="favorite" />
|
||||
</java>
|
||||
</target>
|
||||
|
||||
<target name="eclipse.testtarget.ecj" depends="compile.support" description="Makes an eclipse launch target for running the tests for ecj support">
|
||||
<eclipse.testtarget.conf.jvmtarget />
|
||||
|
||||
<local name="inputs.ecjtarget" />
|
||||
<input message="Which ecj do you want to target? Enter a version, such as '8'." validargs="8,11,14" addproperty="inputs.ecjtarget" />
|
||||
|
||||
<local name="inputs.confname" />
|
||||
<property name="inputs.confname" value="ecj${inputs.ecjtarget}" />
|
||||
|
||||
<local name="inputs.confcp" />
|
||||
<property name="inputs.confcp" refid="cp.ecj${inputs.ecjtarget}" />
|
||||
|
||||
<local name="inputs.bootpath" />
|
||||
<condition property="inputs.bootpath" value="${jdk6-rt.loc}"><equals arg1="${inputs.jvmtarget.raw}" arg2="6" /></condition>
|
||||
<condition property="inputs.bootpath" value="${jdk8-rt.loc}"><equals arg1="${inputs.jvmtarget.raw}" arg2="8" /></condition>
|
||||
<property name="inputs.bootpath" value="0" />
|
||||
|
||||
<fetchdep.ecj version="${inputs.ecjtarget}" />
|
||||
|
||||
<java classname="lombok.eclipseCreate.CreateEclipseDebugTarget" failonerror="true">
|
||||
<classpath>
|
||||
<path refid="cp.buildtools" />
|
||||
<pathelement location="build/support" />
|
||||
</classpath>
|
||||
<arg value="name=Lombok-test ECJ${inputs.ecjtarget}" />
|
||||
<arg value="testType=lombok.TestEclipse" />
|
||||
<arg value="shadowLoaderBased" />
|
||||
<arg value="jvmTarget=${inputs.jvmtarget}" />
|
||||
<arg value="bootpath=${inputs.bootpath}" />
|
||||
<arg value="conf.test=${cp.test}" />
|
||||
<arg value="conf.stripe=${cp.stripe}" />
|
||||
<arg value="conf.${inputs.confname}=${inputs.confcp}" />
|
||||
<arg value="favorite" />
|
||||
</java>
|
||||
</target>
|
||||
</project>
|
||||
@@ -0,0 +1,58 @@
|
||||
<!--
|
||||
Copyright (C) 2010-2020 The Project Lombok Authors.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
-->
|
||||
<project name="lombok.create-intellij-project" default="" xmlns:ivy="antlib:com.zwitserloot.ivyplusplus" basedir="..">
|
||||
<description>
|
||||
This buildfile is part of projectlombok.org. It creates the infrastructure needed to develop lombok on intellij.
|
||||
</description>
|
||||
|
||||
<target name="intellij" depends="deps" description="Creates intellij project files and downloads all dependencies. Open this directory as a project in IntelliJ after running this target">
|
||||
<echo> ** WARNING ** The core lombok contributors all use eclipse to develop lombok. This script will attempt to set up your lombok directory up as intellij project; whether can be used in a modern intellij is currently unknown. Please do continue, but be aware that trying to work on lombok from intellij may run into problems. If you want to adopt 'work on lombok via intellij' as a task, we're open to it!</echo>
|
||||
<echo>NOT IMPLEMENTED: The project should optimally be configured as a java1.6, using the rt.jar in lib/openjdk6_rt.jar as boot basis, to ensure lombok remains 1.6 compatible.</echo>
|
||||
<echo>NOT IMPLEMENTED: Ability to run tests targeted at a specific jvm/javac/ecj/eclipse release; the relevant entrypoint test classes are lombok.RunBaseAndJavacTests and lombok.RunEclipseTests - you can run the eclipse tests even on intellij; an eclipse installation is not required.</echo>
|
||||
<input>Press return to continue</input>
|
||||
<ivy:intellijgen>
|
||||
<conf name="build" sources="contrib" />
|
||||
<conf name="test" sources="contrib" />
|
||||
<module name="lombok" depends="build, test">
|
||||
<srcdir dir="src/core" />
|
||||
<srcdir dir="src/core8" />
|
||||
<srcdir dir="src/launch" />
|
||||
<srcdir dir="src/utils" />
|
||||
<srcdir dir="src/eclipseAgent" />
|
||||
<srcdir dir="src/installer" />
|
||||
<srcdir dir="src/delombok" />
|
||||
<srcdir dir="src/stubs" />
|
||||
<srcdir dir="src/support" />
|
||||
<srcdir dir="experimental/src" />
|
||||
<srcdir dir="test/transform/src" test="true" />
|
||||
<srcdir dir="test/core/src" test="true" />
|
||||
<srcdir dir="test/bytecode/src" test="true" />
|
||||
<srcdir dir="test/configuration/src" test="true" />
|
||||
<srcdir dir="test/stubs" test="true" />
|
||||
</module>
|
||||
<settings>
|
||||
<url url="https://projectlombok.org/downloads/lombok.intellij.settings" />
|
||||
</settings>
|
||||
<apt enabled="true" />
|
||||
</ivy:intellijgen>
|
||||
</target>
|
||||
</project>
|
||||
@@ -1,35 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="org.eclipse.pde.ui.RuntimeWorkbench">
|
||||
<booleanAttribute key="append.args" value="true"/>
|
||||
<booleanAttribute key="askclear" value="false"/>
|
||||
<booleanAttribute key="automaticAdd" value="true"/>
|
||||
<booleanAttribute key="automaticValidate" value="false"/>
|
||||
<stringAttribute key="bootstrap" value=""/>
|
||||
<stringAttribute key="checked" value="[NONE]"/>
|
||||
<booleanAttribute key="clearConfig" value="false"/>
|
||||
<booleanAttribute key="clearws" value="false"/>
|
||||
<booleanAttribute key="clearwslog" value="true"/>
|
||||
<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/LombokizedEclipse"/>
|
||||
<booleanAttribute key="default" value="true"/>
|
||||
<booleanAttribute key="includeOptional" value="true"/>
|
||||
<stringAttribute key="location" value="${project_loc:lombok}/debug/workspace"/>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_id" value="org.eclipse.pde.ui.launcher.PDESourceLookupDirector"/>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <sourceLookupDirector> <sourceContainers duplicates="false"> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;javaProject name=&quot;lombok&quot;/&gt;&#10;" typeId="org.eclipse.jdt.launching.sourceContainer.javaProject"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;javaProject name=&quot;lombok.patcher&quot;/&gt;&#10;" typeId="org.eclipse.jdt.launching.sourceContainer.javaProject"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;default/&gt;&#10;" typeId="org.eclipse.debug.core.containerType.default"/> </sourceContainers> </sourceLookupDirector> "/>
|
||||
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
|
||||
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl}"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms40m -Xmx512m -XX:MaxPermSize=256m -Dorg.eclipse.swt.internal.carbon.smallFonts -javaagent:${project_loc:lombok}/dist/lombok.jar -Xbootclasspath/a:${project_loc:lombok}/dist/lombok.jar -Dlombok.patcher.patchDebugDir=${project_loc:lombok}/debug/patchedClasses"/>
|
||||
<stringAttribute key="pde.version" value="3.3"/>
|
||||
<stringAttribute key="product" value="org.eclipse.sdk.ide"/>
|
||||
<booleanAttribute key="show_selected_only" value="false"/>
|
||||
<stringAttribute key="templateConfig" value="${target_home}/configuration/config.ini"/>
|
||||
<booleanAttribute key="tracing" value="false"/>
|
||||
<booleanAttribute key="useCustomFeatures" value="false"/>
|
||||
<booleanAttribute key="useDefaultConfig" value="true"/>
|
||||
<booleanAttribute key="useDefaultConfigArea" value="true"/>
|
||||
<booleanAttribute key="useProduct" value="false"/>
|
||||
<booleanAttribute key="usefeatures" value="false"/>
|
||||
</launchConfiguration>
|
||||
@@ -19,25 +19,23 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
-->
|
||||
<project name="lombok-eclipse-p2" basedir=".." xmlns:ivy="antlib:com.zwitserloot.ivyplusplus">
|
||||
<project name="lombok.eclipsep2" basedir=".." xmlns:ivy="antlib:com.zwitserloot.ivyplusplus">
|
||||
<description>
|
||||
This buildfile is part of projectlombok.org. It is responsible for building the eclipse P2 update site.
|
||||
</description>
|
||||
|
||||
<taskdef classpath="lib/ivyplusplus.jar" resource="com/zwitserloot/ivyplusplus/antlib.xml" uri="antlib:com.zwitserloot.ivyplusplus" />
|
||||
|
||||
<target name="-p2-clean">
|
||||
<target name="eclipsep2.clean">
|
||||
<delete dir="build/p2" quiet="true" />
|
||||
</target>
|
||||
|
||||
<target name="dist-eclipse-p2" depends="build-eclipse-p2">
|
||||
<tar destfile="dist/eclipse-p2.tar.bz2" compression="bzip2">
|
||||
<tarfileset dir="build/p2" />
|
||||
</tar>
|
||||
<target name="-eclipsep2.get-epoch">
|
||||
<mkdir dir="build/p2-support" />
|
||||
<echo file="build/p2-support/Epoch.java">public class Epoch {public static void main(String[] args) {System.out.print(System.currentTimeMillis());}}</echo>
|
||||
<javac srcdir="build/p2-support" release="8" includeAntRuntime="false" destdir="build/p2-support" />
|
||||
<java classname="Epoch" classpath="build/p2-support" fork="false" outputproperty="dt.epochMillis" />
|
||||
</target>
|
||||
|
||||
<target name="build-eclipse-p2" depends="-set-epoch-millis">
|
||||
<property name="lombok.version" value="1.18.99" />
|
||||
<target name="eclipsep2.build" depends="version, -eclipsep2.get-epoch">
|
||||
<tstamp><format property="dt.year" pattern="yyyy" /></tstamp>
|
||||
<mkdir dir="build/p2" />
|
||||
<mkdir dir="build/p2/features" />
|
||||
@@ -111,10 +109,25 @@ This buildfile is part of projectlombok.org. It is responsible for building the
|
||||
<delete file="build/p2/content.xml" />
|
||||
</target>
|
||||
|
||||
<target name="-set-epoch-millis">
|
||||
<mkdir dir="build/p2-support" />
|
||||
<echo file="build/p2-support/Epoch.java">public class Epoch {public static void main(String[] args) {System.out.print(System.currentTimeMillis());}}</echo>
|
||||
<javac srcdir="build/p2-support" release="8" includeAntRuntime="false" destdir="build/p2-support" />
|
||||
<java classname="Epoch" classpath="build/p2-support" fork="false" outputproperty="dt.epochMillis" />
|
||||
<target name="eclipsep2.pack" depends="eclipsep2.build">
|
||||
<tar destfile="dist/eclipse-p2.tar.bz2" compression="bzip2">
|
||||
<tarfileset dir="build/p2" />
|
||||
</tar>
|
||||
</target>
|
||||
|
||||
<target name="eclipsep2.publish" depends="setup.ssh, eclipsep2.pack">
|
||||
<ivy:scpUpload
|
||||
from="dist/eclipse-p2.tar.bz2"
|
||||
to="/data/lombok/staging"
|
||||
server="projectlombok.org"
|
||||
username="${ssh.username}"
|
||||
keyfile="${ssh.keyfile}"
|
||||
knownHosts="ssh.knownHosts" />
|
||||
<ivy:sshExec
|
||||
cmd="/data/lombok/stagingCmd/deployP2"
|
||||
server="projectlombok.org"
|
||||
username="${ssh.username}"
|
||||
keyfile="${ssh.keyfile}"
|
||||
knownHosts="ssh.knownHosts" />
|
||||
</target>
|
||||
</project>
|
||||
@@ -1,30 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/lombok/test/core/src/lombok/RunAllTests.java"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="1"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
|
||||
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
|
||||
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
|
||||
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
|
||||
<listAttribute key="org.eclipse.jdt.launching.CLASSPATH">
|
||||
<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry containerPath="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.@JAVA_VERSION@" path="1" type="4"/> "/>
|
||||
<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/lombok/@ECJ_LOCATION@" path="3" type="2"/> "/>
|
||||
<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/lombok/@JAVAC_LOCATION@" path="3" type="2"/> "/>
|
||||
<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/lombok/lib/test/com.google.guava-guava.jar" path="3" type="2"/> "/>
|
||||
<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/lombok/lib/test/com.google.code.findbugs-findbugs.jar" path="3" type="2"/> "/>
|
||||
<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry id="org.eclipse.jdt.launching.classpathentry.defaultClasspath"> <memento exportedEntriesOnly="true" project="lombok"/> </runtimeClasspathEntry> "/>
|
||||
</listAttribute>
|
||||
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.@JAVA_VERSION@"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="lombok.RunAllTests"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="lombok"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-javaagent:dist/lombok.jar -Dshadow.override.lombok=${project_loc:lombok}/bin@PATH_SEP@${project_loc:lombok}/lib/runtime/* -Ddelombok.bootclasspath=@RT_LOCATION@"/>
|
||||
</launchConfiguration>
|
||||
@@ -0,0 +1,311 @@
|
||||
<!--
|
||||
Copyright (C) 2020 The Project Lombok Authors.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
-->
|
||||
<project name="lombok.info" basedir=".." default="quickstart">
|
||||
<target name="quickstart">
|
||||
<echo>
|
||||
Dear contributor,
|
||||
|
||||
For full instructions and information on what this project contains, run:
|
||||
|
||||
> ant help
|
||||
|
||||
If you want to get started quickly:
|
||||
|
||||
1. Run `ant eclipse`.
|
||||
2. Start up eclipse (https://www.eclipse.org/).
|
||||
3. In the menu: File > Import... > Existing Project Into Workspace
|
||||
4. Browse to this directory and import it:
|
||||
(${basedir})
|
||||
5. In eclipse: Run > Debug configurations... >
|
||||
then pick one of the configs named `Lombok test`.
|
||||
6. Run `ant dist`.
|
||||
|
||||
Have fun!</echo>
|
||||
</target>
|
||||
|
||||
<target name="help" description="Start here!">
|
||||
<echo>
|
||||
Just want to get started quickly? Run:
|
||||
|
||||
> ant quickstart
|
||||
|
||||
---
|
||||
|
||||
Lombok is specced to run on a wide array of underlying platforms:
|
||||
|
||||
* Any JVM from 1.6 up to the upcoming next official release.
|
||||
* Javac, from 1.6 up to the upcoming next official release.
|
||||
* ECJ, from ecj 4.4.2 (2015/java8) up to the upcoming next official release.
|
||||
* Eclipse, from eclipse-oxygen up to the upcoming next official release.
|
||||
|
||||
The build is a little more complicated to cater to these requirements.
|
||||
|
||||
This build script can perform the following tasks:
|
||||
* IDE
|
||||
Create project files so that you can work on lombok in eclipse or intellij.
|
||||
Includes creating debuggable test targets.
|
||||
* compile
|
||||
Turn java files into class files.
|
||||
* test
|
||||
Run the tests against the various combinations of VM, Javac, eclipse and ecj
|
||||
we support, including finding suitable VMs to run them on.
|
||||
* packaging
|
||||
Create the lombok 'everything' jar, that can serve as eclipse agent, as
|
||||
installer, as library you include on the classpath with javac, and which
|
||||
does not inject its transitive dependencies into your project namespace.
|
||||
* website
|
||||
Builds the website and documentation (projectlombok.org) from templates,
|
||||
including creating the version history page and changelog, and deploying
|
||||
builds to the website (and the maven repo hosted there).
|
||||
* p2
|
||||
We host an experimental eclipse marketplace installer.
|
||||
|
||||
For more info on any of these sections, run for example `ant help.IDE`.
|
||||
|
||||
If you're new to lombok, you should start with `ant help.IDE`,
|
||||
then move on to `ant help.test`.</echo>
|
||||
</target>
|
||||
|
||||
<target name="help.IDE">
|
||||
<echo>
|
||||
We strongly suggest you use eclipse to develop lombok.
|
||||
Experimentally, developing with intellij is possible as well.
|
||||
|
||||
IDE support consists of two features:
|
||||
1. Generate project files so that this directory can be imported as project.
|
||||
2. Generate debug/run launch files so you can debug lombok in your IDE.
|
||||
|
||||
> ant eclipse
|
||||
> ant intellij
|
||||
|
||||
These commands generate project files and download all dependencies required
|
||||
to develop Project Lombok in the named IDE. Run these commands first, then
|
||||
import this directory as project in your IDE.
|
||||
|
||||
> ant eclipse.testtarget.eclipse
|
||||
> ant eclipse.testtarget.ecj
|
||||
> ant eclipse.testtarget.javac
|
||||
|
||||
These 3 commands generate launch targets (these appear in your debug menu),
|
||||
for testing the stated platform (eclipse, ecj, or javac) and will ask you
|
||||
which version of the VM and the relevant platform are to be targeted by
|
||||
these tests. Note that `ant eclipse` already generates default test targets,
|
||||
you don't need these unless you're specifically testing lombok behaviour on
|
||||
some specific version of the JVM or a target platform.
|
||||
|
||||
NB: No debug/launch targets are currently generated for intellij.
|
||||
Got the know how? We'd love a contribution!</echo>
|
||||
</target>
|
||||
|
||||
<target name="help.compile">
|
||||
<echo>
|
||||
The build compilation system is self contained and generally invoked by the
|
||||
other jobs this build script can do; you rarely need to mess with it.
|
||||
|
||||
The compilation is quite complicated; parts of lombok are injected into
|
||||
for example eclipse at runtime via an agent mechanism. To produce the bytecode
|
||||
that is to be injected, we need to compile against various different versions
|
||||
of the core java libraries as well as eclipse/ecj. To make this process smooth
|
||||
and fast, lombok has a 'stubs' concept: We have signature-only versions of
|
||||
various classes of other libraries. We compile these first, then we compile
|
||||
the rest of lombok with these stub classes on the classpath, and then we
|
||||
package lombok without the stubs.
|
||||
|
||||
Various bits of lombok are targeted at different versions, and therefore,
|
||||
different parts of lombok are compiled with different `-release` targets.
|
||||
|
||||
> ant compile
|
||||
|
||||
Compiles lombok itself
|
||||
|
||||
> ant compile.support
|
||||
|
||||
Compiles code that isn't part of the lombok distribution, but which is used
|
||||
for other jobs; For example, eclipse debug target generation, and fetching
|
||||
the current lombok stable release version number on offer at
|
||||
the projectlombok.org website involve java code.</echo>
|
||||
</target>
|
||||
|
||||
<target name="help.packaging">
|
||||
<echo>
|
||||
Lombok is shipped as an 'everything' jar; it is a stand-alone java app,
|
||||
with both a GUI and a command line interface, it's an agent, it's an
|
||||
annotation processor, and it's a module.
|
||||
|
||||
In addition, lombok is a compile-time only dependency, designed to be included
|
||||
in every project a lombok user has. Therefore, we don't want any of the
|
||||
lombok classes that you aren't meant to use directly to be visible,
|
||||
showing up in auto-complete dialogs. Starting with JDK9, the module system's
|
||||
'export' feature does a lot of this, but we also want to avoid contaminating
|
||||
things on JDK8 and below. As a consequence, lombok uses a classloader system,
|
||||
and most classes are included in the jar with a different name, not as
|
||||
.class files, thus avoiding contaminating the namespace.
|
||||
|
||||
The packaging targets take care of setting up the file rename as well as
|
||||
registering all the various manifest and file entries needed so that lombok
|
||||
can be an everything jar.
|
||||
|
||||
> ant dist
|
||||
|
||||
packages the lombok build into a single jar.
|
||||
|
||||
> ant maven
|
||||
> ant maven.publish
|
||||
|
||||
'maven' packages the lombok build ready to upload to mavencentral (sonatype).
|
||||
'maven.publish' also sends this via the lombok server to oss.sonatype.org.
|
||||
|
||||
</echo>
|
||||
</target>
|
||||
|
||||
<target name="help.test">
|
||||
<echo>
|
||||
Lombok tests need to be run against a targeted platform.
|
||||
|
||||
> ant test.javacCurrent
|
||||
> ant test.javac6
|
||||
> ant test.javac8
|
||||
> ant test.javac11
|
||||
> ant test.javac14
|
||||
|
||||
This runs the test suite that tests lombok on javac, as well as testing
|
||||
the delombok feature.
|
||||
|
||||
`javacCurrent` runs the tests on the JVM running this build: ${ant.java.version}
|
||||
|
||||
`javac6` and `javac8` are run on the JVM running this build, by downloading
|
||||
the complete java runtime classes from those versions, including javac, and
|
||||
using module limits to exclude your VM's own javac.
|
||||
|
||||
You _DO NOT_ need an installed JDK1.6 or JDK1.8 to run these.
|
||||
|
||||
`javac11`, `javac14`, etc require that you have a JDK of that version
|
||||
installed on your system. The build will automatically find such a JDK in most
|
||||
cases; alternatively, the system will ask you to provide a path to them.
|
||||
The tests are then run by invoking that VM to run them.
|
||||
|
||||
You can force a particular VM by making a file named `jvm.locations`, and putting
|
||||
in it, for example:
|
||||
|
||||
j11 = /Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home
|
||||
|
||||
Or just enter the path your VM installation when prompted, and the build will
|
||||
automatically create this file for you to remember your choice.
|
||||
|
||||
> ant test.eclipse-oxygen
|
||||
> ant test.eclipse-202006
|
||||
|
||||
This runs the test suite that tests lombok on eclipse/ecj.
|
||||
|
||||
The tests are run on your current VM (${ant.java.version}), fetching
|
||||
the relevant bits of the chosen eclipse release to test against.
|
||||
|
||||
> ant test
|
||||
|
||||
Runs the 'default' targets for all supported platforms. This should catch
|
||||
most problems.
|
||||
|
||||
> ant test.broad
|
||||
|
||||
Runs tests against a selection of versions designed to catch virtually all
|
||||
problems. Doesn't quite test _every_ supported combination.
|
||||
|
||||
> ant test.compile
|
||||
|
||||
Compiles the test suite; generally invoked by the other test targets;
|
||||
you don't need to explicitly invoke this yourself.</echo>
|
||||
</target>
|
||||
|
||||
<target name="help.website">
|
||||
<echo>
|
||||
This build also builds the website, which is a static site generated via
|
||||
freemarker templates. Parts of the site build also involve other custom
|
||||
software, such as building the 'all available versions' page by checking
|
||||
the available versions on the live website, compiling markdown
|
||||
(as used by the changelog) into html, and generated color-coded syntax
|
||||
in HTML for the example snippets.
|
||||
|
||||
> ant changelog.build
|
||||
|
||||
Turns the changelog at doc/changelog.markdown into
|
||||
build/website/changelog.html.
|
||||
|
||||
> ant website.build
|
||||
> ant website.pack
|
||||
> ant website.publish
|
||||
|
||||
'build' Builds the website (by for example applying freemarker templates) into
|
||||
build/website.
|
||||
'pack' bzips this up, ready to ship to the server.
|
||||
'publish' sends this to the server and runs a script to deploy.
|
||||
|
||||
> ant website.open
|
||||
|
||||
First builds the website, then hosts it locally and opens it in your browser so
|
||||
you can see the website in its full, template-applied form.
|
||||
|
||||
> ant latest-changes.build
|
||||
|
||||
Makes a changelog variant that lists only the newest changes; it is included
|
||||
in the distribution for convenience.
|
||||
|
||||
> ant javadoc.build
|
||||
> ant javadoc.pack
|
||||
> ant javadoc.publish
|
||||
|
||||
'build' Builds the javadoc into build/api.
|
||||
'pack' bzips this up, ready to ship to the server.
|
||||
'publish' sends this to the server and runs a script to deploy.
|
||||
|
||||
> ant edge.pack
|
||||
> ant edge.publish
|
||||
|
||||
'pack' creates a bzip with all relevant files needed to deploy a new edge
|
||||
release to the server: A fresh build of the lombok everything jar, plus the
|
||||
maven repo update so that the edge release can be fetched as a maven dep,
|
||||
and an update to the download-edge page listing the latest changes included
|
||||
in the edge release.
|
||||
|
||||
'publish' sends this to the server, runs a script server-side to deploy the
|
||||
content, and updates a git tag on success.</echo>
|
||||
</target>
|
||||
|
||||
<target name="help.p2">
|
||||
<echo>
|
||||
This is still an experimental feature.
|
||||
|
||||
We ship lombok as an eclipse plugin. The plugin isn't much of a plugin; the
|
||||
install script of the plugin fulfills the same role as lombok's installer
|
||||
(which is: add a line configuring lombok as an agent during eclipse bootup),
|
||||
and the uninstall script removes it.
|
||||
|
||||
> ant eclipsep2.build
|
||||
> ant eclipsep2.pack
|
||||
> ant eclipsep2.publish
|
||||
|
||||
'build' generates the various files required to appear as an eclipse plugin,
|
||||
and makes the jar(s).
|
||||
'pack' makes a bzip ready to ship to a server.
|
||||
'publish' ships it and runs a script server-side to put these files in the
|
||||
right place; requires SSH access to the server.</echo>
|
||||
</target>
|
||||
</project>
|
||||
@@ -0,0 +1,13 @@
|
||||
<ivy-module version="2.0">
|
||||
<info organisation="net.java.openjdk.custom" module="javac11" revision="11_2018-09-25" publication="20200606144743">
|
||||
<license name="GNU General Public License v2 with Classpath Exception" url="https://openjdk.java.net/legal/gplv2+ce.html" />
|
||||
<description homepage="https://openjdk.java.net" />
|
||||
</info>
|
||||
<configurations>
|
||||
<conf name="runtime" />
|
||||
</configurations>
|
||||
<publications>
|
||||
<artifact name="javac11-java.compiler" conf="runtime" url="https://projectlombok.org/ivyrepo/langtools/javac11_2018-09-25-java.compiler.jar" />
|
||||
<artifact name="javac11-jdk.compiler" conf="runtime" url="https://projectlombok.org/ivyrepo/langtools/javac11_2018-09-25-jdk.compiler.jar" />
|
||||
</publications>
|
||||
</ivy-module>
|
||||
@@ -0,0 +1,12 @@
|
||||
<ivy-module version="2.0">
|
||||
<info organisation="net.java.openjdk.custom" module="javac13" revision="13_2019-09-17" publication="20200508032346">
|
||||
<license name="GNU General Public License v2 with Classpath Exception" url="https://openjdk.java.net/legal/gplv2+ce.html" />
|
||||
<description homepage="https://openjdk.java.net" />
|
||||
</info>
|
||||
<configurations>
|
||||
<conf name="runtime" />
|
||||
</configurations>
|
||||
<publications>
|
||||
<artifact conf="runtime" url="https://projectlombok.org/ivyrepo/langtools/javac13_2019-09-17.jar" />
|
||||
</publications>
|
||||
</ivy-module>
|
||||
@@ -0,0 +1,12 @@
|
||||
<ivy-module version="2.0">
|
||||
<info organisation="net.java.openjdk.custom" module="javac14" revision="14-ea_2020-03-17" publication="20200508035315">
|
||||
<license name="GNU General Public License v2 with Classpath Exception" url="https://openjdk.java.net/legal/gplv2+ce.html" />
|
||||
<description homepage="https://openjdk.java.net" />
|
||||
</info>
|
||||
<configurations>
|
||||
<conf name="runtime" />
|
||||
</configurations>
|
||||
<publications>
|
||||
<artifact conf="runtime" url="https://projectlombok.org/ivyrepo/langtools/javac14-ea_2020-03-17.jar" />
|
||||
</publications>
|
||||
</ivy-module>
|
||||
@@ -0,0 +1,12 @@
|
||||
<ivy-module version="2.0">
|
||||
<info organisation="net.java.openjdk.custom" module="javac8" revision="1.8.0" publication="20140613120000">
|
||||
<license name="GNU General Public License v2 with Classpath Exception" url="https://openjdk.java.net/legal/gplv2+ce.html" />
|
||||
<description homepage="https://openjdk.java.net" />
|
||||
</info>
|
||||
<configurations>
|
||||
<conf name="runtime" />
|
||||
</configurations>
|
||||
<publications>
|
||||
<artifact conf="runtime" url="https://projectlombok.org/ivyrepo/langtools/jdk8-javac.jar" />
|
||||
</publications>
|
||||
</ivy-module>
|
||||
@@ -1,14 +0,0 @@
|
||||
<ivy-module version="2.0">
|
||||
<info organisation="org.eclipse.custom" module="core.jobs" revision="3.5.200" publication="20120521234600">
|
||||
<license name="Eclipse Public Licence v1.0" url="http://www.eclipse.org/org/documents/epl-v10.php" />
|
||||
<description homepage="http://www.eclipse.org/eclipse/" />
|
||||
</info>
|
||||
<configurations>
|
||||
<conf name="default" />
|
||||
<conf name="sources" />
|
||||
</configurations>
|
||||
<publications>
|
||||
<artifact conf="default" url="https://projectlombok.org/ivyrepo/eclipse/org.eclipse.core.jobs_3.5.200.v20120521-2346.jar" />
|
||||
<artifact type="zip" conf="sources" url="https://projectlombok.org/ivyrepo/eclipse/org.eclipse.core.jobs_3.5.200.v20120521-2346-sources.jar" />
|
||||
</publications>
|
||||
</ivy-module>
|
||||
@@ -1,14 +0,0 @@
|
||||
<ivy-module version="2.0">
|
||||
<info organisation="org.eclipse.custom" module="core.jobs" revision="3.5.300" publication="20130429181300">
|
||||
<license name="Eclipse Public Licence v1.0" url="http://www.eclipse.org/org/documents/epl-v10.php" />
|
||||
<description homepage="http://www.eclipse.org/eclipse/" />
|
||||
</info>
|
||||
<configurations>
|
||||
<conf name="default" />
|
||||
<conf name="sources" />
|
||||
</configurations>
|
||||
<publications>
|
||||
<artifact conf="default" url="https://projectlombok.org/ivyrepo/eclipse/org.eclipse.core.jobs_3.5.300.v20130429-1813.jar" />
|
||||
<artifact type="zip" conf="sources" url="https://projectlombok.org/ivyrepo/eclipse/org.eclipse.core.jobs_3.5.300.v20130429-1813-sources.jar" />
|
||||
</publications>
|
||||
</ivy-module>
|
||||
@@ -1,14 +0,0 @@
|
||||
<ivy-module version="2.0">
|
||||
<info organisation="org.eclipse.custom" module="core.resources" revision="3.7.0" publication="20110510071200">
|
||||
<license name="Eclipse Public Licence v1.0" url="http://www.eclipse.org/org/documents/epl-v10.php" />
|
||||
<description homepage="http://www.eclipse.org/eclipse/" />
|
||||
</info>
|
||||
<configurations>
|
||||
<conf name="default" />
|
||||
<conf name="sources" />
|
||||
</configurations>
|
||||
<publications>
|
||||
<artifact conf="default" url="https://projectlombok.org/ivyrepo/eclipse/org.eclipse.core.resources_3.7.100.v20110510-0712.jar" />
|
||||
<artifact type="zip" conf="sources" url="https://projectlombok.org/ivyrepo/eclipse/org.eclipse.core.resources_3.7.100.v20110510-0712-sources.jar" />
|
||||
</publications>
|
||||
</ivy-module>
|
||||
@@ -1,14 +0,0 @@
|
||||
<ivy-module version="2.0">
|
||||
<info organisation="org.eclipse.custom" module="core.resources" revision="3.8.100" publication="20130521202600">
|
||||
<license name="Eclipse Public Licence v1.0" url="http://www.eclipse.org/org/documents/epl-v10.php" />
|
||||
<description homepage="http://www.eclipse.org/eclipse/" />
|
||||
</info>
|
||||
<configurations>
|
||||
<conf name="default" />
|
||||
<conf name="sources" />
|
||||
</configurations>
|
||||
<publications>
|
||||
<artifact conf="default" url="https://projectlombok.org/ivyrepo/eclipse/org.eclipse.core.resources_3.8.100.v20130521-2026.jar" />
|
||||
<artifact type="zip" conf="sources" url="https://projectlombok.org/ivyrepo/eclipse/org.eclipse.core.resources_3.8.100.v20130521-2026-sources.jar" />
|
||||
</publications>
|
||||
</ivy-module>
|
||||
@@ -1,14 +0,0 @@
|
||||
<ivy-module version="2.0">
|
||||
<info organisation="org.eclipse.custom" module="core.runtime" revision="3.6.0" publication="20100505120000">
|
||||
<license name="Eclipse Public Licence v1.0" url="http://www.eclipse.org/org/documents/epl-v10.php" />
|
||||
<description homepage="http://www.eclipse.org/eclipse/" />
|
||||
</info>
|
||||
<configurations>
|
||||
<conf name="default" />
|
||||
<conf name="sources" />
|
||||
</configurations>
|
||||
<publications>
|
||||
<artifact conf="default" url="https://projectlombok.org/ivyrepo/eclipse/org.eclipse.core.runtime_3.6.0.v20100505.jar" />
|
||||
<artifact type="zip" conf="sources" url="https://projectlombok.org/ivyrepo/eclipse/org.eclipse.core.runtime_3.6.0.v20100505-sources.jar" />
|
||||
</publications>
|
||||
</ivy-module>
|
||||
@@ -1,14 +0,0 @@
|
||||
<ivy-module version="2.0">
|
||||
<info organisation="org.eclipse.custom" module="core.runtime" revision="3.9.0" publication="20130326125500">
|
||||
<license name="Eclipse Public Licence v1.0" url="http://www.eclipse.org/org/documents/epl-v10.php" />
|
||||
<description homepage="http://www.eclipse.org/eclipse/" />
|
||||
</info>
|
||||
<configurations>
|
||||
<conf name="default" />
|
||||
<conf name="sources" />
|
||||
</configurations>
|
||||
<publications>
|
||||
<artifact conf="default" url="https://projectlombok.org/ivyrepo/eclipse/org.eclipse.core.runtime_3.9.0.v20130326-1255.jar" />
|
||||
<artifact type="zip" conf="sources" url="https://projectlombok.org/ivyrepo/eclipse/org.eclipse.core.runtime_3.9.0.v20130326-1255-sources.jar" />
|
||||
</publications>
|
||||
</ivy-module>
|
||||
@@ -1,14 +0,0 @@
|
||||
<ivy-module version="2.0">
|
||||
<info organisation="org.eclipse.custom" module="ecj" revision="3.6.2" publication="20110401190400">
|
||||
<license name="Eclipse Public Licence v1.0" url="http://www.eclipse.org/org/documents/epl-v10.php" />
|
||||
<description homepage="http://www.eclipse.org/eclipse/" />
|
||||
</info>
|
||||
<configurations>
|
||||
<conf name="default" />
|
||||
<conf name="sources" />
|
||||
</configurations>
|
||||
<publications>
|
||||
<artifact conf="default" url="https://projectlombok.org/ivyrepo/eclipse/ecj-3.6.2.jar" />
|
||||
<artifact type="zip" conf="sources" url="https://projectlombok.org/ivyrepo/eclipse/ecjsrc-3.6.2.zip" />
|
||||
</publications>
|
||||
</ivy-module>
|
||||
@@ -1,14 +0,0 @@
|
||||
<ivy-module version="2.0">
|
||||
<info organisation="org.eclipse.custom" module="ecj" revision="4.3.1" publication="20140210214200">
|
||||
<license name="Eclipse Public Licence v1.0" url="http://www.eclipse.org/org/documents/epl-v10.php" />
|
||||
<description homepage="http://www.eclipse.org/eclipse/" />
|
||||
</info>
|
||||
<configurations>
|
||||
<conf name="default" />
|
||||
<conf name="sources" />
|
||||
</configurations>
|
||||
<publications>
|
||||
<artifact conf="default" url="https://projectlombok.org/ivyrepo/eclipse/ecj-4.3.1.jar" />
|
||||
<artifact type="zip" conf="sources" url="https://projectlombok.org/ivyrepo/eclipse/ecjsrc-4.3.1.zip" />
|
||||
</publications>
|
||||
</ivy-module>
|
||||
@@ -1,14 +0,0 @@
|
||||
<ivy-module version="2.0">
|
||||
<info organisation="org.eclipse.custom" module="ecj" revision="I20140430" publication="20140430080000">
|
||||
<license name="Eclipse Public Licence v1.0" url="http://www.eclipse.org/org/documents/epl-v10.php" />
|
||||
<description homepage="http://www.eclipse.org/eclipse/" />
|
||||
</info>
|
||||
<configurations>
|
||||
<conf name="default" />
|
||||
<conf name="sources" />
|
||||
</configurations>
|
||||
<publications>
|
||||
<artifact conf="default" url="https://projectlombok.org/ivyrepo/eclipse/ecj-I20140430-0800.jar" />
|
||||
<artifact type="zip" conf="sources" url="https://projectlombok.org/ivyrepo/eclipse/ecjsrc-I20140430-0800.zip" />
|
||||
</publications>
|
||||
</ivy-module>
|
||||
@@ -1,14 +0,0 @@
|
||||
<ivy-module version="2.0">
|
||||
<info organisation="org.eclipse.custom" module="equinox.common" revision="3.6.0" publication="20100503120000">
|
||||
<license name="Eclipse Public Licence v1.0" url="http://www.eclipse.org/org/documents/epl-v10.php" />
|
||||
<description homepage="http://www.eclipse.org/eclipse/" />
|
||||
</info>
|
||||
<configurations>
|
||||
<conf name="default" />
|
||||
<conf name="sources" />
|
||||
</configurations>
|
||||
<publications>
|
||||
<artifact conf="default" url="https://projectlombok.org/ivyrepo/eclipse/org.eclipse.equinox.common_3.6.0.v20100503.jar" />
|
||||
<artifact type="zip" conf="sources" url="https://projectlombok.org/ivyrepo/eclipse/org.eclipse.equinox.common_3.6.0.v20100503-sources.jar" />
|
||||
</publications>
|
||||
</ivy-module>
|
||||
@@ -1,14 +0,0 @@
|
||||
<ivy-module version="2.0">
|
||||
<info organisation="org.eclipse.custom" module="equinox.common" revision="3.6.200" publication="20130402150500">
|
||||
<license name="Eclipse Public Licence v1.0" url="http://www.eclipse.org/org/documents/epl-v10.php" />
|
||||
<description homepage="http://www.eclipse.org/eclipse/" />
|
||||
</info>
|
||||
<configurations>
|
||||
<conf name="default" />
|
||||
<conf name="sources" />
|
||||
</configurations>
|
||||
<publications>
|
||||
<artifact conf="default" url="https://projectlombok.org/ivyrepo/eclipse/org.eclipse.equinox.common_3.6.200.v20130402-1505.jar" />
|
||||
<artifact type="zip" conf="sources" url="https://projectlombok.org/ivyrepo/eclipse/org.eclipse.equinox.common_3.6.200.v20130402-1505-sources.jar" />
|
||||
</publications>
|
||||
</ivy-module>
|
||||
@@ -1,14 +0,0 @@
|
||||
<ivy-module version="2.0">
|
||||
<info organisation="org.eclipse.custom" module="jdt.core" revision="3.6.0" publication="20100505120000">
|
||||
<license name="Eclipse Public Licence v1.0" url="http://www.eclipse.org/org/documents/epl-v10.php" />
|
||||
<description homepage="http://www.eclipse.org/eclipse/" />
|
||||
</info>
|
||||
<configurations>
|
||||
<conf name="default" />
|
||||
<conf name="sources" />
|
||||
</configurations>
|
||||
<publications>
|
||||
<artifact conf="default" url="https://projectlombok.org/ivyrepo/eclipse/org.eclipse.jdt.core_3.6.0.v_A58.jar" />
|
||||
<artifact type="zip" conf="sources" url="https://projectlombok.org/ivyrepo/eclipse/org.eclipse.jdt.core_3.6.0.v_A58-sources.jar" />
|
||||
</publications>
|
||||
</ivy-module>
|
||||
@@ -1,14 +0,0 @@
|
||||
<ivy-module version="2.0">
|
||||
<info organisation="org.eclipse.custom" module="jdt.core" revision="3.9.1" publication="20130905083700">
|
||||
<license name="Eclipse Public Licence v1.0" url="http://www.eclipse.org/org/documents/epl-v10.php" />
|
||||
<description homepage="http://www.eclipse.org/eclipse/" />
|
||||
</info>
|
||||
<configurations>
|
||||
<conf name="default" />
|
||||
<conf name="sources" />
|
||||
</configurations>
|
||||
<publications>
|
||||
<artifact conf="default" url="https://projectlombok.org/ivyrepo/eclipse/org.eclipse.jdt.core_3.9.1.v20130905-0837.jar" />
|
||||
<artifact type="zip" conf="sources" url="https://projectlombok.org/ivyrepo/eclipse/org.eclipse.jdt.core_3.9.1.v20130905-0837-sources.jar" />
|
||||
</publications>
|
||||
</ivy-module>
|
||||
@@ -1,14 +0,0 @@
|
||||
<ivy-module version="2.0">
|
||||
<info organisation="org.eclipse.custom" module="jdt.ui" revision="3.6.0" publication="20100602160000">
|
||||
<license name="Eclipse Public Licence v1.0" url="http://www.eclipse.org/org/documents/epl-v10.php" />
|
||||
<description homepage="http://www.eclipse.org/eclipse/" />
|
||||
</info>
|
||||
<configurations>
|
||||
<conf name="default" />
|
||||
<conf name="sources" />
|
||||
</configurations>
|
||||
<publications>
|
||||
<artifact conf="default" url="https://projectlombok.org/ivyrepo/eclipse/org.eclipse.jdt.ui_3.6.0.v20100602-1600.jar" />
|
||||
<artifact type="zip" conf="sources" url="https://projectlombok.org/ivyrepo/eclipse/org.eclipse.jdt.ui_3.6.0.v20100602-1600-sources.jar" />
|
||||
</publications>
|
||||
</ivy-module>
|
||||
@@ -1,14 +0,0 @@
|
||||
<ivy-module version="2.0">
|
||||
<info organisation="org.eclipse.custom" module="jdt.ui" revision="3.9.1" publication="20130820142700">
|
||||
<license name="Eclipse Public Licence v1.0" url="http://www.eclipse.org/org/documents/epl-v10.php" />
|
||||
<description homepage="http://www.eclipse.org/eclipse/" />
|
||||
</info>
|
||||
<configurations>
|
||||
<conf name="default" />
|
||||
<conf name="sources" />
|
||||
</configurations>
|
||||
<publications>
|
||||
<artifact conf="default" url="https://projectlombok.org/ivyrepo/eclipse/org.eclipse.jdt.ui_3.9.1.v20130820-1427.jar" />
|
||||
<artifact type="zip" conf="sources" url="https://projectlombok.org/ivyrepo/eclipse/org.eclipse.jdt.ui_3.9.1.v20130820-1427-sources.jar" />
|
||||
</publications>
|
||||
</ivy-module>
|
||||
@@ -1,14 +0,0 @@
|
||||
<ivy-module version="2.0">
|
||||
<info organisation="org.eclipse.custom" module="osgi" revision="3.6.0" publication="20100517120000">
|
||||
<license name="Eclipse Public Licence v1.0" url="http://www.eclipse.org/org/documents/epl-v10.php" />
|
||||
<description homepage="http://www.eclipse.org/eclipse/" />
|
||||
</info>
|
||||
<configurations>
|
||||
<conf name="default" />
|
||||
<conf name="sources" />
|
||||
</configurations>
|
||||
<publications>
|
||||
<artifact conf="default" url="https://projectlombok.org/ivyrepo/eclipse/org.eclipse.osgi_3.6.0.v20100517.jar" />
|
||||
<artifact type="zip" conf="sources" url="https://projectlombok.org/ivyrepo/eclipse/org.eclipse.osgi_3.6.0.v20100517-sources.jar" />
|
||||
</publications>
|
||||
</ivy-module>
|
||||
@@ -1,14 +0,0 @@
|
||||
<ivy-module version="2.0">
|
||||
<info organisation="org.eclipse.custom" module="osgi" revision="3.9.0" publication="20130529171000">
|
||||
<license name="Eclipse Public Licence v1.0" url="http://www.eclipse.org/org/documents/epl-v10.php" />
|
||||
<description homepage="http://www.eclipse.org/eclipse/" />
|
||||
</info>
|
||||
<configurations>
|
||||
<conf name="default" />
|
||||
<conf name="sources" />
|
||||
</configurations>
|
||||
<publications>
|
||||
<artifact conf="default" url="https://projectlombok.org/ivyrepo/eclipse/org.eclipse.osgi_3.9.0.v20130529-1710.jar" />
|
||||
<artifact type="zip" conf="sources" url="https://projectlombok.org/ivyrepo/eclipse/org.eclipse.osgi_3.9.0.v20130529-1710-sources.jar" />
|
||||
</publications>
|
||||
</ivy-module>
|
||||
+87
-52
@@ -1,64 +1,64 @@
|
||||
<ivy-module version="2.0">
|
||||
<info organisation="projectlombok.org" module="lombok" />
|
||||
<configurations>
|
||||
<conf name="eclipseBuild" />
|
||||
<conf name="netbeansBuild" />
|
||||
<conf name="buildBase" extends="netbeansBuild, javac6" />
|
||||
<conf name="build" extends="buildBase, eclipseBuild" />
|
||||
<conf name="moduleBuild" />
|
||||
<conf name="buildWithoutEclipse" extends="buildBase" />
|
||||
<conf name="runtime" />
|
||||
<conf name="test" extends="runtime" />
|
||||
<conf name="contrib" />
|
||||
<conf name="ecj7" />
|
||||
<conf name="ecj8" />
|
||||
<conf name="ecj9" />
|
||||
<!-- dependencies for the build itself, such as tools to create the website or deploy to servers. -->
|
||||
<conf name="buildtools" />
|
||||
|
||||
<!-- dependencies needed only for the 'manage lombok supporters' part of the build -->
|
||||
<conf name="supporters" />
|
||||
|
||||
<!-- test: base dependencies required to run the tests. Does not include javac or ecj. -->
|
||||
<conf name="test" />
|
||||
|
||||
<!-- stripe: dependencies that need to be on the classpath during builds -->
|
||||
<conf name="build" />
|
||||
|
||||
<!-- stripe: dependencies that need to be striped into lombok.jar itself, and are required for both build and test/run purposes -->
|
||||
<conf name="stripe" />
|
||||
|
||||
<!-- sources of various dependencies where having the sources is useful (for example for debugging purposes) -->
|
||||
<conf name="sources" />
|
||||
|
||||
<!-- and now for custom configs for testing lombok against -->
|
||||
|
||||
<conf name="javac6" />
|
||||
<conf name="javac7" />
|
||||
<conf name="supporters" />
|
||||
<conf name="javac8" />
|
||||
|
||||
<conf name="ecj8" />
|
||||
<conf name="ecj11" />
|
||||
<conf name="ecj14" />
|
||||
|
||||
<conf name="eclipse-oxygen" />
|
||||
<conf name="eclipse-202006" />
|
||||
|
||||
<conf name="mapstruct" />
|
||||
</configurations>
|
||||
<dependencies>
|
||||
<dependency org="org.projectlombok" name="lombok.patcher" rev="0.36" conf="buildBase->default; runtime->default" />
|
||||
<dependency org="zwitserloot.com" name="cmdreader" rev="1.2" conf="buildBase->runtime; runtime" />
|
||||
|
||||
<dependency org="junit" name="junit" rev="4.8.2" conf="test->default; contrib->sources" />
|
||||
<dependency org="log4j" name="log4j" rev="1.2.17" conf="test->default; contrib->sources" />
|
||||
<dependency org="org.apache.logging.log4j" name="log4j-api" rev="2.11.1" conf="test->default; contrib->sources" />
|
||||
<dependency org="commons-logging" name="commons-logging" rev="1.2" conf="test->default; contrib->sources" />
|
||||
<dependency org="org.slf4j" name="slf4j-api" rev="1.8.0-beta2" conf="test->default; contrib->sources" />
|
||||
<dependency org="org.slf4j" name="slf4j-ext" rev="1.8.0-beta2" conf="test->default; contrib->sources" />
|
||||
<dependency org="org.jboss.logging" name="jboss-logging" rev="3.3.0.Final" conf="test->default; contrib->sources" />
|
||||
<dependency org="com.google.flogger" name="flogger" rev="0.2" conf="test->default; contrib->sources" />
|
||||
|
||||
<dependency org="com.google.guava" name="guava" rev="18.0" conf="test->default; contrib->sources" />
|
||||
<dependency org="org.projectlombok" name="lombok.patcher" rev="0.36" conf="build,stripe->default" />
|
||||
<dependency org="zwitserloot.com" name="cmdreader" rev="1.2" conf="build,stripe->runtime" />
|
||||
<dependency org="projectlombok.org" name="spi" rev="0.2.7" conf="build" />
|
||||
<dependency org="org.apache.ant" name="ant" rev="1.10.5" conf="build->default" />
|
||||
|
||||
<!-- test deps -->
|
||||
<dependency org="junit" name="junit" rev="4.8.2" conf="test->default; sources" />
|
||||
<dependency org="log4j" name="log4j" rev="1.2.17" conf="test->default; sources" />
|
||||
<dependency org="org.apache.logging.log4j" name="log4j-api" rev="2.11.1" conf="test->default; sources" />
|
||||
<dependency org="commons-logging" name="commons-logging" rev="1.2" conf="test->default; sources" />
|
||||
<dependency org="org.slf4j" name="slf4j-api" rev="1.8.0-beta2" conf="test->default; sources" />
|
||||
<dependency org="org.slf4j" name="slf4j-ext" rev="1.8.0-beta2" conf="test->default; sources" />
|
||||
<dependency org="org.jboss.logging" name="jboss-logging" rev="3.3.0.Final" conf="test->default; sources" />
|
||||
<dependency org="com.google.flogger" name="flogger" rev="0.2" conf="test->default; sources" />
|
||||
<dependency org="com.google.guava" name="guava" rev="18.0" conf="test->default; sources" />
|
||||
<dependency org="com.google.code.findbugs" name="findbugs" rev="3.0.1" conf="test->master" />
|
||||
|
||||
<dependency org="org.apache.ant" name="ant" rev="1.10.5" conf="buildBase->default; contrib->sources" />
|
||||
<dependency org="projectlombok.org" name="spi" rev="0.2.7" conf="buildBase->build" />
|
||||
<dependency org="com.hierynomus" name="sshj" rev="0.26.0" conf="buildBase->default" />
|
||||
<dependency org="projectlombok.org" name="markdownj" rev="1.02b4" conf="buildBase->build" />
|
||||
<dependency org="de.java2html" name="java2html" rev="5.0" conf="buildBase->default" />
|
||||
<dependency org="org.freemarker" name="freemarker" rev="2.3.28" conf="buildBase->default" />
|
||||
|
||||
<dependency org="net.java.openjdk.custom" name="javac6" rev="1.6.0.18" conf="javac6->runtime; contrib->sources" />
|
||||
<dependency org="net.java.openjdk.custom" name="javac7" rev="1.7.0" conf="javac7->runtime; contrib->sources" />
|
||||
<dependency org="org.eclipse.custom" name="ecj" rev="4.3.1" conf="ecj7->default; contrib->sources" />
|
||||
<dependency org="org.eclipse.jdt.core.compiler" name="ecj" rev="4.6.1" conf="ecj8->default; contrib->sources" />
|
||||
<dependency org="org.eclipse.jdt" name="ecj" rev="3.15.1" conf="ecj9->default; eclipseBuild->default" />
|
||||
<dependency org="org.eclipse.jdt" name="org.eclipse.jdt.compiler.apt" rev="1.3.300" conf="ecj9->default; eclipseBuild->default" />
|
||||
|
||||
<dependency org="netbeans.org" name="boot" rev="6.8beta" conf="netbeansBuild->build" />
|
||||
<dependency org="netbeans.org" name="openide.modules" rev="6.8beta" conf="netbeansBuild->build" />
|
||||
<dependency org="netbeans.org" name="openide.util" rev="6.8beta" conf="netbeansBuild->build" />
|
||||
<dependency org="netbeans.org" name="modules.java.source" rev="6.8beta" conf="netbeansBuild->build" />
|
||||
|
||||
<dependency org="org.eclipse.platform" name="org.eclipse.core.runtime" rev="3.17.0" conf="eclipseBuild->default; contrib->sources" transitive="false" />
|
||||
<dependency org="org.eclipse.jdt" name="org.eclipse.jdt.core" rev="3.20.0" conf="eclipseBuild->default; contrib->sources" transitive="false" />
|
||||
<dependency org="org.eclipse.jdt" name="org.eclipse.jdt.ui" rev="3.12.2" conf="eclipseBuild->default; contrib->sources" transitive="false" />
|
||||
<dependency org="org.eclipse.platform" name="org.eclipse.equinox.common" rev="3.10.600" conf="eclipseBuild->default; contrib->sources" transitive="false" />
|
||||
<dependency org="org.eclipse.platform" name="org.eclipse.osgi" rev="3.15.100" conf="eclipseBuild->default; contrib->sources" transitive="false" />
|
||||
<dependency org="org.eclipse.platform" name="org.eclipse.core.resources" rev="3.13.600" conf="eclipseBuild->default; contrib->sources" transitive="false" />
|
||||
<dependency org="org.eclipse.platform" name="org.eclipse.core.jobs" rev="3.10.600" conf="eclipseBuild->default; contrib->sources" transitive="false" />
|
||||
<!-- build tooling -->
|
||||
<dependency org="com.hierynomus" name="sshj" rev="0.26.0" conf="buildtools->default" />
|
||||
<dependency org="projectlombok.org" name="markdownj" rev="1.02b4" conf="buildtools->build" />
|
||||
<dependency org="de.java2html" name="java2html" rev="5.0" conf="buildtools->default" />
|
||||
<dependency org="org.freemarker" name="freemarker" rev="2.3.28" conf="buildtools->default" />
|
||||
<dependency org="com.sparkjava" name="spark-core" rev="2.9.2" conf="buildtools->default" />
|
||||
|
||||
<dependency org="org.eclipse.jgit" name="org.eclipse.jgit.ant" rev="5.2.0.201812061821-r" conf="supporters->default" />
|
||||
<dependency org="org.eclipse.jgit" name="org.eclipse.jgit" rev="5.2.0.201812061821-r" conf="supporters->default" />
|
||||
@@ -66,6 +66,41 @@
|
||||
<dependency org="com.rimerosolutions.ant" name="ant-git-tasks" rev="1.3.2" conf="supporters->default" />
|
||||
<dependency org="org.slf4j" name="slf4j-simple" rev="1.8.0-beta2" conf="supporters->default" />
|
||||
|
||||
<dependency org="org.mapstruct" name="mapstruct-processor" rev="1.3.0.Beta1" conf="moduleBuild->default" />
|
||||
<!-- javacs -->
|
||||
<dependency org="net.java.openjdk.custom" name="javac6" rev="1.6.0.18" conf="javac6->runtime" />
|
||||
<dependency org="net.java.openjdk.custom" name="javac7" rev="1.7.0" conf="javac7->runtime" />
|
||||
<dependency org="net.java.openjdk.custom" name="javac8" rev="1.8.0" conf="javac8->runtime" />
|
||||
|
||||
<!-- ecjs -->
|
||||
|
||||
<dependency org="org.eclipse.jdt" name="ecj" rev="3.22.0.v20200530-2032" conf="ecj14->master" />
|
||||
<dependency org="org.eclipse.jdt" name="ecj" rev="3.16.0" conf="ecj11->master" />
|
||||
<!-- until oct 2016, ecj was released under org 'org.eclipse.jdt.core.compiler', and the versioning followed eclipse's versions. -->
|
||||
<!-- after that, it switched to group 'org.eclipse.jdt', and follows its own version. That means 3.16.0 is a later release than 4.6.1 on the old group! -->
|
||||
<dependency org="org.eclipse.jdt.core.compiler" name="ecj" rev="4.4.2" conf="ecj8->master" />
|
||||
|
||||
<!-- eclipses -->
|
||||
|
||||
<dependency org="org.eclipse.platform" name="org.eclipse.core.runtime" rev="3.13.0" conf="eclipse-oxygen->default" transitive="false" />
|
||||
<dependency org="org.eclipse.jdt" name="org.eclipse.jdt.core" rev="3.13.102" conf="eclipse-oxygen->default" transitive="false" />
|
||||
<dependency org="org.eclipse.jdt" name="org.eclipse.jdt.ui" rev="3.13.100" conf="eclipse-oxygen->default" transitive="false" />
|
||||
<dependency org="org.eclipse.platform" name="org.eclipse.equinox.common" rev="3.9.0" conf="eclipse-oxygen->default" transitive="false" />
|
||||
<dependency org="org.eclipse.platform" name="org.eclipse.core.resources" rev="3.12.0" conf="eclipse-oxygen->default" transitive="false" />
|
||||
<dependency org="org.eclipse.platform" name="org.eclipse.core.jobs" rev="3.9.0" conf="eclipse-oxygen->default" transitive="false" />
|
||||
<dependency org="org.eclipse.platform" name="org.eclipse.osgi" rev="3.12.100" conf="eclipse-oxygen->default" transitive="false" />
|
||||
<dependency org="org.eclipse.platform" name="org.eclipse.text" rev="3.6.100" conf="eclipse-oxygen->default" transitive="false" />
|
||||
|
||||
<dependency org="org.eclipse.platform" name="org.eclipse.core.runtime" rev="3.18.0" conf="eclipse-202006->default" transitive="false" />
|
||||
<dependency org="org.eclipse.jdt" name="org.eclipse.jdt.core" rev="3.22.0" conf="eclipse-202006->default" transitive="false" />
|
||||
<dependency org="org.eclipse.jdt" name="org.eclipse.jdt.ui" rev="3.21.100" conf="eclipse-202006->default" transitive="false" />
|
||||
<dependency org="org.eclipse.platform" name="org.eclipse.equinox.common" rev="3.12.0" conf="eclipse-202006->default" transitive="false" />
|
||||
<dependency org="org.eclipse.platform" name="org.eclipse.equinox.preferences" rev="3.8.0" conf="eclipse-202006->default" transitive="false" />
|
||||
<dependency org="org.eclipse.platform" name="org.eclipse.core.resources" rev="3.13.700" conf="eclipse-202006->default" transitive="false" />
|
||||
<dependency org="org.eclipse.platform" name="org.eclipse.core.jobs" rev="3.10.800" conf="eclipse-202006->default" transitive="false" />
|
||||
<dependency org="org.eclipse.platform" name="org.eclipse.osgi" rev="3.15.300" conf="eclipse-202006->default" transitive="false" />
|
||||
<dependency org="org.eclipse.platform" name="org.eclipse.text" rev="3.10.200" conf="eclipse-202006->default" transitive="false" />
|
||||
|
||||
<!-- integration with other libraries -->
|
||||
<dependency org="org.mapstruct" name="mapstruct-processor" rev="1.3.1.Final" conf="mapstruct->default" transitive="false" />
|
||||
</dependencies>
|
||||
</ivy-module>
|
||||
@@ -4,6 +4,7 @@
|
||||
<filesystem name="projectLocalRepo">
|
||||
<ivy pattern="${ivy.settings.dir}/ivy-repo/[organization]-[module]-[revision].xml" />
|
||||
</filesystem>
|
||||
<ibiblio name="eclipse-staging-repo" m2compatible="true" root="https://repo.eclipse.org/content/repositories/eclipse-staging" />
|
||||
<ibiblio name="maven-repo2" m2compatible="true" root="https://repo1.maven.org/maven2" />
|
||||
</chain>
|
||||
</resolvers>
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
<!--
|
||||
Copyright (C) 2020 The Project Lombok Authors.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
-->
|
||||
<project name="lombok.mapstructBinding" xmlns:ivy="antlib:com.zwitserloot.ivyplusplus" basedir="..">
|
||||
<description>
|
||||
This buildfile is part of projectlombok.org. It builds the mapstruct-lombok binding; we think the
|
||||
version on mavencentral is the last version that is ever needed; the code itself is trivial and
|
||||
exists as a separate dependency solely because it is itself dependent on both lombok and mapstruct.
|
||||
</description>
|
||||
|
||||
<target name="-mapstructBinding.compile">
|
||||
<mkdir dir="build/mapstruct" />
|
||||
<javac includeAntRuntime="false" source="1.9" target="1.9" destdir="build/mapstruct">
|
||||
<src path="src/j9stubs" />
|
||||
<!-- This includes org.mapstruct.ap.spi.AstModifyingAnnotationProcessor; putting this on the classpath doesn't work (needs to be internal or a module) so we just add it and then delete the class file for convenience. -->
|
||||
</javac>
|
||||
<mkdir dir="build/lombok/secondaryLoading.SCL.lombok/org/mapstruct/ap/spi" />
|
||||
<move file="build/mapstruct/org/mapstruct/ap/spi/AstModifyingAnnotationProcessor.class" tofile="build/lombok/secondaryLoading.SCL.lombok/org/mapstruct/ap/spi/AstModifyingAnnotationProcessor.SCL.lombok" />
|
||||
</target>
|
||||
|
||||
<target name="-mapstructBinding.prepare" depends="-mapstructBinding.compile">
|
||||
<mkdir dir="build/mapstruct-module-path" />
|
||||
<copy file="dist/lombok.jar" todir="build/mapstruct-module-path" />
|
||||
<jar destfile="build/mapstruct-module-path/mapstruct-processor.jar" basedir="build/mapstruct" includes="org/**">
|
||||
<manifest>
|
||||
<attribute name="Automatic-Module-Name" value="org.mapstruct.processor" />
|
||||
</manifest>
|
||||
</jar>
|
||||
|
||||
<mkdir dir="build/mapstruct-binding/maven" />
|
||||
<copy tofile="build/mapstruct-binding/maven/pom.xml" overwrite="true" file="doc/mapstruct-binding-maven-pom.xml">
|
||||
<filterchain>
|
||||
<replacetokens>
|
||||
<token key="VERSION" value="${mapstruct-binding.version}" />
|
||||
</replacetokens>
|
||||
</filterchain>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<target name="-mapstructBinding.doc" depends="-mapstructBinding.prepare">
|
||||
<mkdir dir="build/mapstruct-binding/api" />
|
||||
<javadoc
|
||||
Package="true"
|
||||
packagenames="lombok.*"
|
||||
sourcepath="src/bindings/mapstruct"
|
||||
classpath="build/mapstruct"
|
||||
defaultexcludes="yes"
|
||||
destdir="build/mapstruct-binding/api"
|
||||
windowtitle="Lombok Mapstruct Binding"
|
||||
source="1.8" />
|
||||
|
||||
<!-- bugfix for boneheaded javadoc bug where ?is-external=true is inserted before an anchor ref, breaking the anchor ref.
|
||||
is-external=true doesn't actually do anything, so, we'll just get rid of it. -->
|
||||
<replaceregexp match="\?is-external=true#" replace="#" flags="gi">
|
||||
<fileset dir="build/mapstruct-binding/api" includes="**/*.html" />
|
||||
</replaceregexp>
|
||||
|
||||
<jar destfile="dist/lombok-mapstruct-binding-${mapstruct-binding.version}-javadoc.jar" basedir="build/mapstruct-binding/api" includes="**" />
|
||||
</target>
|
||||
|
||||
<target name="-mapstructBinding.jar" depends="dist,-mapstructBinding.prepare">
|
||||
<mkdir dir="build/mapstruct-binding/classes" />
|
||||
<echo file="build/mapstruct-binding/classes/META-INF/services/org.mapstruct.ap.spi.AstModifyingAnnotationProcessor">lombok.mapstruct.NotifierHider$AstModificationNotifier</echo>
|
||||
|
||||
<javac includeAntRuntime="false" source="1.9" target="1.9" destdir="build/mapstruct-binding/classes" modulepath="build/mapstruct-module-path">
|
||||
<src path="src/bindings/mapstruct" />
|
||||
</javac>
|
||||
<jar destfile="dist/lombok-mapstruct-binding-${mapstruct-binding.version}.jar" basedir="build/mapstruct-binding/classes" includes="**" />
|
||||
</target>
|
||||
|
||||
<target name="-mapstructBinding.src" depends="-mapstructBinding.jar">
|
||||
<jar destfile="dist/lombok-mapstruct-binding-${mapstruct-binding.version}-sources.jar" basedir="src/bindings/mapstruct" includes="**" />
|
||||
</target>
|
||||
|
||||
<target name="mapstructBinding.pack" depends="dist,-mapstructBinding.jar,-mapstructBinding.doc,-mapstructBinding.src">
|
||||
</target>
|
||||
|
||||
<target name="mapstructBinding.maven" depends="mapstructBinding.pack" description="Create a maven repo for mapstruct binding into a build dir.">
|
||||
<delete quiet="true" dir="build/mapstruct-binding-maven" />
|
||||
<mkdir dir="build/mapstruct-binding-maven" />
|
||||
<condition property="exe.mvn.base" value="mvn.cmd" else="mvn">
|
||||
<os family="windows" />
|
||||
</condition>
|
||||
<condition property="exe.mvn" value="${env.MAVEN_HOME}/bin/${exe.mvn.base}" else="${exe.mvn.base}">
|
||||
<isset property="env.MAVEN_HOME" />
|
||||
</condition>
|
||||
|
||||
<local name="mvn.result" />
|
||||
<exec executable="${exe.mvn}" failifexecutionfails="false" resultproperty="mvn.result">
|
||||
<arg value="deploy:deploy-file" />
|
||||
<arg value="-Dfile=dist/lombok-mapstruct-binding-${mapstruct-binding.version}.jar" />
|
||||
<arg value="-Dsources=dist/lombok-mapstruct-binding-${mapstruct-binding.version}-sources.jar" />
|
||||
<arg value="-Djavadoc=dist/lombok-mapstruct-binding-${mapstruct-binding.version}-javadoc.jar" />
|
||||
<arg value="-DgroupId=org.projectlombok" />
|
||||
<arg value="-DartifactId=lombok-mapstruct-binding" />
|
||||
<arg value="-Dversion=${mapstruct-binding.version}" />
|
||||
<arg value="-DpomFile=build/mapstruct-binding/maven/pom.xml" />
|
||||
<arg value="-Durl=file://${basedir}/build/mapstruct-binding-maven" />
|
||||
</exec>
|
||||
<fail>
|
||||
mvn is not on your path and/or MAVEN_HOME is not set. Add mvn to your path or set MAVEN_HOME to continue.
|
||||
<condition>
|
||||
<not><isset property="mvn.result" /></not>
|
||||
</condition>
|
||||
</fail>
|
||||
</target>
|
||||
</project>
|
||||
@@ -0,0 +1,126 @@
|
||||
<!--
|
||||
Copyright (C) 2020 The Project Lombok Authors.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
-->
|
||||
<project name="lombok.maven" xmlns:ivy="antlib:com.zwitserloot.ivyplusplus" basedir="..">
|
||||
<description>
|
||||
This buildfile is part of projectlombok.org. It makes maven-compatible repositories.
|
||||
</description>
|
||||
|
||||
<condition property="exe.mvn.base" value="mvn.cmd" else="mvn">
|
||||
<os family="windows" />
|
||||
</condition>
|
||||
<condition property="exe.mvn" value="${env.MAVEN_HOME}/bin/${exe.mvn.base}" else="${exe.mvn.base}">
|
||||
<isset property="env.MAVEN_HOME" />
|
||||
</condition>
|
||||
|
||||
<macrodef name="maven.make">
|
||||
<attribute name="version-name" />
|
||||
<sequential>
|
||||
<jar destfile="dist/lombok-${lombok.version}-javadoc.jar">
|
||||
<fileset dir="doc/api" />
|
||||
</jar>
|
||||
|
||||
<jar destfile="dist/lombok-${lombok.version}-sources.jar">
|
||||
<fileset dir="src/core" />
|
||||
<fileset dir="src/launch" />
|
||||
<fileset dir="src/utils" />
|
||||
<fileset dir="src/eclipseAgent" />
|
||||
<fileset dir="src/installer" />
|
||||
<fileset dir="src/delombok" />
|
||||
<fileset dir="test/transform/src" />
|
||||
<fileset dir="test/core/src" />
|
||||
</jar>
|
||||
|
||||
<copy tofile="build/pom.xml" overwrite="true" file="doc/maven-pom.xml">
|
||||
<filterchain>
|
||||
<replacetokens>
|
||||
<token key="VERSION" value="@{version-name}" />
|
||||
</replacetokens>
|
||||
</filterchain>
|
||||
</copy>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
<target name="maven" depends="version, dist, javadoc.build" description="Creates a maven repo for the current release into a build dir. The intent is for you to put that on a server someplace. Will invoke your local mvn installation.">
|
||||
<mkdir dir="build" />
|
||||
<mkdir dir="dist" />
|
||||
|
||||
<maven.make version-name="${lombok.version}" />
|
||||
<tar destfile="dist/mavenPublish.tar.bz2" compression="bzip2">
|
||||
<tarfileset dir="dist">
|
||||
<include name="lombok-${lombok.version}.jar" />
|
||||
<include name="lombok-${lombok.version}-sources.jar" />
|
||||
<include name="lombok-${lombok.version}-javadoc.jar" />
|
||||
</tarfileset>
|
||||
<tarfileset dir="build" includes="pom.xml" />
|
||||
</tar>
|
||||
</target>
|
||||
|
||||
<target name="maven.publish" depends="maven, setup.ssh">
|
||||
<ivy:scpUpload
|
||||
from="dist/mavenPublish.tar.bz2"
|
||||
to="/data/lombok/staging"
|
||||
server="projectlombok.org"
|
||||
username="${ssh.username}"
|
||||
keyfile="${ssh.keyfile}"
|
||||
knownHosts="ssh.knownHosts" />
|
||||
<ivy:sshExec
|
||||
cmd="/data/lombok/stagingCmd/publishToMavenCentral"
|
||||
server="projectlombok.org"
|
||||
username="${ssh.username}"
|
||||
keyfile="${ssh.keyfile}"
|
||||
knownHosts="ssh.knownHosts" />
|
||||
<echo>The artifact has been published to staging. Now go to https://oss.sonatype.org/ and log in as Reinier, then doublecheck if all is well and 'release' it.</echo>
|
||||
<ivy:sshExec
|
||||
cmd="/data/lombok/stagingCmd/showMavenCentralPassword"
|
||||
server="projectlombok.org"
|
||||
username="${ssh.username}"
|
||||
keyfile="${ssh.keyfile}"
|
||||
knownHosts="ssh.knownHosts" />
|
||||
</target>
|
||||
|
||||
<target name="maven.edge" depends="version, dist, javadoc.build" description="Create a maven repo for the current snapshot into a build dir. The intent is for you to put that on a server someplace. Will invoke your local mvn installation.">
|
||||
<delete quiet="true" dir="build/edge-releases" />
|
||||
<mkdir dir="build/edge-releases" />
|
||||
|
||||
<maven.make version-name="edge-SNAPSHOT" />
|
||||
|
||||
<local name="mvn.result" />
|
||||
<exec executable="${exe.mvn}" failifexecutionfails="false" resultproperty="mvn.result">
|
||||
<arg value="deploy:deploy-file" />
|
||||
<arg value="-Dfile=dist/lombok-${lombok.version}.jar" />
|
||||
<arg value="-Dsources=dist/lombok-${lombok.version}-sources.jar" />
|
||||
<arg value="-Djavadoc=dist/lombok-${lombok.version}-javadoc.jar" />
|
||||
<arg value="-DgroupId=org.projectlombok" />
|
||||
<arg value="-DartifactId=lombok" />
|
||||
<arg value="-Dversion=edge-SNAPSHOT" />
|
||||
<arg value="-DpomFile=build/pom.xml" />
|
||||
<arg value="-Durl=file://${basedir}/build/edge-releases" />
|
||||
</exec>
|
||||
|
||||
<fail>
|
||||
mvn is not on your path and/or MAVEN_HOME is not set. Add mvn to your path or set MAVEN_HOME to continue.
|
||||
<condition>
|
||||
<not><isset property="mvn.result" /></not>
|
||||
</condition>
|
||||
</fail>
|
||||
</target>
|
||||
</project>
|
||||
@@ -0,0 +1,188 @@
|
||||
<!--
|
||||
Copyright (C) 2020 The Project Lombok Authors.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
-->
|
||||
<project name="lombok.setup" default="deps" xmlns:ivy="antlib:com.zwitserloot.ivyplusplus" basedir="..">
|
||||
<description>
|
||||
This buildfile is part of projectlombok.org. It sets up the build itself.
|
||||
</description>
|
||||
|
||||
<property name="pattern.jdk11plus" value="^(\d\d\d+|1[1-9]|[2-9]\d)(\..*)?$" />
|
||||
<property name="ivy.retrieve.pattern" value="lib/[conf]/[organisation]-[artifact].[ext]" />
|
||||
<property environment="env" />
|
||||
<available file="lib/ivyplusplus.jar" property="ivyplusplus.available" />
|
||||
|
||||
<property name="jdk6-rt.loc" location="lib/openjdk6_rt.jar" />
|
||||
<property name="jdk8-rt.loc" location="lib/openjdk8_rt.jar" />
|
||||
<available file="${jdk6-rt.loc}" property="jdk6-rt.available" />
|
||||
<available file="${jdk8-rt.loc}" property="jdk8-rt.available" />
|
||||
<property name="ssh.configuration.file" location="ssh.configuration" />
|
||||
|
||||
<target name="-setup.ssh.ask">
|
||||
<property file="${ssh.configuration.file}" />
|
||||
<fail>
|
||||
Your ssh.configuration file is corrupted; delete it and rerun this script.
|
||||
<condition>
|
||||
<or>
|
||||
<and>
|
||||
<isset property="ssh.username" />
|
||||
<equals arg1="" arg2="${ssh.username}" />
|
||||
</and>
|
||||
<and>
|
||||
<isset property="ssh.keyfile" />
|
||||
<equals arg1="" arg2="${ssh.keyfile}" />
|
||||
</and>
|
||||
</or>
|
||||
</condition>
|
||||
</fail>
|
||||
<fail>
|
||||
The keyfile configured in your ${ssh.configuration.file} file does not exist.
|
||||
<condition>
|
||||
<and>
|
||||
<isset property="ssh.keyfile" />
|
||||
<not><available file="${ssh.keyfile}" /></not>
|
||||
</and>
|
||||
</condition>
|
||||
</fail>
|
||||
|
||||
<condition property="ssh.configuration.write">
|
||||
<or>
|
||||
<not><isset property="ssh.username" /></not>
|
||||
<not><isset property="ssh.keyfile" /></not>
|
||||
</or>
|
||||
</condition>
|
||||
<input message="What is your SSH username on the projectlombok.org server? (Enter to abort)." addproperty="ssh.username" />
|
||||
<fail>Aborted<condition><equals arg1="" arg2="${ssh.username}" /></condition></fail>
|
||||
<input message="Where is your ssh keyfile located? (Enter to abort)." addproperty="ssh.keyfile" defaultvalue="${user.home}/.ssh/id_rsa" />
|
||||
<fail>File ${ssh.keyfile} does not exist<condition><not><available file="${ssh.keyfile}" /></not></condition></fail>
|
||||
</target>
|
||||
|
||||
<target name="-setup.ssh.save" if="ssh.configuration.write">
|
||||
<propertyfile file="${ssh.configuration.file}" comment="SSH connect info for projectlombok.org.">
|
||||
<entry key="ssh.username" value="${ssh.username}" />
|
||||
<entry key="ssh.keyfile" value="${ssh.keyfile}" />
|
||||
</propertyfile>
|
||||
<echo>Your connection info has been written to ${ssh.configuration.file} and will be remembered for future invocations.</echo>
|
||||
</target>
|
||||
|
||||
<target name="setup.ssh" depends="-setup.ssh.ask, -setup.ssh.save" />
|
||||
|
||||
<target name="clean" description="Removes all generated files.">
|
||||
<delete dir="build" quiet="true" />
|
||||
</target>
|
||||
|
||||
<target name="clean.dist" depends="clean" description="Deletes everything that this build script has ever generated.">
|
||||
<delete dir="lib" quiet="true" />
|
||||
<delete dir="dist" quiet="true" />
|
||||
<delete file=".project" quiet="true" />
|
||||
<delete file=".classpath" quiet="true" />
|
||||
<delete dir=".settings" quiet="true" />
|
||||
<delete dir=".idea" quiet="true" />
|
||||
<delete file="lombok.iml" quiet="true" />
|
||||
<delete dir="ivyCache" quiet="true" />
|
||||
</target>
|
||||
|
||||
<target name="-ipp.download" unless="ivyplusplus.available">
|
||||
<mkdir dir="lib" />
|
||||
<get src="https://projectlombok.org/downloads/ivyplusplus.jar" dest="lib/ivyplusplus.jar" usetimestamp="true" />
|
||||
</target>
|
||||
|
||||
<target name="-ipp.load" depends="-ipp.download">
|
||||
<taskdef classpath="lib/ivyplusplus.jar" resource="com/zwitserloot/ivyplusplus/antlib.xml" uri="antlib:com.zwitserloot.ivyplusplus" />
|
||||
<ivy:ensureippversion version="1.36" property="ivyplusplus.minimumAvailable" />
|
||||
</target>
|
||||
|
||||
<target name="-ipp.redownload" unless="ivyplusplus.minimumAvailable">
|
||||
<get src="https://projectlombok.org/downloads/ivyplusplus.jar" dest="lib/ivyplusplus.jar" />
|
||||
<fail>A new version of ivyplusplus was required and has been downloaded. Rerun the script to continue.</fail>
|
||||
</target>
|
||||
|
||||
<target name="ipp.setup" depends="-ipp.load, -ipp.redownload" />
|
||||
|
||||
<target name="ivy.config" depends="ipp.setup" unless="ivy.config">
|
||||
<ivy:configure file="buildScripts/ivysettings.xml" />
|
||||
<property name="ivy.config" value="true" />
|
||||
</target>
|
||||
|
||||
<target name="deps.jdk6-runtime" unless="jdk6-rt.available">
|
||||
<echo>To ensure stable builds and avoid accessing API that was not available in JDK6, most of lombok is set up to build against OpenJDK6's runtime, which will now be downloaded...</echo>
|
||||
<mkdir dir="lib" />
|
||||
<get src="https://projectlombok.org/ivyrepo/langtools/rt-openjdk6.jar" dest="${jdk6-rt.loc}" verbose="true" usetimestamp="true" />
|
||||
</target>
|
||||
|
||||
<target name="deps.jdk8-runtime" unless="jdk8-rt.available">
|
||||
<echo>To test java8, we need a java8 runtime, which will now be downloaded...</echo>
|
||||
<mkdir dir="lib" />
|
||||
<get src="https://projectlombok.org/ivyrepo/langtools/rt-openjdk8.jar" dest="${jdk8-rt.loc}" verbose="true" usetimestamp="true" />
|
||||
</target>
|
||||
|
||||
<target name="deps.jdk-runtime" depends="deps.jdk6-runtime, deps.jdk8-runtime" />
|
||||
|
||||
<target name="deps.custom" depends="ivy.config" description="Download the dependencies that comprise a configuration (from ivy.xml)">
|
||||
<fail unless="deps.conf">Supply ant with -Ddeps.conf=confname to pick the configuration you want to fetch</fail>
|
||||
<ivy:resolve file="buildScripts/ivy.xml" refresh="true" conf="${deps.conf}" />
|
||||
<ivy:retrieve symlink="true" />
|
||||
</target>
|
||||
|
||||
<macrodef name="fetchdep.ecj">
|
||||
<attribute name="version" />
|
||||
<sequential>
|
||||
<ivy:resolve file="buildScripts/ivy.xml" refresh="true" conf="ecj@{version}" />
|
||||
<ivy:retrieve symlink="true" />
|
||||
<ivy:cachepath pathid="cp.ecj@{version}" conf="ecj@{version}" />
|
||||
<property name="cp.ecj@{version}" refid="cp.ecj@{version}" />
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
<macrodef name="fetchdep.eclipse">
|
||||
<attribute name="version" />
|
||||
<sequential>
|
||||
<ivy:resolve file="buildScripts/ivy.xml" refresh="true" conf="eclipse-@{version}" />
|
||||
<ivy:retrieve symlink="true" />
|
||||
<ivy:cachepath pathid="cp.eclipse-@{version}" conf="eclipse-@{version}" />
|
||||
<property name="cp.eclipse-@{version}" refid="cp.eclipse-@{version}" />
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
<target name="deps" depends="ivy.config, deps.jdk-runtime" description="Downloads all dependencies needed for common tasks">
|
||||
<ivy:resolve file="buildScripts/ivy.xml" refresh="true" conf="javac6,javac8,ecj8,build,eclipse-oxygen,mapstruct,sources,stripe,buildtools,test" />
|
||||
<ivy:retrieve symlink="true" />
|
||||
<ivy:cachepath pathid="cp.javac6" conf="javac6" />
|
||||
<ivy:cachepath pathid="cp.javac8" conf="javac8" />
|
||||
<ivy:cachepath pathid="cp.ecj8" conf="ecj8" />
|
||||
<ivy:cachepath pathid="cp.build" conf="build" />
|
||||
<ivy:cachepath pathid="cp.eclipse-oxygen" conf="eclipse-oxygen" />
|
||||
<ivy:cachepath pathid="cp.mapstruct" conf="mapstruct" />
|
||||
<ivy:cachepath pathid="cp.stripe" conf="stripe" />
|
||||
<ivy:cachepath pathid="cp.buildtools" conf="buildtools" />
|
||||
<ivy:cachepath pathid="cp.test" conf="test" />
|
||||
</target>
|
||||
|
||||
<fail>ant needs to be at least v1.10.0 or higher to build lombok. Your version is: ${ant.version}
|
||||
<condition>
|
||||
<not><antversion atleast="1.10.0" /></not>
|
||||
</condition>
|
||||
</fail>
|
||||
<fail>lombok must be compiled on jdk11 or later. Your version is: ${ant.java.version}
|
||||
<condition>
|
||||
<not><matches string="${ant.java.version}" pattern="${pattern.jdk11plus}" /></not>
|
||||
</condition>
|
||||
</fail>
|
||||
</project>
|
||||
@@ -0,0 +1,181 @@
|
||||
<!--
|
||||
Copyright (C) 2020 The Project Lombok Authors.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
-->
|
||||
<project name="lombok.tests" default="test" xmlns:ivy="antlib:com.zwitserloot.ivyplusplus" basedir="..">
|
||||
<description>
|
||||
This buildfile is part of projectlombok.org. It takes care of compiling and running tests.
|
||||
</description>
|
||||
|
||||
<target name="test.compile" depends="deps, compile" description="compiles the tests" unless="skip.tests">
|
||||
<mkdir dir="build/tests" />
|
||||
<ivy:compile destdir="build/teststubs" source="1.6" target="1.6" ecj="true" nowarn="true">
|
||||
<src path="test/stubs" />
|
||||
</ivy:compile>
|
||||
<ivy:compile destdir="build/tests" source="1.5" target="1.5" ecj="true" nowarn="true">
|
||||
<bootclasspath path="${jdk6-rt.loc}" />
|
||||
<classpath refid="cp.test" />
|
||||
<classpath refid="cp.eclipse-oxygen" />
|
||||
<classpath location="build/lombok" />
|
||||
<classpath location="build/tests" />
|
||||
<src path="test/core/src" />
|
||||
<src path="test/transform/src" />
|
||||
<src path="test/bytecode/src" />
|
||||
<src path="test/configuration/src" />
|
||||
</ivy:compile>
|
||||
<mkdir dir="build/teststubs" />
|
||||
<ivy:compile destdir="build/teststubs" source="1.6" target="1.6" ecj="true" nowarn="true">
|
||||
<src path="test/stubs" />
|
||||
</ivy:compile>
|
||||
</target>
|
||||
|
||||
<target name="test.ecj11" depends="deps, dist" description="Runs a few ecj-specific tests" unless="skip.tests">
|
||||
<java jar="lib/ecj11/org.eclipse.jdt-ecj.jar" fork="true" failonerror="true">
|
||||
<jvmarg value="-javaagent:dist/lombok.jar=ecj" />
|
||||
<arg line="-source 1.6 -target 1.6 -cp dist/lombok.jar test/ecj/SimpleTest.java" />
|
||||
</java>
|
||||
<echo>run ecj11 with a test file to confirm agent injection works: OK</echo>
|
||||
</target>
|
||||
|
||||
<property name="test.addopens.raw">
|
||||
--add-opens jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
|
||||
--add-opens jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
|
||||
--add-opens jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED
|
||||
--add-opens jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED
|
||||
--add-opens jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED
|
||||
--add-opens jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
|
||||
--add-opens jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
|
||||
--add-opens jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
|
||||
</property>
|
||||
<property name="test.limitmodules">--limit-modules java.base,jdk.unsupported</property>
|
||||
|
||||
<loadresource property="test.addopens">
|
||||
<propertyresource name="test.addopens.raw" />
|
||||
<filterchain><tokenfilter>
|
||||
<filetokenizer />
|
||||
<replaceregex pattern="\s+" replace=" " flags="g" />
|
||||
</tokenfilter></filterchain>
|
||||
</loadresource>
|
||||
|
||||
<target name="test.javac6" depends="test.compile" description="runs the tests on your default VM, using javac6 as underlying compiler">
|
||||
<echo>Running TestJavac on JVM${ant.java.version}, with lowest supported javac: 1.6.</echo>
|
||||
<junit haltonfailure="yes" fork="true" forkmode="once">
|
||||
<jvmarg value="-Xbootclasspath/a:${jdk6-rt.loc}" />
|
||||
<jvmarg line="${test.limitmodules}" />
|
||||
<jvmarg value="-Ddelombok.bootclasspath=${jdk6-rt.loc}" />
|
||||
<formatter type="plain" usefile="false" unless="tests.quiet" />
|
||||
<classpath refid="cp.test" />
|
||||
<classpath refid="cp.stripe" />
|
||||
<classpath refid="cp.javac6" />
|
||||
<classpath location="build/lombok" />
|
||||
<classpath location="build/tests" />
|
||||
<test name="lombok.TestJavac" />
|
||||
</junit>
|
||||
</target>
|
||||
|
||||
<target name="test.javac8" depends="test.compile, deps.jdk8-runtime" description="runs the tests on your default VM, using javac8 as underlying compiler">
|
||||
<echo>Running TestJavac on JVM${ant.java.version}, with javac: 1.8.</echo>
|
||||
<junit haltonfailure="yes" fork="true" forkmode="once">
|
||||
<jvmarg value="-Xbootclasspath/a:${jdk8-rt.loc}" />
|
||||
<jvmarg line="${test.limitmodules}" />
|
||||
<jvmarg value="-Ddelombok.bootclasspath=${jdk8-rt.loc}" />
|
||||
<formatter type="plain" usefile="false" unless="tests.quiet" />
|
||||
<classpath refid="cp.test" />
|
||||
<classpath refid="cp.stripe" />
|
||||
<classpath refid="cp.javac8" />
|
||||
<classpath location="build/lombok" />
|
||||
<classpath location="build/tests" />
|
||||
<test name="lombok.TestJavac" />
|
||||
</junit>
|
||||
</target>
|
||||
|
||||
<macrodef name="test.javacX">
|
||||
<attribute name="version" />
|
||||
<sequential>
|
||||
<find-vm version="@{version}" />
|
||||
<echo>Running TestJavac with JVM ${jvm.loc.@{version}}.</echo>
|
||||
|
||||
<junit haltonfailure="yes" fork="true" forkmode="once" jvm="${jvm.loc.@{version}}/bin/${exe.java}">
|
||||
<jvmarg line="${test.addopens}" />
|
||||
<formatter type="plain" usefile="false" unless="tests.quiet" />
|
||||
<classpath refid="cp.test" />
|
||||
<classpath refid="cp.stripe" />
|
||||
<classpath location="build/lombok" />
|
||||
<classpath location="build/tests" />
|
||||
<classpath location="build/teststubs" />
|
||||
<test name="lombok.TestJavac" />
|
||||
</junit>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
<target name="test.javac11" depends="test.compile" description="runs the tests on your default VM, using javac11 as underlying compiler">
|
||||
<test.javacX version="11" />
|
||||
</target>
|
||||
|
||||
<target name="test.javac14" depends="test.compile" description="runs the tests on your default VM, using javac14 as underlying compiler">
|
||||
<test.javacX version="14" />
|
||||
</target>
|
||||
|
||||
<target name="test.javacCurrent" depends="test.compile" description="runs the tests on your default VM, using its javac as underlying compiler">
|
||||
<echo>Running TestJavac on JVM${ant.java.version}, with the javac built into your VM distributon.</echo>
|
||||
<junit haltonfailure="yes" fork="true" forkmode="once">
|
||||
<jvmarg line="${test.addopens}" />
|
||||
<formatter type="plain" usefile="false" unless="tests.quiet" />
|
||||
<classpath refid="cp.test" />
|
||||
<classpath refid="cp.stripe" />
|
||||
<classpath location="build/lombok" />
|
||||
<classpath location="build/tests" />
|
||||
<classpath location="build/teststubs" />
|
||||
<test name="lombok.TestJavac" />
|
||||
</junit>
|
||||
</target>
|
||||
|
||||
<macrodef name="test.eclipse-X">
|
||||
<attribute name="version" />
|
||||
<sequential>
|
||||
<echo>Running TestEclipse on eclipse-@{version} on JVM${ant.java.version}.</echo>
|
||||
<junit haltonfailure="yes" fork="true" forkmode="once">
|
||||
<jvmarg value="-Xbootclasspath/a:${jdk8-rt.loc}" />
|
||||
<jvmarg value="-Ddelombok.bootclasspath=${jdk8-rt.loc}" />
|
||||
<jvmarg value="-javaagent:dist/lombok.jar" />
|
||||
<jvmarg line="${test.addopens}" />
|
||||
<formatter type="plain" usefile="false" unless="tests.quiet" />
|
||||
<classpath refid="cp.test" />
|
||||
<classpath refid="cp.stripe" />
|
||||
<classpath refid="cp.eclipse-@{version}" />
|
||||
<classpath location="build/lombok" />
|
||||
<classpath location="build/tests" />
|
||||
<test name="lombok.TestEclipse" />
|
||||
</junit>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
<target name="test.eclipse-oxygen" depends="test.compile" description="runs the tests on your default VM, testing the oxygen release of eclipse">
|
||||
<test.eclipse-X version="oxygen" />
|
||||
</target>
|
||||
|
||||
<target name="test.eclipse-202006" depends="test.compile" description="runs the tests on your default VM, testing the 2020-03 release of eclipse">
|
||||
<fetchdep.eclipse version="202006" />
|
||||
<test.eclipse-X version="202006" />
|
||||
</target>
|
||||
|
||||
<target name="test" depends="test.javacCurrent, test.eclipse-202006" description="runs the tests against the default JVM, javac, and eclipse" />
|
||||
<target name="test.broad" depends="test.javac8, test.javac14, test.eclipse-oxygen, test.eclipse-202006" description="runs the tests against the default JVM, javac, and eclipse" />
|
||||
</project>
|
||||
@@ -0,0 +1,191 @@
|
||||
<!--
|
||||
Copyright (C) 2020 The Project Lombok Authors.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
-->
|
||||
<project name="lombok.vm-finder" xmlns:ivy="antlib:com.zwitserloot.ivyplusplus" basedir="..">
|
||||
<description>
|
||||
This buildfile is part of projectlombok.org. It contains platform specific code to find installed JVMs.
|
||||
</description>
|
||||
|
||||
<available property="exe.java_home" value="/usr/libexec/java_home" file="/usr/libexec/java_home" />
|
||||
<property name="env.SystemRoot" value="C:\Windows" />
|
||||
<available property="exe.reg" value="${env.SystemRoot}/System32/reg.exe" file="${env.SystemRoot}/System32/reg.exe" />
|
||||
<condition property="exe.java" value="java.exe" else="java">
|
||||
<os family="windows" />
|
||||
</condition>
|
||||
|
||||
<property name="jvm.locations.file" location="jvm.locations" />
|
||||
<property prefix="jvm.locations" file="${jvm.locations.file}" />
|
||||
|
||||
<target name="-find.vm.property">
|
||||
<condition property="jvm.loc" value="${jvm.loc.force}">
|
||||
<and>
|
||||
<isset property="jvm.loc.force" />
|
||||
<not><matches string="${jvm.loc.force}" pattern="^\$\{jvm[0-9\.]+\.loc\}$" /></not>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="jvm.loc.invalid">
|
||||
<and>
|
||||
<isset property="jvm.loc" />
|
||||
<not><available file="${jvm.loc}/bin/${exe.java}" type="file" /></not>
|
||||
</and>
|
||||
</condition>
|
||||
<fail if="jvm.loc.invalid">
|
||||
.
|
||||
|
||||
ERROR: You explicitly specified the home of JVM${find-vm.version} as: ${jvm.loc} in the ${jvm.locations.file} file.
|
||||
However, ${jvm.loc}/bin/${exe.java} does not exist or is not executable. Please fix the entry in jvm.locations, or delete it
|
||||
and rerun the build; this build is capable of finding VMs automatically on many platforms.
|
||||
</fail>
|
||||
</target>
|
||||
|
||||
<target name="-find.vm.java_home" if="exe.java_home" unless="jvm.loc">
|
||||
<fail unless="find-vm.version">Set property find-vm.version first</fail>
|
||||
<local name="java_home.answer" />
|
||||
<local name="java_home.result" />
|
||||
<exec executable="${exe.java_home}" errorproperty="discard" outputproperty="java_home.answer" failifexecutionfails="false" resultproperty="java_home.result">
|
||||
<arg value="-v" />
|
||||
<arg value="${find-vm.version}" />
|
||||
</exec>
|
||||
<condition property="jvm.loc" value="${java_home.answer}">
|
||||
<equals arg1="0" arg2="${java_home.result}" />
|
||||
</condition>
|
||||
</target>
|
||||
|
||||
<target name="-find.vm.reg" if="exe.reg" unless="jvm.loc">
|
||||
<fail unless="find-vm.version">Set property find-vm.version first</fail>
|
||||
|
||||
<macrodef name="findkey">
|
||||
<attribute name="idx" />
|
||||
<attribute name="key" />
|
||||
<attribute name="regex" />
|
||||
<attribute name="value" />
|
||||
<sequential>
|
||||
<local name="reg.answer1.@{idx}" />
|
||||
<local name="reg.result1.@{idx}" />
|
||||
<local name="reg.first.@{idx}" />
|
||||
<local name="reg.answer2.@{idx}" />
|
||||
<local name="reg.result2.@{idx}" />
|
||||
<exec executable="${exe.reg}" errorproperty="discard" outputproperty="reg.answer1.@{idx}" failifexecutionfails="false" resultproperty="reg.result1.@{idx}">
|
||||
<arg value="query" />
|
||||
<arg value="@{key}" />
|
||||
<arg value="/f" />
|
||||
<arg value="${find-vm.version}"/>
|
||||
<arg value="/k" />
|
||||
</exec>
|
||||
|
||||
<loadresource property="reg.first.@{idx}">
|
||||
<propertyresource name="reg.answer1.@{idx}" />
|
||||
<filterchain>
|
||||
<tokenfilter>
|
||||
<containsregex flags="i" pattern="@{regex}" replace="\1" />
|
||||
<trim />
|
||||
<ignoreblank />
|
||||
</tokenfilter>
|
||||
<headfilter lines="1" />
|
||||
<striplinebreaks />
|
||||
</filterchain>
|
||||
</loadresource>
|
||||
<exec executable="${exe.reg}" errorproperty="discard" outputproperty="reg.answer2.@{idx}" failifexecutionfails="false" resultproperty="reg.result2.@{idx}">
|
||||
<arg value="query" />
|
||||
<arg value="${reg.first.@{idx}}" />
|
||||
<arg value="/s" />
|
||||
<arg value="/f" />
|
||||
<arg value="@{value}" />
|
||||
<arg value="/v" />
|
||||
<arg value="@{value}" />
|
||||
</exec>
|
||||
<loadresource property="jvm.loc">
|
||||
<propertyresource name="reg.answer2.@{idx}" />
|
||||
<filterchain>
|
||||
<tokenfilter>
|
||||
<trim />
|
||||
<containsregex flags="i" pattern="\s*@{value}\s*REG_SZ\s*(.*)$" replace="\1" />
|
||||
<ignoreblank />
|
||||
</tokenfilter>
|
||||
<headfilter lines="1" />
|
||||
<striplinebreaks />
|
||||
</filterchain>
|
||||
</loadresource>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
<findkey idx="1" key="hklm\Software\AdoptOpenJDK\JDK" value="Path"
|
||||
regex="\s*(HKEY.*\\AdoptOpenJDK\\JDK\\${find-vm.version}(?:\.\S*)?)\s*$" />
|
||||
<findkey idx="2" key="hklm\Software\JavaSoft\Java Development Kit" value="JavaHome"
|
||||
regex="\s*(HKEY.*\\JavaSoft\\Java Development Kit\\${find-vm.version}(?:\.\S*)?)\s*$" />
|
||||
</target>
|
||||
|
||||
<target name="-find.vm.ask" unless="jvm.loc">
|
||||
<fail unless="find-vm.version">Set property find-vm.version first</fail>
|
||||
<echo>A JVM${find-vm.version} is required to run the request tests.</echo>
|
||||
<echo>this script can automatically find VMs on mac and windows but did not find a suitable VM.</echo>
|
||||
<input message="Enter the full path to JVM${find-vm.version}:" addproperty="jvm.loc" />
|
||||
<condition property="jvm.loc.aborted">
|
||||
<matches pattern="^\s*$" string="${jvm.loc}" />
|
||||
</condition>
|
||||
<fail if="jvm.loc.aborted">aborted</fail>
|
||||
<fail if="jvm.loc.invalid">.
|
||||
|
||||
ERROR: That does not appear to be a valid location; ${jvm.loc}/bin/${exe.java} should exist.
|
||||
<condition>
|
||||
<not><available file="${jvm.loc}/bin/${exe.java}" type="file" /></not>
|
||||
</condition>
|
||||
</fail>
|
||||
<exec executable="${jvm.loc}/bin/${exe.java}" errorproperty="jvm.versioncheck.answer" failifexecutionfails="false" resultproperty="jvm.versioncheck.result">
|
||||
<arg value="-version" />
|
||||
</exec>
|
||||
<fail>
|
||||
That does not appear to be a valid JVM${find-vm.version} - perhaps it isn't the right version?
|
||||
<condition>
|
||||
<not><and>
|
||||
<equals arg1="${jvm.versioncheck.result}" arg2="0" />
|
||||
<contains string="${jvm.versioncheck.answer}" substring="version "${find-vm.version}" />
|
||||
</and></not>
|
||||
</condition>
|
||||
</fail>
|
||||
<propertyfile file="${jvm.locations.file}" comment="Locations of various JVMs to be used to run lombok tests if targeting specific versions.">
|
||||
<entry key="j${find-vm.version}" value="${jvm.loc}" />
|
||||
</propertyfile>
|
||||
<echo>Your choice of VM has been written to ${jvm.locations.file} and will be remembered for future invocations.</echo>
|
||||
</target>
|
||||
|
||||
<target name="-find.vm.save" if="jvm.loc">
|
||||
<mkdir dir="build" />
|
||||
<echo file="build/vmloc.${find-vm.version}.tmp" message="${jvm.loc}" />
|
||||
</target>
|
||||
|
||||
<target name="-find.vm" depends="-find.vm.property, -find.vm.java_home, -find.vm.reg, -find.vm.ask, -find.vm.save">
|
||||
<fail unless="jvm.loc">JVM ${find-vm.version} cannot be found</fail>
|
||||
</target>
|
||||
|
||||
<macrodef name="find-vm">
|
||||
<attribute name="version" />
|
||||
<sequential>
|
||||
<delete quiet="true" file="build/vmloc.@{version}.tmp" />
|
||||
<antcall target="-find.vm">
|
||||
<param name="find-vm.version" value="@{version}" />
|
||||
<param name="jvm.loc.force" value="${jvm.locations.j@{version}}" />
|
||||
</antcall>
|
||||
<loadfile property="jvm.loc.@{version}" failonerror="true" srcFile="build/vmloc.@{version}.tmp" />
|
||||
<delete quiet="true" file="build/vmloc.@{version}.tmp" />
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</project>
|
||||
+216
-185
@@ -1,5 +1,5 @@
|
||||
<!--
|
||||
Copyright (C) 2010-2020 The Project Lombok Authors.
|
||||
Copyright (C) 2020 The Project Lombok Authors.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -25,118 +25,77 @@ This buildfile is part of projectlombok.org. It is responsible for building the
|
||||
such as applying the templates to produce the website, converting the changelog into HTML, and creating javadoc.
|
||||
</description>
|
||||
|
||||
<taskdef classpath="lib/ivyplusplus.jar" resource="com/zwitserloot/ivyplusplus/antlib.xml" uri="antlib:com.zwitserloot.ivyplusplus" />
|
||||
|
||||
<path id="build.path">
|
||||
<fileset dir="lib/build">
|
||||
<include name="**/*.jar" />
|
||||
</fileset>
|
||||
</path>
|
||||
|
||||
<property name="web.root" value="https://projectlombok.org/" />
|
||||
<property name="SNIPPET_TAB_STOP" value="2" />
|
||||
|
||||
<target name="-website-clean">
|
||||
<target name="-website.clean">
|
||||
<delete dir="build/website" quiet="true" />
|
||||
</target>
|
||||
|
||||
<target name="website-only" description="Prepares the website for distribution using the lombok version currently 'live'." depends="-fetch-version-from-site, -show-version, -ensure-version, -website-main, -delete-edge-page" />
|
||||
|
||||
<target name="-delete-edge-page">
|
||||
<delete file="build/website/download-edge.html" />
|
||||
</target>
|
||||
|
||||
<target name="website" description="Prepares the website for distribution" depends="javadoc, -website-main" />
|
||||
|
||||
<target name="website-supporters" description="Updates website supporters store and adds it to the website build.">
|
||||
<ant antfile="buildScripts/supporters.ant.xml" target="deployToWebsiteBuild" inheritAll="false" />
|
||||
</target>
|
||||
|
||||
<target name="-fetch-version-from-site" depends="-compile-webclasses">
|
||||
<fail if="lombok.version">lombok.version already set.</fail>
|
||||
<fail if="lombok.fullversion">lombok.fullversion already set.</fail>
|
||||
<java classname="lombok.website.FetchCurrentVersion" outputproperty="lombok.version" failonerror="true">
|
||||
<!-- Fetches the current (latest) lombok available from projectlombok.org, tracking this 'latest available version' in ant properties -->
|
||||
<target name="-website.fetch-version" depends="compile.support">
|
||||
<java classname="lombok.website.FetchCurrentVersion" outputproperty="lombok.version.live" failonerror="true">
|
||||
<classpath>
|
||||
<path refid="build.path" />
|
||||
<pathelement location="build/webclasses" />
|
||||
<path refid="cp.buildtools" />
|
||||
<pathelement location="build/support" />
|
||||
</classpath>
|
||||
<arg value="${web.root}" />
|
||||
<arg value="base" />
|
||||
</java>
|
||||
<java classname="lombok.website.FetchCurrentVersion" outputproperty="lombok.fullversion" failonerror="true">
|
||||
<java classname="lombok.website.FetchCurrentVersion" outputproperty="lombok.fullversion.live" failonerror="true">
|
||||
<classpath>
|
||||
<path refid="build.path" />
|
||||
<pathelement location="build/webclasses" />
|
||||
<path refid="cp.buildtools" />
|
||||
<pathelement location="build/support" />
|
||||
</classpath>
|
||||
<arg value="${web.root}" />
|
||||
<arg value="full" />
|
||||
</java>
|
||||
</target>
|
||||
|
||||
<target name="-ensure-version" unless="lombok.version">
|
||||
<fail>Supply lombok.version</fail>
|
||||
<target name="website.print-live-version" depends="-website.fetch-version" description="Print the current version of lombok available from projectlombok.org">
|
||||
<echo>Live version: ${lombok.version.live}</echo>
|
||||
<echo>Live full versionstring : ${lombok.fullversion.live}</echo>
|
||||
</target>
|
||||
|
||||
<target name="-show-version">
|
||||
<echo>Version: ${lombok.version}</echo>
|
||||
<echo>Full: ${lombok.fullversion}</echo>
|
||||
</target>
|
||||
|
||||
<target name="-ensure-fullversion" unless="lombok.fullversion">
|
||||
<fail>Supply lombok.fullversion</fail>
|
||||
</target>
|
||||
|
||||
<target name="-compile-webclasses">
|
||||
<mkdir dir="build/webclasses" />
|
||||
<javac includeDestClasses="false" includeantruntime="false" destdir="build/webclasses" debug="on" source="1.8" target="1.8">
|
||||
<compilerarg value="-proc:none" />
|
||||
<compilerarg value="-Xlint:-options" />
|
||||
<classpath refid="build.path" />
|
||||
<src path="src/website" />
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<target name="changelogToHtml" depends="-compile-webclasses">
|
||||
<target name="changelog.build" depends="version, deps, compile.support" description="Turns the current changelog (doc/changelog.txt) into HTML">
|
||||
<mkdir dir="build/website" />
|
||||
<java classname="lombok.website.WebsiteMaker" failonerror="true">
|
||||
<classpath>
|
||||
<path refid="build.path" />
|
||||
<pathelement location="build/webclasses" />
|
||||
</classpath>
|
||||
<path refid="cp.buildtools" />
|
||||
<pathelement location="build/support" />
|
||||
</classpath>
|
||||
<arg value="${web.root}" />
|
||||
<arg value="${lombok.version}" />
|
||||
<arg value="${lombok.fullversion}" />
|
||||
<arg value="changelog" />
|
||||
</java>
|
||||
</target>
|
||||
|
||||
<target name="-website-main" depends="-ensure-version, -ensure-fullversion, -website-clean, -compile-webclasses, changelogToHtml">
|
||||
<mkdir dir="build/website" />
|
||||
<copy todir="build/website">
|
||||
<fileset dir="website/resources" />
|
||||
<fileset dir=".">
|
||||
<include name="LICENSE" />
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<get src="https://code.jquery.com/jquery-3.3.1.min.js" dest="build/website/js/jquery.min.js" />
|
||||
<target name="-website.clientdeps">
|
||||
<mkdir dir="build/website/js" />
|
||||
<get src="https://code.jquery.com/jquery-3.3.1.min.js" dest="build/website/js/jquery.min.js" usetimestamp="true" />
|
||||
<fail message="jQuery checksum failed">
|
||||
<condition><not>
|
||||
<checksum file="build/website/js/jquery.min.js" algorithm="SHA-384" property="b6c405aa91117aeed92e1055d9566502eef370e57ead76d8945d9ca81f2dc48ffc6996a38e9e01a9df95e83e4882f293" verifyproperty="jquery.ok" />
|
||||
</not></condition>
|
||||
</fail>
|
||||
|
||||
<get src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.min.js" dest="build/website/js/modernizr.min.js" />
|
||||
<get src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.min.js" dest="build/website/js/modernizr.min.js" usetimestamp="true" />
|
||||
<fail message="modernizr checksum failed">
|
||||
<condition><not>
|
||||
<checksum file="build/website/js/modernizr.min.js" algorithm="SHA-384" property="6cf577980d9ea3779da2ae7a57370f0661b537541551f8d833154824f3f3c85272159f0615f37b369b74e99af6deab6c" verifyproperty="modernizr.ok" />
|
||||
</not></condition>
|
||||
</fail>
|
||||
|
||||
<get src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/js/bootstrap.min.js" dest="build/website/js/bootstrap.min.js" />
|
||||
<get src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/js/bootstrap.min.js" dest="build/website/js/bootstrap.min.js" usetimestamp="true" />
|
||||
<fail message="bootstrap checksum failed">
|
||||
<condition><not>
|
||||
<checksum file="build/website/js/bootstrap.min.js" algorithm="SHA-384" property="0a17eaab1b995029c948adfe31798f348c84e996d687620ca84db8d6b622a89c7232267a396fc9999439b2dc0450b4f2" verifyproperty="bootstrap.ok" />
|
||||
</not></condition>
|
||||
</fail>
|
||||
|
||||
<get src="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" dest="build/website/css/font-awesome.min.css" />
|
||||
|
||||
<mkdir dir="build/website/css" />
|
||||
<get src="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" dest="build/website/css/font-awesome.min.css" usetimestamp="true" />
|
||||
<fail message="font-awesome checksum failed">
|
||||
<condition><not>
|
||||
<checksum file="build/website/css/font-awesome.min.css" algorithm="SHA-384" property="c2f7d7a6aa596554062ba4c08793d594639f40d1d2a03db16c4f9090fc4200594d11ebe8107dd2974b226d570e4159cd" verifyproperty="fontawesome.ok" />
|
||||
@@ -144,49 +103,87 @@ such as applying the templates to produce the website, converting the changelog
|
||||
</fail>
|
||||
|
||||
<mkdir dir="build/website/fonts" />
|
||||
<get src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/fonts/fontawesome-webfont.woff" dest="build/website/fonts/fontawesome-webfont.woff" />
|
||||
<get src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/fonts/fontawesome-webfont.woff" dest="build/website/fonts/fontawesome-webfont.woff" usetimestamp="true" />
|
||||
<fail message="woff checksum failed">
|
||||
<condition><not>
|
||||
<checksum file="build/website/fonts/fontawesome-webfont.woff" algorithm="SHA-384" property="9a2008ccbb9e142d9ad62db6439db4a0543073f376c2d6987bddd0cab298963e5fd13d3e0e4404a4cb3b4be32f9135bf" verifyproperty="woff.ok" />
|
||||
</not></condition>
|
||||
</fail>
|
||||
|
||||
<get src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/fonts/fontawesome-webfont.woff2" dest="build/website/fonts/fontawesome-webfont.woff2" />
|
||||
<get src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/fonts/fontawesome-webfont.woff2" dest="build/website/fonts/fontawesome-webfont.woff2" usetimestamp="true" />
|
||||
<fail message="woff2 checksum failed">
|
||||
<condition><not>
|
||||
<checksum file="build/website/fonts/fontawesome-webfont.woff2" algorithm="SHA-384" property="c267dab02b05137a7d06041209c8a227447a1af392b0a29924c5c1bd3882b966b7ca96b9c971958d2773b94fce37a3fa" verifyproperty="woff2.ok" />
|
||||
</not></condition>
|
||||
</fail>
|
||||
|
||||
<java classname="lombok.website.WebsiteMaker" failonerror="true">
|
||||
</target>
|
||||
|
||||
<macrodef name="website.make">
|
||||
<attribute name="version" />
|
||||
<attribute name="fullversion" />
|
||||
<attribute name="cmd" />
|
||||
<sequential>
|
||||
<mkdir dir="build/website" />
|
||||
<copy todir="build/website">
|
||||
<fileset dir="website/resources" />
|
||||
<fileset dir="." includes="LICENSE" />
|
||||
</copy>
|
||||
|
||||
<java classname="lombok.website.WebsiteMaker" failonerror="true">
|
||||
<classpath>
|
||||
<path refid="cp.buildtools" />
|
||||
<pathelement location="build/support" />
|
||||
</classpath>
|
||||
<arg value="${web.root}" />
|
||||
<arg value="@{version}" />
|
||||
<arg value="@{fullversion}" />
|
||||
<arg value="@{cmd}" />
|
||||
</java>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
<target name="website.release-build" depends="version, -website.clean, compile.support, -website.clientdeps">
|
||||
<website.make version="${lombok.version}" fullversion="${lombok.fullversion}" cmd="all-newrelease" />
|
||||
</target>
|
||||
|
||||
<target name="website.build" depends="-website.fetch-version, -website.clean, compile.support, -website.clientdeps" description="Builds the website based on current live version">
|
||||
<website.make version="${lombok.version.live}" fullversion="${lombok.fullversion.live}" cmd="all" />
|
||||
</target>
|
||||
|
||||
<target name="website.open" depends="website.build, compile.support" description="Builds the website, then serves it locally, opening a browser.">
|
||||
<local name="dir.build.website" />
|
||||
<property name="dir.build.website" location="build/website" />
|
||||
<java classname="lombok.website.RunSite" failonerror="true">
|
||||
<classpath>
|
||||
<path refid="build.path" />
|
||||
<pathelement location="build/webclasses" />
|
||||
<path refid="cp.buildtools" />
|
||||
<pathelement location="build/support" />
|
||||
</classpath>
|
||||
<arg value="${lombok.version}" />
|
||||
<arg value="${lombok.fullversion}" />
|
||||
<arg value="all" />
|
||||
<arg value="${dir.build.website}" />
|
||||
<arg value="open" />
|
||||
</java>
|
||||
</target>
|
||||
|
||||
<target name="-website-dist">
|
||||
<target name="website.print-all-versions" depends="compile.support">
|
||||
<java classname="lombok.website.WebsiteMaker" failonerror="true">
|
||||
<classpath>
|
||||
<path refid="cp.buildtools" />
|
||||
<pathelement location="build/support" />
|
||||
</classpath>
|
||||
<arg value="${web.root}" />
|
||||
<arg value="1" />
|
||||
<arg value="1" />
|
||||
<arg value="print-allversions" />
|
||||
</java>
|
||||
</target>
|
||||
|
||||
<target name="website.pack" depends="website.build">
|
||||
<mkdir dir="dist" />
|
||||
<tar destfile="dist/website.tar.bz2" compression="bzip2">
|
||||
<tarfileset dir="build/website" />
|
||||
<tarfileset dir="doc/api" prefix="api" />
|
||||
<tarfileset dir="build/website" excludes="download-edge.html" />
|
||||
</tar>
|
||||
</target>
|
||||
|
||||
<target name="-website-only-dist">
|
||||
<mkdir dir="dist" />
|
||||
<tar destfile="dist/website.tar.bz2" compression="bzip2">
|
||||
<tarfileset dir="build/website" />
|
||||
</tar>
|
||||
</target>
|
||||
|
||||
<target name="website-publish" depends="website, website-supporters, -website-dist, -send-site-to-remote" />
|
||||
<target name="website-only-publish" depends="website-only, website-supporters, -website-only-dist, -send-site-to-remote" />
|
||||
<target name="-send-site-to-remote" depends="-requires-ssh">
|
||||
<target name="website.publish" depends="setup.ssh, website.pack" description="Builds the website, compresses it, sends it to the projectlombok.org server and deploys it">
|
||||
<ivy:scpUpload
|
||||
from="dist/website.tar.bz2"
|
||||
to="/data/lombok/staging"
|
||||
@@ -202,97 +199,7 @@ such as applying the templates to produce the website, converting the changelog
|
||||
knownHosts="ssh.knownHosts" />
|
||||
</target>
|
||||
|
||||
<target name="latestChanges" depends="-compile-webclasses, -ensure-version, -ensure-fullversion">
|
||||
<mkdir dir="build/website" />
|
||||
<java classname="lombok.website.WebsiteMaker" failonerror="true">
|
||||
<classpath>
|
||||
<path refid="build.path" />
|
||||
<pathelement location="build/webclasses" />
|
||||
</classpath>
|
||||
<arg value="${lombok.version}" />
|
||||
<arg value="${lombok.fullversion}" />
|
||||
<arg value="changelog-latest" />
|
||||
<arg value="website" />
|
||||
<arg value="build/latestchanges.html" />
|
||||
</java>
|
||||
</target>
|
||||
|
||||
<target name="edgeRelease-build" depends="-compile-webclasses, -ensure-version, -ensure-fullversion">
|
||||
<mkdir dir="build/website-edge" />
|
||||
<java classname="lombok.website.WebsiteMaker" failonerror="true">
|
||||
<classpath>
|
||||
<path refid="build.path" />
|
||||
<pathelement location="build/webclasses" />
|
||||
</classpath>
|
||||
<arg value="${lombok.version}" />
|
||||
<arg value="${lombok.fullversion}" />
|
||||
<arg value="download-edge" />
|
||||
<arg value="website" />
|
||||
<arg value="build/website-edge/download-edge.html" />
|
||||
</java>
|
||||
<copy file="dist/lombok.jar" tofile="build/website-edge/lombok-edge.jar" />
|
||||
<tar destfile="dist/website-edge.tar.bz2" compression="bzip2">
|
||||
<tarfileset dir="build/website-edge" />
|
||||
<tarfileset dir="build">
|
||||
<include name="edge-releases/**" />
|
||||
</tarfileset>
|
||||
</tar>
|
||||
</target>
|
||||
|
||||
<target name="-requires-ssh" unless="ssh.username">
|
||||
<fail>ssh.username and ssh.keyfile should be set.</fail>
|
||||
</target>
|
||||
|
||||
<target name="deploy-p2" depends="-requires-ssh">
|
||||
<ivy:scpUpload
|
||||
from="dist/eclipse-p2.tar.bz2"
|
||||
to="/data/lombok/staging"
|
||||
server="projectlombok.org"
|
||||
username="${ssh.username}"
|
||||
keyfile="${ssh.keyfile}"
|
||||
knownHosts="ssh.knownHosts" />
|
||||
<ivy:sshExec
|
||||
cmd="/data/lombok/stagingCmd/deployP2"
|
||||
server="projectlombok.org"
|
||||
username="${ssh.username}"
|
||||
keyfile="${ssh.keyfile}"
|
||||
knownHosts="ssh.knownHosts" />
|
||||
</target>
|
||||
|
||||
<target name="edgeRelease" depends="-requires-ssh, edgeRelease-build">
|
||||
<ivy:scpUpload
|
||||
from="dist/website-edge.tar.bz2"
|
||||
to="/data/lombok/staging"
|
||||
server="projectlombok.org"
|
||||
username="${ssh.username}"
|
||||
keyfile="${ssh.keyfile}"
|
||||
knownHosts="ssh.knownHosts" />
|
||||
<ivy:sshExec
|
||||
cmd="/data/lombok/stagingCmd/deployEdge"
|
||||
server="projectlombok.org"
|
||||
username="${ssh.username}"
|
||||
keyfile="${ssh.keyfile}"
|
||||
knownHosts="ssh.knownHosts" />
|
||||
<exec executable="/usr/bin/git" failonerror="true">
|
||||
<arg value="merge-base" />
|
||||
<arg value="--is-ancestor" />
|
||||
<arg value="edge" />
|
||||
<arg value="master" />
|
||||
</exec>
|
||||
<exec executable="/usr/bin/git">
|
||||
<arg value="branch" />
|
||||
<arg value="-f" />
|
||||
<arg value="edge" />
|
||||
<arg value="master" />
|
||||
</exec>
|
||||
<exec executable="/usr/bin/git">
|
||||
<arg value="push" />
|
||||
<arg value="origin" />
|
||||
<arg value="edge:refs/heads/edge" />
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="javadoc" description="Generates the javadoc" depends="-ensure-version, -ensure-fullversion" unless="skip.javadoc">
|
||||
<target name="javadoc.build" description="Generates the javadoc" depends="version, compile" unless="skip.javadoc">
|
||||
<delete dir="build/api" quiet="true" />
|
||||
<delete dir="doc/api" quiet="true" />
|
||||
<mkdir dir="build/api" />
|
||||
@@ -304,13 +211,12 @@ such as applying the templates to produce the website, converting the changelog
|
||||
write your own plugins, the other packages are what you're looking for.</body></html>
|
||||
]]></echo>
|
||||
<tstamp>
|
||||
<format property="javadoc.year" pattern="yyyy"/>
|
||||
<format property="javadoc.year" pattern="yyyy" />
|
||||
</tstamp>
|
||||
<javadoc sourcepath="src/core" defaultexcludes="yes" destdir="build/api" windowtitle="Lombok" source="1.8" Overview="${javadoc.overview.html}">
|
||||
<package name="lombok" />
|
||||
<package name="lombok.experimental" />
|
||||
<package name="lombok.extern.*" />
|
||||
<classpath refid="build.path" />
|
||||
<classpath location="build/lombok" />
|
||||
<header><![CDATA[<a href='https://projectlombok.org/' target='_blank'>Lombok</a> - ]]>v${lombok.version}</header>
|
||||
<bottom><![CDATA[<i>Copyright © 2009-${javadoc.year} The Project Lombok Authors, licensed under the <a href='http://www.opensource.org/licenses/mit-license.php' target='_blank'>MIT licence</a>.]]></bottom>
|
||||
@@ -346,4 +252,129 @@ such as applying the templates to produce the website, converting the changelog
|
||||
<echo append="true" file="doc/api/module-search-index.js"></echo>
|
||||
<echo append="true" file="doc/api/tag-search-index.js"></echo>
|
||||
</target>
|
||||
|
||||
<target name="javadoc.pack" depends="javadoc.build">
|
||||
<mkdir dir="dist" />
|
||||
<tar destfile="dist/javadoc.tar.bz2" compression="bzip2">
|
||||
<tarfileset dir="build/api" />
|
||||
</tar>
|
||||
<echo>File dist/javadoc.tar.bz2 is available</echo>
|
||||
</target>
|
||||
|
||||
<target name="javadoc.publish" depends="setup.ssh, javadoc.pack">
|
||||
<ivy:scpUpload
|
||||
from="dist/javadoc.tar.bz2"
|
||||
to="/data/lombok/staging"
|
||||
server="projectlombok.org"
|
||||
username="${ssh.username}"
|
||||
keyfile="${ssh.keyfile}"
|
||||
knownHosts="ssh.knownHosts" />
|
||||
<ivy:sshExec
|
||||
cmd="/data/lombok/stagingCmd/deployJavadoc"
|
||||
server="projectlombok.org"
|
||||
username="${ssh.username}"
|
||||
keyfile="${ssh.keyfile}"
|
||||
knownHosts="ssh.knownHosts" />
|
||||
</target>
|
||||
|
||||
<target name="latest-changes.build" depends="compile.support, version" description="Creates the latest changes HTML file from the markdown in doc/changelog">
|
||||
<mkdir dir="build/website" />
|
||||
<java classname="lombok.website.WebsiteMaker" failonerror="true">
|
||||
<classpath>
|
||||
<path refid="cp.buildtools" />
|
||||
<pathelement location="build/support" />
|
||||
</classpath>
|
||||
<arg value="${web.root}" />
|
||||
<arg value="${lombok.version}" />
|
||||
<arg value="${lombok.fullversion}" />
|
||||
<arg value="changelog-latest" />
|
||||
<arg value="website" />
|
||||
<arg value="build/latestchanges.html" />
|
||||
</java>
|
||||
</target>
|
||||
|
||||
<target name="release.pack" depends="dist, website.release-build">
|
||||
<tar destfile="dist/website-release.tar.bz2" compression="bzip2">
|
||||
<tarfileset dir="dist" includes="lombok-${lombok.version}.jar" prefix="downloads/" />
|
||||
<tarfileset dir="dist" includes="lombok-${lombok.version}.jar" fullpath="downloads/lombok.jar" />
|
||||
<tarfileset dir="dist" includes="lombok-${lombok.version}.jar" fullpath="lombok-edge.jar" />
|
||||
<tarfileset dir="build/website" includes="all-versions.html,download.html,download-edge.html" />
|
||||
</tar>
|
||||
</target>
|
||||
|
||||
<target name="-release.publish.site" depends="setup.ssh, release.pack">
|
||||
<ivy:scpUpload
|
||||
from="dist/website-release.tar.bz2"
|
||||
to="/data/lombok/staging"
|
||||
server="projectlombok.org"
|
||||
username="${ssh.username}"
|
||||
keyfile="${ssh.keyfile}"
|
||||
knownHosts="ssh.knownHosts" />
|
||||
<ivy:sshExec
|
||||
cmd="/data/lombok/stagingCmd/deployRelease"
|
||||
server="projectlombok.org"
|
||||
username="${ssh.username}"
|
||||
keyfile="${ssh.keyfile}"
|
||||
knownHosts="ssh.knownHosts" />
|
||||
</target>
|
||||
|
||||
<target name="release.publish" depends="maven, -release.publish.site, website.publish, eclipsep2.publish, maven.publish" />
|
||||
|
||||
<target name="edge.pack" depends="compile.support, version, dist, maven.edge">
|
||||
<delete file="build/website/download-edge.html" />
|
||||
<mkdir dir="build/website-edge" />
|
||||
<java classname="lombok.website.WebsiteMaker" failonerror="true">
|
||||
<classpath>
|
||||
<path refid="cp.buildtools" />
|
||||
<pathelement location="build/support" />
|
||||
</classpath>
|
||||
<arg value="${web.root}" />
|
||||
<arg value="${lombok.version}" />
|
||||
<arg value="${lombok.fullversion}" />
|
||||
<arg value="download-edge" />
|
||||
<arg value="website" />
|
||||
<arg value="build/website-edge/download-edge.html" />
|
||||
</java>
|
||||
<copy file="dist/lombok.jar" tofile="build/website-edge/lombok-edge.jar" />
|
||||
<tar destfile="dist/website-edge.tar.bz2" compression="bzip2">
|
||||
<tarfileset dir="build/website-edge" />
|
||||
<tarfileset dir="build">
|
||||
<include name="edge-releases/**" />
|
||||
</tarfileset>
|
||||
</tar>
|
||||
</target>
|
||||
|
||||
<target name="edge.publish" depends="setup.ssh, edge.pack" description="Builds an edge release, sends it to the projectlombok.org server and deploys it by updating the download-edge link">
|
||||
<ivy:scpUpload
|
||||
from="dist/website-edge.tar.bz2"
|
||||
to="/data/lombok/staging"
|
||||
server="projectlombok.org"
|
||||
username="${ssh.username}"
|
||||
keyfile="${ssh.keyfile}"
|
||||
knownHosts="ssh.knownHosts" />
|
||||
<ivy:sshExec
|
||||
cmd="/data/lombok/stagingCmd/deployEdge"
|
||||
server="projectlombok.org"
|
||||
username="${ssh.username}"
|
||||
keyfile="${ssh.keyfile}"
|
||||
knownHosts="ssh.knownHosts" />
|
||||
|
||||
<exec executable="/usr/bin/git" failonerror="true">
|
||||
<arg value="merge-base" />
|
||||
<arg value="--is-ancestor" />
|
||||
<arg value="edge" />
|
||||
<arg value="master" />
|
||||
</exec>
|
||||
<exec executable="/usr/bin/git">
|
||||
<arg value="branch" />
|
||||
<arg value="-f" />
|
||||
<arg value="edge" />
|
||||
<arg value="master" />
|
||||
</exec>
|
||||
<exec executable="/usr/bin/git">
|
||||
<arg value="push" />
|
||||
<arg value="origin" />
|
||||
<arg value="edge:refs/heads/edge" />
|
||||
</exec>
|
||||
</target>
|
||||
</project>
|
||||
@@ -2,15 +2,22 @@ Lombok Changelog
|
||||
----------------
|
||||
|
||||
### v1.18.13 "Edgy Guinea Pig"
|
||||
* PERFORMANCE: Several performance improvements during parsing/compilation, both using javac and Eclipse. Thanks __@Rawi01__!
|
||||
* PERFORMANCE: The generated equals method will first compare primitives, then primitive wrappers and then reference fields. Manual re-ordering is possible using `@Include(rank=n)`. [Pull Request #2485](https://github.com/rzwitserloot/lombok/pull/2485), [Issue #1543](https://github.com/rzwitserloot/lombok/issues/1543)
|
||||
* IMPROBABLE BREAKING CHANGE: The generated hashcode has changed for classes that include both primitive fields and reference fields.
|
||||
* PLATFORM: Added support for compiling projects with OpenJ9 [Pull Request #2437](https://github.com/rzwitserloot/lombok/pull/2437)
|
||||
* BREAKING CHANGE: mapstruct users should now add a dependency to lombok-mapstruct-binding. This solves compiling modules with lombok (and mapstruct).
|
||||
* FEATURE: Similar to `@Builder`, you can now configure a `@SuperBuilder`'s 'setter' prefixes via `@SuperBuilder(setterPrefix = "set")` for example. We still discourage doing this. [Pull Request #2357](https://github.com/rzwitserloot/lombok/pull/2357).
|
||||
* FEATURE: If using `@Synchronized("lockVar")`, if `lockVar` is referring to a static field, the code lombok generates no longer causes a warning about accessing a static entity incorrectly. [Issue #678](https://github.com/rzwitserloot/lombok/issues/678)
|
||||
* BUGFIX: Delombok print the first `this` parameter. [Issue #2444](https://github.com/rzwitserloot/lombok/issues/2444)
|
||||
* BUGFIX: Using `val` in combination with values whose generics include wildcards that reference themselves would cause a `StackOverflowError` in javac. [Issue #2358](https://github.com/rzwitserloot/lombok/issues/2358).
|
||||
* BUGFIX: Using `@SuperBuilder` on a class that has some fairly convoluted generics usage would fail with 'Wrong number of type arguments'. [Issue #2359](https://github.com/rzwitserloot/lombok/issues/2359) [Pull Request #2362](https://github.com/rzwitserloot/lombok/pull/2362)
|
||||
* BUGFIX: Various lombok annotations on classes nested inside enums or interfaces would cause errors in eclipse. [Issue #2369](https://github.com/rzwitserloot/lombok/issues/2369)
|
||||
* BUGFIX: Trying to add `@ExtensionMethod`s with exactly 2 arguments would fail in eclipse. [Issue #1441](https://github.com/rzwitserloot/lombok/issues/1441) [Pull Request #2376](https://github.com/rzwitserloot/lombok/pull/2376) thanks to __@Rawi01__.
|
||||
* BUGFIX: Javac sets incorrect annotated type on with methods. [Issue #2463](https://github.com/rzwitserloot/lombok/issues/2463)
|
||||
* FEATURE: `@Jacksonized` on a `@Builder` or `@SuperBuilder` will configure [Jackson](https://github.com/FasterXML/jackson) to use this builder when deserializing. [Pull Request #2387](https://github.com/rzwitserloot/lombok/pull/2387) thanks to __@JanRieke__. [@Jacksonized documentation](https://projectlombok.org/features/experimental/Jacksonized).
|
||||
|
||||
|
||||
### v1.18.12 (February 1st, 2020)
|
||||
* PLATFORM: Support for JDK13 (including `yield` in switch expressions, as well as delombok having a nicer style for arrow-style switch blocks, and text blocks).
|
||||
* PLATFORM: Support for JDK14 (including `pattern match` instanceof expressions).
|
||||
|
||||
@@ -32,8 +32,8 @@ import java.lang.annotation.Target;
|
||||
* that contains a member which is annotated with {@code @Builder}.
|
||||
* <p>
|
||||
* If a member is annotated, it must be either a constructor or a method. If a class is annotated,
|
||||
* then a private constructor is generated with all fields as arguments
|
||||
* (as if {@code @AllArgsConstructor(access = AccessLevel.PRIVATE)} is present
|
||||
* then a package-private constructor is generated with all fields as arguments
|
||||
* (as if {@code @AllArgsConstructor(access = AccessLevel.PACKAGE)} is present
|
||||
* on the class), and it is as if this constructor has been annotated with {@code @Builder} instead.
|
||||
* Note that this constructor is only generated if you haven't written any constructors and also haven't
|
||||
* added any explicit {@code @XArgsConstructor} annotations. In those cases, lombok will assume an all-args
|
||||
|
||||
@@ -89,6 +89,13 @@ public class ConfigurationKeys {
|
||||
*/
|
||||
public static final ConfigurationKey<Boolean> ADD_FINDBUGS_SUPPRESSWARNINGS_ANNOTATIONS = new ConfigurationKey<Boolean>("lombok.extern.findbugs.addSuppressFBWarnings", "Generate @edu.umd.cs.findbugs.annotations.SuppressFBWarnings on all generated code (default: false).") {};
|
||||
|
||||
/**
|
||||
* lombok configuration: {@code lombok.addSuppressWarnings} = {@code true} | {@code false}.
|
||||
*
|
||||
* If {@code true}, lombok generates {@code @java.lang.SuppressWarnings("all")} on all fields, methods, and types that are generated.
|
||||
*/
|
||||
public static final ConfigurationKey<Boolean> ADD_SUPPRESSWARNINGS_ANNOTATIONS = new ConfigurationKey<Boolean>("lombok.addSuppressWarnings", "Generate @java.lang.SuppressWarnings(\"all\") on all generated code (default: true).") {};
|
||||
|
||||
/**
|
||||
* lombok configuration: {@code lombok.addNullAnnotations = }one of: [{@code none}, {@code javax}, {@code eclipse}, {@code jetbrains}, {@code netbeans}, {@code androidx}, {@code android.support}, {@code checkerframework}, {@code findbugs}, {@code spring}, {@code JML}, or a custom set of fully qualified annotation types].
|
||||
*
|
||||
@@ -133,7 +140,7 @@ public class ConfigurationKeys {
|
||||
* NB: GWT projects, and probably android projects, should explicitly set this key to {@code true} for the entire project.
|
||||
*
|
||||
* <br>
|
||||
* <em>BREAKING CHANGE</em>: Starting with lombok v1.16.20, defaults to {@code false} instead of {@code true}, as {@code @ConstructorProperties} requires extra modules in JDK9.
|
||||
* <em>BREAKING CHANGE</em>: Starting with lombok v1.16.20, defaults to {@code true} instead of {@code false}, as {@code @ConstructorProperties} requires extra modules in JDK9.
|
||||
*
|
||||
* @see ConfigurationKeys#ANY_CONSTRUCTOR_ADD_CONSTRUCTOR_PROPERTIES
|
||||
* @deprecated Since version 2.0, use {@link #ANY_CONSTRUCTOR_ADD_CONSTRUCTOR_PROPERTIES} instead.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2018 The Project Lombok Authors.
|
||||
* Copyright (C) 2009-2020 The Project Lombok Authors.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -122,5 +122,14 @@ public @interface EqualsAndHashCode {
|
||||
* @return If present, this method serves as replacement for the named field.
|
||||
*/
|
||||
String replaces() default "";
|
||||
|
||||
/**
|
||||
* Higher ranks are considered first. Members of the same rank are considered in the order they appear in the source file.
|
||||
*
|
||||
* If not explicitly set, the {@code default} rank for primitives is 1000, and for primitive wrappers 800.
|
||||
*
|
||||
* @return ordering within the generating {@code equals} and {@code hashCode} methods; higher numbers are considered first.
|
||||
*/
|
||||
int rank() default 0;
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,6 @@ public @interface Singular {
|
||||
/** @return The singular name of this field. If it's a normal english plural, lombok will figure it out automatically. Otherwise, this parameter is mandatory. */
|
||||
String value() default "";
|
||||
|
||||
/** @return If true, the plural variant (which takes a collection and adds each element inside) will treat {@code null} as an empty collection, i.e. do nothing. If {@code false) (the default), it is null checked as if annotated with {@code @lombok.NonNull}. */
|
||||
/** @return If true, the plural variant (which takes a collection and adds each element inside) will treat {@code null} as an empty collection, i.e. do nothing. If {@code false} (the default), it is null checked as if annotated with {@code @lombok.NonNull}. */
|
||||
boolean ignoreNullCollections() default false;
|
||||
}
|
||||
@@ -26,8 +26,6 @@ import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
|
||||
/**
|
||||
* Put on any field to make lombok build a 'with' - a withX method which produces a clone of this object (except for 1 field which gets a new value).
|
||||
* <p>
|
||||
|
||||
@@ -83,7 +83,12 @@ public class AnnotationProcessor extends AbstractProcessor {
|
||||
|
||||
for (Class<?> procEnvClass = procEnv.getClass(); procEnvClass != null; procEnvClass = procEnvClass.getSuperclass()) {
|
||||
try {
|
||||
Field field = Permit.getField(procEnvClass, "delegate");
|
||||
Field field;
|
||||
try {
|
||||
field = Permit.getField(procEnvClass, "delegate");
|
||||
} catch (NoSuchFieldException e) {
|
||||
field = Permit.getField(procEnvClass, "processingEnv");
|
||||
}
|
||||
Object delegate = field.get(procEnv);
|
||||
|
||||
return tryRecursivelyObtainJavacProcessingEnvironment((ProcessingEnvironment) delegate);
|
||||
|
||||
@@ -411,6 +411,14 @@ public class AnnotationValues<A extends Annotation> {
|
||||
List<Object> l = getActualExpressions(annotationMethodName);
|
||||
return l.isEmpty() ? null : l.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the guessed value for the provided {@code annotationMethodName}.
|
||||
*/
|
||||
public Object getValueGuess(String annotationMethodName) {
|
||||
AnnotationValue v = values.get(annotationMethodName);
|
||||
return v == null || v.valueGuesses.isEmpty() ? null : v.valueGuesses.get(0);
|
||||
}
|
||||
|
||||
/** Generates an error message on the stated annotation value (you should only call this method if you know it's there!) */
|
||||
public void setError(String annotationMethodName, String message) {
|
||||
|
||||
@@ -288,9 +288,23 @@ public abstract class LombokNode<A extends AST<A, L, N>, L extends LombokNode<A,
|
||||
public abstract boolean isStatic();
|
||||
public abstract boolean isFinal();
|
||||
public abstract boolean isTransient();
|
||||
public abstract boolean isPrimitive();
|
||||
public abstract boolean isEnumMember();
|
||||
public abstract boolean isEnumType();
|
||||
|
||||
/**
|
||||
* The 'type' of the field or method, or {@code null} if this node is neither.
|
||||
*
|
||||
* The type is as it is written in the code (no resolution), includes array dimensions,
|
||||
* but not necessarily generics.
|
||||
*
|
||||
* The main purpose of this method is to verify this type against a list of known types,
|
||||
* like primitives or primitive wrappers.
|
||||
*
|
||||
* @return The 'type' of the field or method, or {@code null} if this node is neither.
|
||||
*/
|
||||
public abstract String fieldOrMethodBaseType();
|
||||
|
||||
public abstract int countMethodParameters();
|
||||
|
||||
public abstract int getStartPos();
|
||||
|
||||
@@ -72,10 +72,12 @@ public final class PostCompiler {
|
||||
// no need to call super
|
||||
byte[] original = toByteArray();
|
||||
byte[] copy = null;
|
||||
try {
|
||||
copy = applyTransformations(original, fileName, diagnostics);
|
||||
} catch (Exception e) {
|
||||
diagnostics.addWarning(String.format("Error during the transformation of '%s'; no post-compilation has been applied", fileName));
|
||||
if (original.length > 0) {
|
||||
try {
|
||||
copy = applyTransformations(original, fileName, diagnostics);
|
||||
} catch (Exception e) {
|
||||
diagnostics.addWarning(String.format("Error during the transformation of '%s'; no post-compilation has been applied", fileName));
|
||||
}
|
||||
}
|
||||
|
||||
if (copy == null) {
|
||||
|
||||
@@ -27,6 +27,7 @@ import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.ConfigurationKeys;
|
||||
@@ -76,7 +77,7 @@ public class HandlerUtil {
|
||||
return 43;
|
||||
}
|
||||
|
||||
public static final List<String> NONNULL_ANNOTATIONS, BASE_COPYABLE_ANNOTATIONS, COPY_TO_SETTER_ANNOTATIONS, JACKSON_COPY_TO_BUILDER_ANNOTATIONS;
|
||||
public static final List<String> NONNULL_ANNOTATIONS, BASE_COPYABLE_ANNOTATIONS, COPY_TO_SETTER_ANNOTATIONS, COPY_TO_BUILDER_SINGULAR_SETTER_ANNOTATIONS, JACKSON_COPY_TO_BUILDER_ANNOTATIONS;
|
||||
static {
|
||||
NONNULL_ANNOTATIONS = Collections.unmodifiableList(Arrays.asList(new String[] {
|
||||
"androidx.annotation.NonNull",
|
||||
@@ -312,10 +313,24 @@ public class HandlerUtil {
|
||||
"org.netbeans.api.annotations.common.NullAllowed",
|
||||
}));
|
||||
COPY_TO_SETTER_ANNOTATIONS = Collections.unmodifiableList(Arrays.asList(new String[] {
|
||||
"com.fasterxml.jackson.annotation.JacksonInject",
|
||||
"com.fasterxml.jackson.annotation.JsonAlias",
|
||||
"com.fasterxml.jackson.annotation.JsonFormat",
|
||||
"com.fasterxml.jackson.annotation.JsonIgnore",
|
||||
"com.fasterxml.jackson.annotation.JsonIgnoreProperties",
|
||||
"com.fasterxml.jackson.annotation.JsonProperty",
|
||||
"com.fasterxml.jackson.annotation.JsonSetter",
|
||||
"com.fasterxml.jackson.annotation.JsonSubTypes",
|
||||
"com.fasterxml.jackson.annotation.JsonTypeInfo",
|
||||
"com.fasterxml.jackson.annotation.JsonView",
|
||||
"com.fasterxml.jackson.databind.annotation.JsonDeserialize",
|
||||
"com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty",
|
||||
}));
|
||||
COPY_TO_BUILDER_SINGULAR_SETTER_ANNOTATIONS = Collections.unmodifiableList(Arrays.asList(new String[] {
|
||||
"com.fasterxml.jackson.annotation.JsonAnySetter",
|
||||
}));
|
||||
JACKSON_COPY_TO_BUILDER_ANNOTATIONS = Collections.unmodifiableList(Arrays.asList(new String[] {
|
||||
"com.fasterxml.jackson.annotation.JsonAutoDetect",
|
||||
"com.fasterxml.jackson.annotation.JsonFormat",
|
||||
"com.fasterxml.jackson.annotation.JsonIgnoreProperties",
|
||||
"com.fasterxml.jackson.annotation.JsonIgnoreType",
|
||||
@@ -351,6 +366,7 @@ public class HandlerUtil {
|
||||
public static String autoSingularize(String plural) {
|
||||
return Singulars.autoSingularize(plural);
|
||||
}
|
||||
|
||||
public static void handleFlagUsage(LombokNode<?, ?, ?> node, ConfigurationKey<FlagUsageType> key, String featureName) {
|
||||
FlagUsageType fut = node.getAst().readConfiguration(key);
|
||||
|
||||
@@ -728,4 +744,16 @@ public class HandlerUtil {
|
||||
}
|
||||
return b.toString();
|
||||
}
|
||||
|
||||
/** Matches any of the 8 primitive wrapper names, such as {@code Boolean}. */
|
||||
private static final Pattern PRIMITIVE_WRAPPER_TYPE_NAME_PATTERN = Pattern.compile("^(?:java\\.lang\\.)?(?:Boolean|Byte|Short|Integer|Long|Float|Double|Character)$");
|
||||
|
||||
public static int defaultEqualsAndHashcodeIncludeRank(String typeName) {
|
||||
// Modification in this code should be documented
|
||||
// 1. In the changelog this should be marked as an INPROBABLE BREAKING CHANGE, since the hashcode will change
|
||||
// 2. In the javadoc of EqualsAndHashcode.Include#rank
|
||||
if (JavaIdentifiers.isPrimitive(typeName)) return 1000;
|
||||
if (PRIMITIVE_WRAPPER_TYPE_NAME_PATTERN.matcher(typeName).matches()) return 800;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2018 The Project Lombok Authors.
|
||||
* Copyright (C) 2009-2020 The Project Lombok Authors.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -76,11 +76,13 @@ public class InclusionExclusionUtils {
|
||||
private final L node;
|
||||
private final I inc;
|
||||
private final boolean defaultInclude;
|
||||
private final boolean explicitRank;
|
||||
|
||||
public Included(L node, I inc, boolean defaultInclude) {
|
||||
public Included(L node, I inc, boolean defaultInclude, boolean explicitRank) {
|
||||
this.node = node;
|
||||
this.inc = inc;
|
||||
this.defaultInclude = defaultInclude;
|
||||
this.explicitRank = explicitRank;
|
||||
}
|
||||
|
||||
public L getNode() {
|
||||
@@ -94,6 +96,10 @@ public class InclusionExclusionUtils {
|
||||
public boolean isDefaultInclude() {
|
||||
return defaultInclude;
|
||||
}
|
||||
|
||||
public boolean hasExplicitRank() {
|
||||
return explicitRank;
|
||||
}
|
||||
}
|
||||
|
||||
private static String innerAnnName(Class<? extends Annotation> type) {
|
||||
@@ -106,7 +112,7 @@ public class InclusionExclusionUtils {
|
||||
return name;
|
||||
}
|
||||
|
||||
public static <A extends AST<A, L, N>, L extends LombokNode<A, L, N>, N, I extends Annotation> List<Included<L, I>> handleIncludeExcludeMarking(Class<I> inclType, String replaceName, Class<? extends Annotation> exclType, LombokNode<A, L, N> typeNode, AnnotationValues<?> annotation, LombokNode<A, L, N> annotationNode, boolean includeTransient) {
|
||||
private static <A extends AST<A, L, N>, L extends LombokNode<A, L, N>, N, I extends Annotation> List<Included<L, I>> handleIncludeExcludeMarking(Class<I> inclType, String replaceName, Class<? extends Annotation> exclType, LombokNode<A, L, N> typeNode, AnnotationValues<?> annotation, LombokNode<A, L, N> annotationNode, boolean includeTransient) {
|
||||
List<String> oldExcludes = (annotation != null && annotation.isExplicit("exclude")) ? annotation.getAsStringList("exclude") : null;
|
||||
List<String> oldIncludes = (annotation != null && annotation.isExplicit("of")) ? annotation.getAsStringList("of") : null;
|
||||
|
||||
@@ -118,9 +124,6 @@ public class InclusionExclusionUtils {
|
||||
if (typeNode == null || typeNode.getKind() != Kind.TYPE) return null;
|
||||
|
||||
checkForBogusFieldNames(typeNode, annotation, oldExcludes, oldIncludes);
|
||||
String inclTypeName = innerAnnName(inclType);
|
||||
String exclTypeName = innerAnnName(exclType);
|
||||
|
||||
if (oldExcludes != null && oldIncludes != null) {
|
||||
oldExcludes = null;
|
||||
if (annotation != null) annotation.setWarning("exclude", "exclude and of are mutually exclusive; the 'exclude' parameter will be ignored.");
|
||||
@@ -134,7 +137,7 @@ public class InclusionExclusionUtils {
|
||||
if (markExclude || markInclude != null) memberAnnotationMode = true;
|
||||
|
||||
if (markInclude != null && markExclude) {
|
||||
child.addError("@" + exclTypeName + " and @" + inclTypeName + " are mutually exclusive; the @Include annotation will be ignored");
|
||||
child.addError("@" + innerAnnName(exclType) + " and @" + innerAnnName(inclType) + " are mutually exclusive; the @Include annotation will be ignored");
|
||||
markInclude = null;
|
||||
}
|
||||
|
||||
@@ -157,20 +160,20 @@ public class InclusionExclusionUtils {
|
||||
I inc = markInclude.getInstance();
|
||||
if (child.getKind() == Kind.METHOD) {
|
||||
if (child.countMethodParameters() > 0) {
|
||||
child.addError("Methods included with @" + inclTypeName + " must have no arguments; it will not be included");
|
||||
child.addError("Methods included with @" + innerAnnName(inclType) + " must have no arguments; it will not be included");
|
||||
continue;
|
||||
}
|
||||
String n = replaceName != null ? markInclude.getAsString(replaceName) : "";
|
||||
if (n.isEmpty()) n = name;
|
||||
namesToAutoExclude.add(n);
|
||||
}
|
||||
members.add(new Included<L, I>(child, inc, false));
|
||||
members.add(new Included<L, I>(child, inc, false, markInclude.isExplicit("rank")));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (onlyExplicitlyIncluded) continue;
|
||||
if (oldIncludes != null) {
|
||||
if (child.getKind() == Kind.FIELD && oldIncludes.contains(name)) members.add(new Included<L, I>(child, null, false));
|
||||
if (child.getKind() == Kind.FIELD && oldIncludes.contains(name)) members.add(new Included<L, I>(child, null, false, false));
|
||||
continue;
|
||||
}
|
||||
if (child.getKind() != Kind.FIELD) continue;
|
||||
@@ -178,7 +181,7 @@ public class InclusionExclusionUtils {
|
||||
if (child.isTransient() && !includeTransient) continue;
|
||||
if (name.startsWith("$")) continue;
|
||||
if (child.isEnumMember()) continue;
|
||||
members.add(new Included<L, I>(child, null, true));
|
||||
members.add(new Included<L, I>(child, null, true, false));
|
||||
}
|
||||
|
||||
/* delete default-included fields with the same name as an explicit inclusion */ {
|
||||
@@ -207,22 +210,37 @@ public class InclusionExclusionUtils {
|
||||
@Override public int compare(Included<L, ToString.Include> a, Included<L, ToString.Include> b) {
|
||||
int ra = a.getInc() == null ? 0 : a.getInc().rank();
|
||||
int rb = b.getInc() == null ? 0 : b.getInc().rank();
|
||||
if (ra < rb) return +1;
|
||||
if (ra > rb) return -1;
|
||||
|
||||
int pa = a.getNode().getStartPos();
|
||||
int pb = b.getNode().getStartPos();
|
||||
|
||||
if (pa < pb) return -1;
|
||||
if (pa > pb) return +1;
|
||||
|
||||
return 0;
|
||||
|
||||
return compareRankOrPosition(ra, rb, a.getNode(), b.getNode());
|
||||
}
|
||||
});
|
||||
return members;
|
||||
}
|
||||
|
||||
public static <A extends AST<A, L, N>, L extends LombokNode<A, L, N>, N> List<Included<L, EqualsAndHashCode.Include>> handleEqualsAndHashCodeMarking(LombokNode<A, L, N> typeNode, AnnotationValues<EqualsAndHashCode> annotation, LombokNode<A, L, N> annotationNode) {
|
||||
return handleIncludeExcludeMarking(EqualsAndHashCode.Include.class, "replaces", EqualsAndHashCode.Exclude.class, typeNode, annotation, annotationNode, false);
|
||||
List<Included<L, EqualsAndHashCode.Include>> members = handleIncludeExcludeMarking(EqualsAndHashCode.Include.class, "replaces", EqualsAndHashCode.Exclude.class, typeNode, annotation, annotationNode, false);
|
||||
|
||||
Collections.sort(members, new Comparator<Included<L, EqualsAndHashCode.Include>>() {
|
||||
@Override public int compare(Included<L, EqualsAndHashCode.Include> a, Included<L, EqualsAndHashCode.Include> b) {
|
||||
int ra = a.hasExplicitRank() ? a.getInc().rank() : HandlerUtil.defaultEqualsAndHashcodeIncludeRank(a.node.fieldOrMethodBaseType());
|
||||
int rb = b.hasExplicitRank() ? b.getInc().rank() : HandlerUtil.defaultEqualsAndHashcodeIncludeRank(b.node.fieldOrMethodBaseType());
|
||||
|
||||
return compareRankOrPosition(ra, rb, a.getNode(), b.getNode());
|
||||
}
|
||||
});
|
||||
return members;
|
||||
}
|
||||
|
||||
private static <A extends AST<A, L, N>, L extends LombokNode<A, L, N>, N> int compareRankOrPosition(int ra, int rb, LombokNode<A, L, N> nodeA, LombokNode<A, L, N> nodeB) {
|
||||
if (ra < rb) return +1;
|
||||
if (ra > rb) return -1;
|
||||
|
||||
int pa = nodeA.getStartPos();
|
||||
int pb = nodeB.getStartPos();
|
||||
|
||||
if (pa < pb) return -1;
|
||||
if (pa > pb) return +1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -318,6 +318,7 @@ public class EclipseAST extends AST<EclipseAST, EclipseNode, ASTNode> {
|
||||
Field f = EcjReflectionCheck.typeReferenceAnnotations;
|
||||
if (f == null) return null;
|
||||
annss = (Annotation[][]) f.get(tr);
|
||||
if (annss == null) return null;
|
||||
return annss[annss.length - 1];
|
||||
} catch (Throwable t) {
|
||||
return null;
|
||||
@@ -349,7 +350,7 @@ public class EclipseAST extends AST<EclipseAST, EclipseNode, ASTNode> {
|
||||
if (!changed) clearChanged();
|
||||
}
|
||||
|
||||
private static boolean isComplete(CompilationUnitDeclaration unit) {
|
||||
public static boolean isComplete(CompilationUnitDeclaration unit) {
|
||||
return (unit.bits & ASTNode.HasAllMethodBodies) != 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,10 +23,6 @@ package lombok.eclipse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.core.AnnotationValues;
|
||||
import lombok.core.AST.Kind;
|
||||
import lombok.eclipse.handlers.EclipseHandlerUtil;
|
||||
|
||||
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
|
||||
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
|
||||
import org.eclipse.jdt.internal.compiler.ast.Annotation;
|
||||
@@ -36,11 +32,16 @@ import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
|
||||
import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
|
||||
import org.eclipse.jdt.internal.compiler.ast.Initializer;
|
||||
import org.eclipse.jdt.internal.compiler.ast.LocalDeclaration;
|
||||
import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
|
||||
import org.eclipse.jdt.internal.compiler.ast.Statement;
|
||||
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
|
||||
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
|
||||
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
|
||||
|
||||
import lombok.core.AST.Kind;
|
||||
import lombok.core.AnnotationValues;
|
||||
import lombok.eclipse.handlers.EclipseHandlerUtil;
|
||||
|
||||
/**
|
||||
* Eclipse specific version of the LombokNode class.
|
||||
*/
|
||||
@@ -264,6 +265,39 @@ public class EclipseNode extends lombok.core.LombokNode<EclipseAST, EclipseNode,
|
||||
return (ClassFileConstants.AccFinal & f) != 0;
|
||||
}
|
||||
|
||||
@Override public boolean isPrimitive() {
|
||||
if (node instanceof FieldDeclaration && !isEnumMember()) {
|
||||
return Eclipse.isPrimitive(((FieldDeclaration) node).type);
|
||||
}
|
||||
if (node instanceof MethodDeclaration) {
|
||||
return Eclipse.isPrimitive(((MethodDeclaration) node).returnType);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override public String fieldOrMethodBaseType() {
|
||||
TypeReference typeReference = null;
|
||||
if (node instanceof FieldDeclaration && !isEnumMember()) {
|
||||
typeReference = ((FieldDeclaration) node).type;
|
||||
}
|
||||
if (node instanceof MethodDeclaration) {
|
||||
typeReference = ((MethodDeclaration) node).returnType;
|
||||
}
|
||||
if (typeReference == null) return null;
|
||||
|
||||
String fqn = Eclipse.toQualifiedName(typeReference.getTypeName());
|
||||
if (typeReference.dimensions() == 0) return fqn;
|
||||
StringBuilder result = new StringBuilder(fqn.length() + 2 * typeReference.dimensions());
|
||||
result.append(fqn);
|
||||
for (int i = 0; i < typeReference.dimensions(); i++) {
|
||||
result.append("[]");
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
@Override public boolean isTransient() {
|
||||
if (getKind() != Kind.FIELD) return false;
|
||||
Integer i = getModifiers();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2019 The Project Lombok Authors.
|
||||
* Copyright (C) 2009-2020 The Project Lombok Authors.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -24,6 +24,9 @@ package lombok.eclipse;
|
||||
import static lombok.eclipse.handlers.EclipseHandlerUtil.*;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import lombok.ConfigurationKeys;
|
||||
import lombok.core.LombokConfiguration;
|
||||
@@ -63,6 +66,7 @@ public class TransformEclipseAST {
|
||||
|
||||
public static boolean disableLombok = false;
|
||||
private static final HistogramTracker lombokTracker;
|
||||
private static Map<CompilationUnitDeclaration, State> transformationStates = Collections.synchronizedMap(new WeakHashMap<CompilationUnitDeclaration, State>());
|
||||
|
||||
static {
|
||||
String v = System.getProperty("lombok.histogram");
|
||||
@@ -129,6 +133,30 @@ public class TransformEclipseAST {
|
||||
return existing;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if lombok already handled the given AST. This method will return
|
||||
* <code>true</code> once for diet mode and once for full mode.
|
||||
*
|
||||
* The reason for this is that Eclipse invokes the transform method multiple
|
||||
* times during compilation and it is enough to transform it once and not
|
||||
* repeat the whole thing over and over again.
|
||||
*
|
||||
* @param ast The AST node belonging to the compilation unit (java speak for a single source file).
|
||||
* @return <code>true</code> if this AST was already handled by lombok.
|
||||
*/
|
||||
public static boolean alreadyTransformed(CompilationUnitDeclaration ast) {
|
||||
State state = transformationStates.get(ast);
|
||||
|
||||
if (state == State.FULL) return true;
|
||||
if (state == State.DIET) {
|
||||
if (!EclipseAST.isComplete(ast)) return true;
|
||||
transformationStates.put(ast, State.FULL);
|
||||
} else {
|
||||
transformationStates.put(ast, State.DIET);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called immediately after Eclipse finishes building a CompilationUnitDeclaration, which is
|
||||
* the top-level AST node when Eclipse parses a source file. The signature is 'magic' - you should not
|
||||
@@ -144,6 +172,7 @@ public class TransformEclipseAST {
|
||||
if (disableLombok) return;
|
||||
|
||||
if (Symbols.hasSymbol("lombok.disable")) return;
|
||||
if (alreadyTransformed(ast)) return;
|
||||
|
||||
// Do NOT abort if (ast.bits & ASTNode.HasAllMethodBodies) != 0 - that doesn't work.
|
||||
|
||||
@@ -243,4 +272,9 @@ public class TransformEclipseAST {
|
||||
nextPriority = Math.min(nextPriority, handlers.handleAnnotation(top, annotationNode, annotation, priority));
|
||||
}
|
||||
}
|
||||
|
||||
private static enum State {
|
||||
DIET,
|
||||
FULL
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,7 @@ import static lombok.eclipse.Eclipse.*;
|
||||
import static lombok.eclipse.EclipseAugments.*;
|
||||
import static lombok.eclipse.handlers.EclipseHandlerUtil.EclipseReflectiveMembers.*;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
@@ -48,6 +49,7 @@ import org.eclipse.jdt.internal.compiler.ast.ArrayInitializer;
|
||||
import org.eclipse.jdt.internal.compiler.ast.ArrayQualifiedTypeReference;
|
||||
import org.eclipse.jdt.internal.compiler.ast.ArrayTypeReference;
|
||||
import org.eclipse.jdt.internal.compiler.ast.AssertStatement;
|
||||
import org.eclipse.jdt.internal.compiler.ast.BinaryExpression;
|
||||
import org.eclipse.jdt.internal.compiler.ast.Block;
|
||||
import org.eclipse.jdt.internal.compiler.ast.CastExpression;
|
||||
import org.eclipse.jdt.internal.compiler.ast.CharLiteral;
|
||||
@@ -232,14 +234,7 @@ public class EclipseHandlerUtil {
|
||||
* @param typeRef A type reference to check.
|
||||
*/
|
||||
public static boolean typeMatches(Class<?> type, EclipseNode node, TypeReference typeRef) {
|
||||
if (typeRef == null || typeRef.getTypeName() == null || typeRef.getTypeName().length == 0) return false;
|
||||
String lastPartA = new String(typeRef.getTypeName()[typeRef.getTypeName().length -1]);
|
||||
String lastPartB = type.getSimpleName();
|
||||
if (!lastPartA.equals(lastPartB)) return false;
|
||||
String typeName = toQualifiedName(typeRef.getTypeName());
|
||||
|
||||
TypeResolver resolver = new TypeResolver(node.getImportList());
|
||||
return resolver.typeMatches(node, type.getName(), typeName);
|
||||
return typeMatches(type.getName(), node, typeRef);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -253,7 +248,7 @@ public class EclipseHandlerUtil {
|
||||
char[][] tn = typeRef == null ? null : typeRef.getTypeName();
|
||||
if (tn == null || tn.length == 0) return false;
|
||||
char[] lastPartA = tn[tn.length - 1];
|
||||
int lastIndex = type.lastIndexOf('.') + 1;
|
||||
int lastIndex = Math.max(type.lastIndexOf('.'), type.lastIndexOf('$')) + 1;
|
||||
if (lastPartA.length != type.length() - lastIndex) return false;
|
||||
for (int i = 0; i < lastPartA.length; i++) if (lastPartA[i] != type.charAt(i + lastIndex)) return false;
|
||||
String typeName = toQualifiedName(tn);
|
||||
@@ -335,14 +330,16 @@ public class EclipseHandlerUtil {
|
||||
public static final Field STRING_LITERAL__LINE_NUMBER;
|
||||
public static final Field ANNOTATION__MEMBER_VALUE_PAIR_NAME;
|
||||
public static final Field TYPE_REFERENCE__ANNOTATIONS;
|
||||
public static final Class<?> INTERSECTION_BINDING;
|
||||
public static final Field INTERSECTION_BINDING_TYPES;
|
||||
public static final Class<?> INTERSECTION_BINDING1, INTERSECTION_BINDING2;
|
||||
public static final Field INTERSECTION_BINDING_TYPES1, INTERSECTION_BINDING_TYPES2;
|
||||
static {
|
||||
STRING_LITERAL__LINE_NUMBER = getField(StringLiteral.class, "lineNumber");
|
||||
ANNOTATION__MEMBER_VALUE_PAIR_NAME = getField(Annotation.class, "memberValuePairName");
|
||||
TYPE_REFERENCE__ANNOTATIONS = getField(TypeReference.class, "annotations");
|
||||
INTERSECTION_BINDING = getClass("org.eclipse.jdt.internal.compiler.lookup.IntersectionTypeBinding18");
|
||||
INTERSECTION_BINDING_TYPES = INTERSECTION_BINDING == null ? null : getField(INTERSECTION_BINDING, "intersectingTypes");
|
||||
INTERSECTION_BINDING1 = getClass("org.eclipse.jdt.internal.compiler.lookup.IntersectionTypeBinding18");
|
||||
INTERSECTION_BINDING2 = getClass("org.eclipse.jdt.internal.compiler.lookup.IntersectionCastTypeBinding");
|
||||
INTERSECTION_BINDING_TYPES1 = INTERSECTION_BINDING1 == null ? null : getField(INTERSECTION_BINDING1, "intersectingTypes");
|
||||
INTERSECTION_BINDING_TYPES2 = INTERSECTION_BINDING2 == null ? null : getField(INTERSECTION_BINDING2, "intersectingTypes");
|
||||
}
|
||||
|
||||
public static int reflectInt(Field f, Object o) {
|
||||
@@ -386,7 +383,7 @@ public class EclipseHandlerUtil {
|
||||
}
|
||||
}
|
||||
|
||||
private static Expression copyAnnotationMemberValue(Expression in) {
|
||||
public static Expression copyAnnotationMemberValue(Expression in) {
|
||||
Expression out = copyAnnotationMemberValue0(in);
|
||||
out.constant = in.constant;
|
||||
return out;
|
||||
@@ -427,12 +424,11 @@ public class EclipseHandlerUtil {
|
||||
|
||||
if (in instanceof SingleNameReference) {
|
||||
SingleNameReference snr = (SingleNameReference) in;
|
||||
long p = (long) s << 32 | e;
|
||||
return new SingleNameReference(snr.token, p);
|
||||
return new SingleNameReference(snr.token, pos(in));
|
||||
}
|
||||
if (in instanceof QualifiedNameReference) {
|
||||
QualifiedNameReference qnr = (QualifiedNameReference) in;
|
||||
return new QualifiedNameReference(qnr.tokens, qnr.sourcePositions, s, e);
|
||||
return new QualifiedNameReference(qnr.tokens, poss(in, qnr.tokens.length), s, e);
|
||||
}
|
||||
|
||||
// class refs
|
||||
@@ -448,11 +444,22 @@ public class EclipseHandlerUtil {
|
||||
out.sourceEnd = e;
|
||||
out.bits = in.bits;
|
||||
out.implicitConversion = in.implicitConversion;
|
||||
out.statementEnd = in.statementEnd;
|
||||
out.statementEnd = e;
|
||||
out.expressions = copy;
|
||||
return out;
|
||||
}
|
||||
|
||||
if (in instanceof BinaryExpression) {
|
||||
BinaryExpression be = (BinaryExpression) in;
|
||||
BinaryExpression out = new BinaryExpression(be);
|
||||
out.left = copyAnnotationMemberValue(be.left);
|
||||
out.right = copyAnnotationMemberValue(be.right);
|
||||
out.sourceStart = s;
|
||||
out.sourceEnd = e;
|
||||
out.statementEnd = e;
|
||||
return out;
|
||||
}
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
@@ -660,9 +667,11 @@ public class EclipseHandlerUtil {
|
||||
|
||||
Annotation[][] b = new Annotation[a.length][];
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
b[i] = new Annotation[a[i].length];
|
||||
for (int j = 0 ; j < a[i].length; j++) {
|
||||
b[i][j] = copyAnnotation(a[i][j], a[i][j]);
|
||||
if (a[i] != null) {
|
||||
b[i] = new Annotation[a[i].length];
|
||||
for (int j = 0 ; j < a[i].length; j++) {
|
||||
b[i][j] = copyAnnotation(a[i][j], a[i][j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -817,6 +826,20 @@ public class EclipseHandlerUtil {
|
||||
* Searches the given field node for annotations that are specifically intentioned to be copied to the setter.
|
||||
*/
|
||||
public static Annotation[] findCopyableToSetterAnnotations(EclipseNode node) {
|
||||
return findAnnotationsInList(node, COPY_TO_SETTER_ANNOTATIONS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches the given field node for annotations that are specifically intentioned to be copied to the builder's singular method.
|
||||
*/
|
||||
public static Annotation[] findCopyableToBuilderSingularSetterAnnotations(EclipseNode node) {
|
||||
return findAnnotationsInList(node, COPY_TO_BUILDER_SINGULAR_SETTER_ANNOTATIONS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches the given field node for annotations that are in the given list, and returns those.
|
||||
*/
|
||||
private static Annotation[] findAnnotationsInList(EclipseNode node, java.util.List<String> annotationsToFind) {
|
||||
AbstractVariableDeclaration avd = (AbstractVariableDeclaration) node.get();
|
||||
if (avd.annotations == null) return EMPTY_ANNOTATIONS_ARRAY;
|
||||
List<Annotation> result = new ArrayList<Annotation>();
|
||||
@@ -824,7 +847,7 @@ public class EclipseHandlerUtil {
|
||||
for (Annotation annotation : avd.annotations) {
|
||||
TypeReference typeRef = annotation.type;
|
||||
if (typeRef != null && typeRef.getTypeName() != null) {
|
||||
for (String bn : COPY_TO_SETTER_ANNOTATIONS) if (typeMatches(bn, node, typeRef)) {
|
||||
for (String bn : annotationsToFind) if (typeMatches(bn, node, typeRef)) {
|
||||
result.add(annotation);
|
||||
break;
|
||||
}
|
||||
@@ -1024,11 +1047,54 @@ public class EclipseHandlerUtil {
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
private static final char[] OBJECT_SIG = "Ljava/lang/Object;".toCharArray();
|
||||
|
||||
private static int compare(char[] a, char[] b) {
|
||||
if (a == null) return b == null ? 0 : -1;
|
||||
if (b == null) return +1;
|
||||
int len = Math.min(a.length, b.length);
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (a[i] < b[i]) return -1;
|
||||
if (a[i] > b[i]) return +1;
|
||||
}
|
||||
return a.length < b.length ? -1 : a.length > b.length ? +1 : 0;
|
||||
}
|
||||
|
||||
public static TypeReference makeType(TypeBinding binding, ASTNode pos, boolean allowCompound) {
|
||||
if (binding.getClass() == EclipseReflectiveMembers.INTERSECTION_BINDING) {
|
||||
Object[] arr = (Object[]) EclipseReflectiveMembers.reflect(EclipseReflectiveMembers.INTERSECTION_BINDING_TYPES, binding);
|
||||
binding = (TypeBinding) arr[0];
|
||||
Object[] arr = null;
|
||||
if (binding.getClass() == EclipseReflectiveMembers.INTERSECTION_BINDING1) {
|
||||
arr = (Object[]) EclipseReflectiveMembers.reflect(EclipseReflectiveMembers.INTERSECTION_BINDING_TYPES1, binding);
|
||||
} else if (binding.getClass() == EclipseReflectiveMembers.INTERSECTION_BINDING2) {
|
||||
arr = (Object[]) EclipseReflectiveMembers.reflect(EclipseReflectiveMembers.INTERSECTION_BINDING_TYPES2, binding);
|
||||
}
|
||||
|
||||
if (arr != null) {
|
||||
// Is there a class? Alphabetically lowest wins.
|
||||
TypeBinding winner = null;
|
||||
int winLevel = 0; // 100 = array, 50 = class, 20 = typevar, 15 = wildcard, 10 = interface, 1 = Object.
|
||||
for (Object b : arr) {
|
||||
if (b instanceof TypeBinding) {
|
||||
TypeBinding tb = (TypeBinding) b;
|
||||
int level = 0;
|
||||
if (tb.isArrayType()) level = 100;
|
||||
else if (tb.isClass()) level = 50;
|
||||
else if (tb.isTypeVariable()) level = 20;
|
||||
else if (tb.isWildcard()) level = 15;
|
||||
else level = 10;
|
||||
|
||||
if (level == 50 && compare(tb.signature(), OBJECT_SIG) == 0) level = 1;
|
||||
|
||||
if (winLevel > level) continue;
|
||||
if (winLevel < level) {
|
||||
winner = tb;
|
||||
winLevel = level;
|
||||
continue;
|
||||
}
|
||||
if (compare(winner.signature(), tb.signature()) > 0) winner = tb;
|
||||
}
|
||||
}
|
||||
binding = winner;
|
||||
}
|
||||
int dims = binding.dimensions();
|
||||
binding = binding.leafComponentType();
|
||||
@@ -1941,7 +2007,11 @@ public class EclipseHandlerUtil {
|
||||
private static final char[][] EDU_UMD_CS_FINDBUGS_ANNOTATIONS_SUPPRESSFBWARNINGS = Eclipse.fromQualifiedName("edu.umd.cs.findbugs.annotations.SuppressFBWarnings");
|
||||
|
||||
public static Annotation[] addSuppressWarningsAll(EclipseNode node, ASTNode source, Annotation[] originalAnnotationArray) {
|
||||
Annotation[] anns = addAnnotation(source, originalAnnotationArray, TypeConstants.JAVA_LANG_SUPPRESSWARNINGS, new StringLiteral(ALL, 0, 0, 0));
|
||||
Annotation[] anns = originalAnnotationArray;
|
||||
|
||||
if (!Boolean.FALSE.equals(node.getAst().readConfiguration(ConfigurationKeys.ADD_SUPPRESSWARNINGS_ANNOTATIONS))) {
|
||||
anns = addAnnotation(source, anns, TypeConstants.JAVA_LANG_SUPPRESSWARNINGS, new StringLiteral(ALL, 0, 0, 0));
|
||||
}
|
||||
|
||||
if (Boolean.TRUE.equals(node.getAst().readConfiguration(ConfigurationKeys.ADD_FINDBUGS_SUPPRESSWARNINGS_ANNOTATIONS))) {
|
||||
MemberValuePair mvp = new MemberValuePair(JUSTIFICATION, 0, 0, new StringLiteral(GENERATED_CODE, 0, 0, 0));
|
||||
@@ -2418,6 +2488,26 @@ public class EclipseHandlerUtil {
|
||||
return array == null ? null : array.clone();
|
||||
}
|
||||
|
||||
public static <T> T[] concat(T[] first, T[] second, Class<T> type) {
|
||||
if (first == null)
|
||||
return second;
|
||||
if (second == null)
|
||||
return first;
|
||||
if (first.length == 0)
|
||||
return second;
|
||||
if (second.length == 0)
|
||||
return first;
|
||||
T[] result = newArray(type, first.length + second.length);
|
||||
System.arraycopy(first, 0, result, 0, first.length);
|
||||
System.arraycopy(second, 0, result, first.length, second.length);
|
||||
return result;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static <T> T[] newArray(Class<T> type, int length) {
|
||||
return (T[]) Array.newInstance(type, length);
|
||||
}
|
||||
|
||||
public static boolean isDirectDescendantOfObject(EclipseNode typeNode) {
|
||||
if (!(typeNode.get() instanceof TypeDeclaration)) throw new IllegalArgumentException("not a type node");
|
||||
TypeDeclaration typeDecl = (TypeDeclaration) typeNode.get();
|
||||
|
||||
@@ -57,6 +57,7 @@ import org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference;
|
||||
import org.eclipse.jdt.internal.compiler.ast.QualifiedAllocationExpression;
|
||||
import org.eclipse.jdt.internal.compiler.ast.QualifiedThisReference;
|
||||
import org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference;
|
||||
import org.eclipse.jdt.internal.compiler.ast.Receiver;
|
||||
import org.eclipse.jdt.internal.compiler.ast.ReturnStatement;
|
||||
import org.eclipse.jdt.internal.compiler.ast.SingleMemberAnnotation;
|
||||
import org.eclipse.jdt.internal.compiler.ast.SingleNameReference;
|
||||
@@ -485,7 +486,7 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
|
||||
List<Included<EclipseNode, ToString.Include>> fieldNodes = new ArrayList<Included<EclipseNode, ToString.Include>>();
|
||||
for (BuilderFieldData bfd : builderFields) {
|
||||
for (EclipseNode f : bfd.createdFields) {
|
||||
fieldNodes.add(new Included<EclipseNode, ToString.Include>(f, null, true));
|
||||
fieldNodes.add(new Included<EclipseNode, ToString.Include>(f, null, true, false));
|
||||
}
|
||||
}
|
||||
MethodDeclaration md = HandleToString.createToString(builderType, fieldNodes, true, false, ast, FieldAccess.ALWAYS_FIELD);
|
||||
@@ -683,7 +684,7 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
|
||||
return decl;
|
||||
}
|
||||
|
||||
static Argument[] generateBuildArgs(CheckerFrameworkVersion cfv, EclipseNode type, List<BuilderFieldData> builderFields, ASTNode source) {
|
||||
static Receiver generateBuildReceiver(CheckerFrameworkVersion cfv, EclipseNode type, List<BuilderFieldData> builderFields, ASTNode source) {
|
||||
if (!cfv.generateCalledMethods()) return null;
|
||||
|
||||
List<char[]> mandatories = new ArrayList<char[]>();
|
||||
@@ -706,9 +707,11 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
|
||||
}
|
||||
ann.memberValue = arr;
|
||||
}
|
||||
Argument arg = new Argument(new char[] { 't', 'h', 'i', 's' }, 0, generateTypeReference(type, source.sourceStart), Modifier.FINAL);
|
||||
arg.annotations = new Annotation[] {ann};
|
||||
return new Argument[] {arg};
|
||||
|
||||
QualifiedTypeReference typeReference = (QualifiedTypeReference) generateTypeReference(type, source.sourceStart);
|
||||
typeReference.annotations = new Annotation[typeReference.tokens.length][];
|
||||
typeReference.annotations[0] = new Annotation[] {ann};
|
||||
return new Receiver(new char[] { 't', 'h', 'i', 's' }, 0, typeReference, null, Modifier.FINAL);
|
||||
}
|
||||
|
||||
public MethodDeclaration generateBuildMethod(CheckerFrameworkVersion cfv, EclipseNode tdParent, boolean isStatic, String name, char[] staticName, TypeReference returnType, List<BuilderFieldData> builderFields, EclipseNode type, TypeReference[] thrownExceptions, boolean addCleaning, ASTNode source, AccessLevel access) {
|
||||
@@ -802,7 +805,7 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
|
||||
if (cfv.generateSideEffectFree()) {
|
||||
out.annotations = new Annotation[] {generateNamedAnnotation(source, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE)};
|
||||
}
|
||||
out.arguments = generateBuildArgs(cfv, type, builderFields, source);
|
||||
out.receiver = generateBuildReceiver(cfv, type, builderFields, source);
|
||||
if (staticName == null) createRelevantNonNullAnnotation(type, out);
|
||||
out.traverse(new SetGeneratedByVisitor(source), (ClassScope) null);
|
||||
return out;
|
||||
@@ -953,16 +956,14 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
|
||||
MethodDeclaration setter = HandleSetter.createSetter(td, deprecate, fieldNode, setterName, paramName, nameOfSetFlag, chain, toEclipseModifier(access),
|
||||
sourceNode, methodAnnsList, annotations != null ? Arrays.asList(copyAnnotations(source, annotations)) : Collections.<Annotation>emptyList());
|
||||
if (cfv.generateCalledMethods()) {
|
||||
Argument[] arr = setter.arguments == null ? new Argument[0] : setter.arguments;
|
||||
Argument[] newArr = new Argument[arr.length + 1];
|
||||
System.arraycopy(arr, 0, newArr, 1, arr.length);
|
||||
newArr[0] = new Argument(new char[] { 't', 'h', 'i', 's' }, 0, generateTypeReference(builderType, 0), Modifier.FINAL);
|
||||
char[][] nameNotCalled = fromQualifiedName(CheckerFrameworkVersion.NAME__NOT_CALLED);
|
||||
SingleMemberAnnotation ann = new SingleMemberAnnotation(new QualifiedTypeReference(nameNotCalled, poss(
|
||||
source, nameNotCalled.length)), source.sourceStart);
|
||||
SingleMemberAnnotation ann = new SingleMemberAnnotation(new QualifiedTypeReference(nameNotCalled, poss(source, nameNotCalled.length)), source.sourceStart);
|
||||
ann.memberValue = new StringLiteral(setterName.toCharArray(), 0, 0, 0);
|
||||
newArr[0].annotations = new Annotation[] {ann};
|
||||
setter.arguments = newArr;
|
||||
|
||||
QualifiedTypeReference typeReference = (QualifiedTypeReference) generateTypeReference(builderType, 0);
|
||||
typeReference.annotations = new Annotation[typeReference.tokens.length][];
|
||||
typeReference.annotations[0] = new Annotation[] {ann};
|
||||
setter.receiver = new Receiver(new char[] { 't', 'h', 'i', 's' }, 0, typeReference, null, Modifier.FINAL);
|
||||
}
|
||||
injectMethod(builderType, setter);
|
||||
}
|
||||
|
||||
@@ -84,13 +84,14 @@ import org.mangosdk.spi.ProviderFor;
|
||||
public class HandleConstructor {
|
||||
@ProviderFor(EclipseAnnotationHandler.class)
|
||||
public static class HandleNoArgsConstructor extends EclipseAnnotationHandler<NoArgsConstructor> {
|
||||
private static final String NAME = NoArgsConstructor.class.getSimpleName();
|
||||
private HandleConstructor handleConstructor = new HandleConstructor();
|
||||
|
||||
@Override public void handle(AnnotationValues<NoArgsConstructor> annotation, Annotation ast, EclipseNode annotationNode) {
|
||||
handleFlagUsage(annotationNode, ConfigurationKeys.NO_ARGS_CONSTRUCTOR_FLAG_USAGE, "@NoArgsConstructor", ConfigurationKeys.ANY_CONSTRUCTOR_FLAG_USAGE, "any @xArgsConstructor");
|
||||
|
||||
EclipseNode typeNode = annotationNode.up();
|
||||
if (!checkLegality(typeNode, annotationNode, NoArgsConstructor.class.getSimpleName())) return;
|
||||
if (!checkLegality(typeNode, annotationNode, NAME)) return;
|
||||
NoArgsConstructor ann = annotation.getInstance();
|
||||
AccessLevel level = ann.access();
|
||||
String staticName = ann.staticName();
|
||||
@@ -106,13 +107,14 @@ public class HandleConstructor {
|
||||
|
||||
@ProviderFor(EclipseAnnotationHandler.class)
|
||||
public static class HandleRequiredArgsConstructor extends EclipseAnnotationHandler<RequiredArgsConstructor> {
|
||||
private static final String NAME = RequiredArgsConstructor.class.getSimpleName();
|
||||
private HandleConstructor handleConstructor = new HandleConstructor();
|
||||
|
||||
@Override public void handle(AnnotationValues<RequiredArgsConstructor> annotation, Annotation ast, EclipseNode annotationNode) {
|
||||
handleFlagUsage(annotationNode, ConfigurationKeys.REQUIRED_ARGS_CONSTRUCTOR_FLAG_USAGE, "@RequiredArgsConstructor", ConfigurationKeys.ANY_CONSTRUCTOR_FLAG_USAGE, "any @xArgsConstructor");
|
||||
|
||||
EclipseNode typeNode = annotationNode.up();
|
||||
if (!checkLegality(typeNode, annotationNode, RequiredArgsConstructor.class.getSimpleName())) return;
|
||||
if (!checkLegality(typeNode, annotationNode, NAME)) return;
|
||||
RequiredArgsConstructor ann = annotation.getInstance();
|
||||
AccessLevel level = ann.access();
|
||||
if (level == AccessLevel.NONE) return;
|
||||
@@ -166,13 +168,15 @@ public class HandleConstructor {
|
||||
|
||||
@ProviderFor(EclipseAnnotationHandler.class)
|
||||
public static class HandleAllArgsConstructor extends EclipseAnnotationHandler<AllArgsConstructor> {
|
||||
private static final String NAME = AllArgsConstructor.class.getSimpleName();
|
||||
|
||||
private HandleConstructor handleConstructor = new HandleConstructor();
|
||||
|
||||
@Override public void handle(AnnotationValues<AllArgsConstructor> annotation, Annotation ast, EclipseNode annotationNode) {
|
||||
handleFlagUsage(annotationNode, ConfigurationKeys.ALL_ARGS_CONSTRUCTOR_FLAG_USAGE, "@AllArgsConstructor", ConfigurationKeys.ANY_CONSTRUCTOR_FLAG_USAGE, "any @xArgsConstructor");
|
||||
|
||||
EclipseNode typeNode = annotationNode.up();
|
||||
if (!checkLegality(typeNode, annotationNode, AllArgsConstructor.class.getSimpleName())) return;
|
||||
if (!checkLegality(typeNode, annotationNode, NAME)) return;
|
||||
AllArgsConstructor ann = annotation.getInstance();
|
||||
AccessLevel level = ann.access();
|
||||
if (level == AccessLevel.NONE) return;
|
||||
|
||||
@@ -136,9 +136,8 @@ public class HandleFieldNameConstants extends EclipseAnnotationHandler<FieldName
|
||||
EclipseNode fieldsType = findInnerClass(typeNode, innerTypeName.getName());
|
||||
boolean genConstr = false, genClinit = false;
|
||||
char[] name = innerTypeName.getCharArray();
|
||||
TypeDeclaration generatedInnerType = null;
|
||||
if (fieldsType == null) {
|
||||
generatedInnerType = new TypeDeclaration(parent.compilationResult);
|
||||
TypeDeclaration generatedInnerType = new TypeDeclaration(parent.compilationResult);
|
||||
generatedInnerType.bits |= Eclipse.ECLIPSE_DO_NOT_TOUCH_FLAG;
|
||||
generatedInnerType.modifiers = toEclipseModifier(level) | (asEnum ? ClassFileConstants.AccEnum : (ClassFileConstants.AccStatic | ClassFileConstants.AccFinal));
|
||||
generatedInnerType.name = name;
|
||||
@@ -172,10 +171,10 @@ public class HandleFieldNameConstants extends EclipseAnnotationHandler<FieldName
|
||||
injectMethod(fieldsType, constructor);
|
||||
}
|
||||
|
||||
Clinit cli = null;
|
||||
if (genClinit) {
|
||||
Clinit cli = new Clinit(parent.compilationResult);
|
||||
cli = new Clinit(parent.compilationResult);
|
||||
injectMethod(fieldsType, cli);
|
||||
cli.traverse(generatedByVisitor, ((TypeDeclaration) fieldsType.get()).scope);
|
||||
}
|
||||
|
||||
for (EclipseNode fieldNode : fields) {
|
||||
@@ -194,6 +193,7 @@ public class HandleFieldNameConstants extends EclipseAnnotationHandler<FieldName
|
||||
ac.sourceEnd = source.sourceEnd;
|
||||
constantField.initialization = ac;
|
||||
constantField.modifiers = 0;
|
||||
((TypeDeclaration) fieldsType.get()).enumConstantsCounter++;
|
||||
} else {
|
||||
constantField.type = new QualifiedTypeReference(TypeConstants.JAVA_LANG_STRING, new long[] {p, p, p});
|
||||
constantField.initialization = new StringLiteral(field.name, pS, pE, 0);
|
||||
@@ -202,5 +202,9 @@ public class HandleFieldNameConstants extends EclipseAnnotationHandler<FieldName
|
||||
injectField(fieldsType, constantField);
|
||||
constantField.traverse(generatedByVisitor, ((TypeDeclaration) fieldsType.get()).initializerScope);
|
||||
}
|
||||
|
||||
if (genClinit) {
|
||||
cli.traverse(generatedByVisitor, ((TypeDeclaration) fieldsType.get()).scope);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -285,10 +285,13 @@ public class HandleGetter extends EclipseAnnotationHandler<Getter> {
|
||||
}
|
||||
|
||||
if (addSuppressWarningsUnchecked) {
|
||||
List<Expression> suppressions = new ArrayList<Expression>(2);
|
||||
if (!Boolean.FALSE.equals(fieldNode.getAst().readConfiguration(ConfigurationKeys.ADD_SUPPRESSWARNINGS_ANNOTATIONS))) {
|
||||
suppressions.add(new StringLiteral(ALL, 0, 0, 0));
|
||||
}
|
||||
suppressions.add(new StringLiteral(UNCHECKED, 0, 0, 0));
|
||||
ArrayInitializer arr = new ArrayInitializer();
|
||||
arr.expressions = new Expression[2];
|
||||
arr.expressions[0] = new StringLiteral(ALL, 0, 0, 0);
|
||||
arr.expressions[1] = new StringLiteral(UNCHECKED, 0, 0, 0);
|
||||
arr.expressions = suppressions.toArray(new Expression[0]);
|
||||
method.annotations = addAnnotation(source, method.annotations, TypeConstants.JAVA_LANG_SUPPRESSWARNINGS, arr);
|
||||
}
|
||||
|
||||
|
||||
@@ -51,6 +51,7 @@ import lombok.core.configuration.LogDeclaration.LogFactoryParameter;
|
||||
import lombok.core.handlers.LoggingFramework;
|
||||
import lombok.eclipse.EclipseAnnotationHandler;
|
||||
import lombok.eclipse.EclipseNode;
|
||||
import lombok.eclipse.handlers.EclipseHandlerUtil.MemberExistsResult;
|
||||
|
||||
public class HandleLog {
|
||||
private static final IdentifierName LOG = IdentifierName.valueOf("log");
|
||||
@@ -59,7 +60,7 @@ public class HandleLog {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public static void processAnnotation(LoggingFramework framework, AnnotationValues<? extends java.lang.annotation.Annotation> annotation, Annotation source, EclipseNode annotationNode, String loggerTopic) {
|
||||
public static void processAnnotation(LoggingFramework framework, AnnotationValues<? extends java.lang.annotation.Annotation> annotation, Annotation source, EclipseNode annotationNode) {
|
||||
EclipseNode owner = annotationNode.up();
|
||||
|
||||
switch (owner.getKind()) {
|
||||
@@ -84,15 +85,18 @@ public class HandleLog {
|
||||
annotationNode.addWarning("Field '" + logFieldName + "' already exists.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (loggerTopic != null && loggerTopic.trim().isEmpty()) loggerTopic = null;
|
||||
|
||||
Object valueGuess = annotation.getValueGuess("topic");
|
||||
Expression loggerTopic = (Expression) annotation.getActualExpression("topic");
|
||||
|
||||
if (valueGuess instanceof String && ((String) valueGuess).trim().isEmpty()) loggerTopic = null;
|
||||
if (framework.getDeclaration().getParametersWithTopic() == null && loggerTopic != null) {
|
||||
annotationNode.addError(framework.getAnnotationAsString() + " does not allow a topic.");
|
||||
loggerTopic = null;
|
||||
}
|
||||
if (framework.getDeclaration().getParametersWithoutTopic() == null && loggerTopic == null) {
|
||||
annotationNode.addError(framework.getAnnotationAsString() + " requires a topic.");
|
||||
loggerTopic = "";
|
||||
loggerTopic = new StringLiteral(new char[]{}, 0, 0, 0);
|
||||
}
|
||||
|
||||
ClassLiteralAccess loggingType = selfType(owner, source);
|
||||
@@ -122,7 +126,7 @@ public class HandleLog {
|
||||
return result;
|
||||
}
|
||||
|
||||
private static FieldDeclaration createField(LoggingFramework framework, Annotation source, ClassLiteralAccess loggingType, String logFieldName, boolean useStatic, String loggerTopic) {
|
||||
private static FieldDeclaration createField(LoggingFramework framework, Annotation source, ClassLiteralAccess loggingType, String logFieldName, boolean useStatic, Expression loggerTopic) {
|
||||
int pS = source.sourceStart, pE = source.sourceEnd;
|
||||
long p = (long) pS << 32 | pE;
|
||||
|
||||
@@ -165,7 +169,7 @@ public class HandleLog {
|
||||
return typeReference;
|
||||
}
|
||||
|
||||
private static final Expression[] createFactoryParameters(ClassLiteralAccess loggingType, Annotation source, List<LogFactoryParameter> parameters, String loggerTopic) {
|
||||
private static final Expression[] createFactoryParameters(ClassLiteralAccess loggingType, Annotation source, List<LogFactoryParameter> parameters, Expression loggerTopic) {
|
||||
Expression[] expressions = new Expression[parameters.size()];
|
||||
int pS = source.sourceStart, pE = source.sourceEnd;
|
||||
|
||||
@@ -192,7 +196,7 @@ public class HandleLog {
|
||||
expressions[i] = factoryParameterCall;
|
||||
break;
|
||||
case TOPIC:
|
||||
expressions[i] = new StringLiteral(loggerTopic.toCharArray(), pS, pE, 0);
|
||||
expressions[i] = EclipseHandlerUtil.copyAnnotationMemberValue(loggerTopic);
|
||||
break;
|
||||
case NULL:
|
||||
expressions[i] = new NullLiteral(pS, pE);
|
||||
@@ -219,7 +223,7 @@ public class HandleLog {
|
||||
public static class HandleCommonsLog extends EclipseAnnotationHandler<lombok.extern.apachecommons.CommonsLog> {
|
||||
@Override public void handle(AnnotationValues<lombok.extern.apachecommons.CommonsLog> annotation, Annotation source, EclipseNode annotationNode) {
|
||||
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_COMMONS_FLAG_USAGE, "@apachecommons.CommonsLog", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
|
||||
processAnnotation(LoggingFramework.COMMONS, annotation, source, annotationNode, annotation.getInstance().topic());
|
||||
processAnnotation(LoggingFramework.COMMONS, annotation, source, annotationNode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,7 +234,7 @@ public class HandleLog {
|
||||
public static class HandleJulLog extends EclipseAnnotationHandler<lombok.extern.java.Log> {
|
||||
@Override public void handle(AnnotationValues<lombok.extern.java.Log> annotation, Annotation source, EclipseNode annotationNode) {
|
||||
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_JUL_FLAG_USAGE, "@java.Log", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
|
||||
processAnnotation(LoggingFramework.JUL, annotation, source, annotationNode, annotation.getInstance().topic());
|
||||
processAnnotation(LoggingFramework.JUL, annotation, source, annotationNode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -241,7 +245,7 @@ public class HandleLog {
|
||||
public static class HandleLog4jLog extends EclipseAnnotationHandler<lombok.extern.log4j.Log4j> {
|
||||
@Override public void handle(AnnotationValues<lombok.extern.log4j.Log4j> annotation, Annotation source, EclipseNode annotationNode) {
|
||||
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_LOG4J_FLAG_USAGE, "@Log4j", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
|
||||
processAnnotation(LoggingFramework.LOG4J, annotation, source, annotationNode, annotation.getInstance().topic());
|
||||
processAnnotation(LoggingFramework.LOG4J, annotation, source, annotationNode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,7 +256,7 @@ public class HandleLog {
|
||||
public static class HandleLog4j2Log extends EclipseAnnotationHandler<lombok.extern.log4j.Log4j2> {
|
||||
@Override public void handle(AnnotationValues<lombok.extern.log4j.Log4j2> annotation, Annotation source, EclipseNode annotationNode) {
|
||||
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_LOG4J2_FLAG_USAGE, "@Log4j2", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
|
||||
processAnnotation(LoggingFramework.LOG4J2, annotation, source, annotationNode, annotation.getInstance().topic());
|
||||
processAnnotation(LoggingFramework.LOG4J2, annotation, source, annotationNode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,7 +267,7 @@ public class HandleLog {
|
||||
public static class HandleSlf4jLog extends EclipseAnnotationHandler<lombok.extern.slf4j.Slf4j> {
|
||||
@Override public void handle(AnnotationValues<lombok.extern.slf4j.Slf4j> annotation, Annotation source, EclipseNode annotationNode) {
|
||||
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_SLF4J_FLAG_USAGE, "@Slf4j", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
|
||||
processAnnotation(LoggingFramework.SLF4J, annotation, source, annotationNode, annotation.getInstance().topic());
|
||||
processAnnotation(LoggingFramework.SLF4J, annotation, source, annotationNode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,7 +278,7 @@ public class HandleLog {
|
||||
public static class HandleXSlf4jLog extends EclipseAnnotationHandler<lombok.extern.slf4j.XSlf4j> {
|
||||
@Override public void handle(AnnotationValues<lombok.extern.slf4j.XSlf4j> annotation, Annotation source, EclipseNode annotationNode) {
|
||||
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_XSLF4J_FLAG_USAGE, "@XSlf4j", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
|
||||
processAnnotation(LoggingFramework.XSLF4J, annotation, source, annotationNode, annotation.getInstance().topic());
|
||||
processAnnotation(LoggingFramework.XSLF4J, annotation, source, annotationNode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -285,7 +289,7 @@ public class HandleLog {
|
||||
public static class HandleJBossLog extends EclipseAnnotationHandler<lombok.extern.jbosslog.JBossLog> {
|
||||
@Override public void handle(AnnotationValues<lombok.extern.jbosslog.JBossLog> annotation, Annotation source, EclipseNode annotationNode) {
|
||||
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_JBOSSLOG_FLAG_USAGE, "@JBossLog", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
|
||||
processAnnotation(LoggingFramework.JBOSSLOG, annotation, source, annotationNode, annotation.getInstance().topic());
|
||||
processAnnotation(LoggingFramework.JBOSSLOG, annotation, source, annotationNode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -296,7 +300,7 @@ public class HandleLog {
|
||||
public static class HandleFloggerLog extends EclipseAnnotationHandler<lombok.extern.flogger.Flogger> {
|
||||
@Override public void handle(AnnotationValues<lombok.extern.flogger.Flogger> annotation, Annotation source, EclipseNode annotationNode) {
|
||||
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_FLOGGER_FLAG_USAGE, "@Flogger", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
|
||||
processAnnotation(LoggingFramework.FLOGGER, annotation, source, annotationNode, "");
|
||||
processAnnotation(LoggingFramework.FLOGGER, annotation, source, annotationNode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -313,7 +317,7 @@ public class HandleLog {
|
||||
return;
|
||||
}
|
||||
LoggingFramework framework = new LoggingFramework(lombok.CustomLog.class, logDeclaration);
|
||||
processAnnotation(framework, annotation, source, annotationNode, annotation.getInstance().topic());
|
||||
processAnnotation(framework, annotation, source, annotationNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,6 @@ import org.eclipse.jdt.internal.compiler.ast.Expression;
|
||||
import org.eclipse.jdt.internal.compiler.ast.IfStatement;
|
||||
import org.eclipse.jdt.internal.compiler.ast.MessageSend;
|
||||
import org.eclipse.jdt.internal.compiler.ast.NullLiteral;
|
||||
import org.eclipse.jdt.internal.compiler.ast.OperatorIds;
|
||||
import org.eclipse.jdt.internal.compiler.ast.SingleNameReference;
|
||||
import org.eclipse.jdt.internal.compiler.ast.Statement;
|
||||
import org.eclipse.jdt.internal.compiler.ast.SynchronizedStatement;
|
||||
@@ -232,11 +231,11 @@ public class HandleNonNull extends EclipseAnnotationHandler<NonNull> {
|
||||
Expression cond = isIf ? ((IfStatement) stat).condition : ((AssertStatement) stat).assertExpression;
|
||||
if (!(cond instanceof EqualExpression)) return null;
|
||||
EqualExpression bin = (EqualExpression) cond;
|
||||
int operatorId = ((bin.bits & ASTNode.OperatorMASK) >> ASTNode.OperatorSHIFT);
|
||||
String op = bin.operatorToString();
|
||||
if (isIf) {
|
||||
if (operatorId != OperatorIds.EQUAL_EQUAL) return null;
|
||||
if (!"==".equals(op)) return null;
|
||||
} else {
|
||||
if (operatorId != OperatorIds.NOT_EQUAL) return null;
|
||||
if (!"!=".equals(op)) return null;
|
||||
}
|
||||
if (!(bin.left instanceof SingleNameReference)) return null;
|
||||
if (!(bin.right instanceof NullLiteral)) return null;
|
||||
|
||||
@@ -57,6 +57,7 @@ import org.eclipse.jdt.internal.compiler.ast.ParameterizedQualifiedTypeReference
|
||||
import org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference;
|
||||
import org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference;
|
||||
import org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference;
|
||||
import org.eclipse.jdt.internal.compiler.ast.Receiver;
|
||||
import org.eclipse.jdt.internal.compiler.ast.ReturnStatement;
|
||||
import org.eclipse.jdt.internal.compiler.ast.SingleMemberAnnotation;
|
||||
import org.eclipse.jdt.internal.compiler.ast.SingleNameReference;
|
||||
@@ -144,9 +145,9 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
|
||||
generateBuilderMethod = true;
|
||||
}
|
||||
if (!checkName("buildMethodName", buildMethodName, annotationNode)) return;
|
||||
|
||||
|
||||
boolean toBuilder = superbuilderAnnotation.toBuilder();
|
||||
|
||||
|
||||
EclipseNode tdParent = annotationNode.up();
|
||||
|
||||
java.util.List<BuilderFieldData> builderFields = new ArrayList<BuilderFieldData>();
|
||||
@@ -233,7 +234,7 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
|
||||
TypeReference extendsClause = td.superclass;
|
||||
TypeReference superclassBuilderClass = null;
|
||||
TypeReference[] typeArguments = new TypeReference[] {
|
||||
new SingleTypeReference(classGenericName.toCharArray(), 0),
|
||||
new SingleTypeReference(classGenericName.toCharArray(), 0),
|
||||
new SingleTypeReference(builderGenericName.toCharArray(), 0)
|
||||
};
|
||||
if (extendsClause instanceof QualifiedTypeReference) {
|
||||
@@ -242,7 +243,7 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
|
||||
String superclassBuilderClassName = builderClassNameTemplate.replace("*", superclassClassName);
|
||||
|
||||
char[][] tokens = Arrays.copyOf(qualifiedTypeReference.tokens, qualifiedTypeReference.tokens.length + 1);
|
||||
tokens[tokens.length] = superclassBuilderClassName.toCharArray();
|
||||
tokens[tokens.length-1] = superclassBuilderClassName.toCharArray();
|
||||
long[] poss = new long[tokens.length];
|
||||
Arrays.fill(poss, p);
|
||||
|
||||
@@ -274,8 +275,10 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
|
||||
// If there is no superclass, superclassBuilderClassExpression is still == null at this point.
|
||||
// You can use it to check whether to inherit or not.
|
||||
|
||||
generateBuilderBasedConstructor(cfv, tdParent, typeParams, builderFields, annotationNode, builderClassName,
|
||||
superclassBuilderClass != null);
|
||||
if (!constructorExists(tdParent, builderClassName)) {
|
||||
generateBuilderBasedConstructor(cfv, tdParent, typeParams, builderFields, annotationNode, builderClassName,
|
||||
superclassBuilderClass != null);
|
||||
}
|
||||
|
||||
// Create the abstract builder class, or reuse an existing one.
|
||||
EclipseNode builderType = findInnerClass(tdParent, builderClassName);
|
||||
@@ -330,14 +333,14 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
|
||||
cleanDecl.type = TypeReference.baseTypeReference(TypeIds.T_boolean, 0);
|
||||
injectFieldAndMarkGenerated(builderType, cleanDecl);
|
||||
}
|
||||
|
||||
|
||||
if (toBuilder) {
|
||||
// Generate $fillValuesFrom() method in the abstract builder.
|
||||
injectMethod(builderType, generateFillValuesMethod(tdParent, superclassBuilderClass != null, builderGenericName, classGenericName, builderClassName, typeParams));
|
||||
// Generate $fillValuesFromInstanceIntoBuilder() method in the builder implementation class.
|
||||
injectMethod(builderType, generateStaticFillValuesMethod(tdParent, builderClassName, typeParams, builderFields, ast, superbuilderAnnotation.setterPrefix()));
|
||||
}
|
||||
|
||||
|
||||
// Generate abstract self() and build() methods in the abstract builder.
|
||||
injectMethod(builderType, generateAbstractSelfMethod(cfv, tdParent, superclassBuilderClass != null, builderGenericName));
|
||||
injectMethod(builderType, generateAbstractBuildMethod(cfv, builderType, buildMethodName, builderFields, superclassBuilderClass != null, classGenericName, ast));
|
||||
@@ -352,7 +355,7 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
|
||||
List<Included<EclipseNode, ToString.Include>> fieldNodes = new ArrayList<Included<EclipseNode, ToString.Include>>();
|
||||
for (BuilderFieldData bfd : builderFields) {
|
||||
for (EclipseNode f : bfd.createdFields) {
|
||||
fieldNodes.add(new Included<EclipseNode, ToString.Include>(f, null, true));
|
||||
fieldNodes.add(new Included<EclipseNode, ToString.Include>(f, null, true, false));
|
||||
}
|
||||
}
|
||||
// Let toString() call super.toString() if there is a superclass, so that it also shows fields from the superclass' builder.
|
||||
@@ -383,22 +386,23 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
|
||||
}
|
||||
sanityCheckForMethodGeneratingAnnotationsOnBuilderClass(builderImplType, annotationNode);
|
||||
}
|
||||
|
||||
|
||||
if (toBuilder) {
|
||||
// Add the toBuilder() method to the annotated class.
|
||||
switch (methodExists(TO_BUILDER_METHOD_NAME_STRING, tdParent, 0)) {
|
||||
case EXISTS_BY_USER:
|
||||
annotationNode.addWarning("Not generating toBuilder() as it already exists.");
|
||||
break;
|
||||
case NOT_EXISTS:
|
||||
injectMethod(tdParent, generateToBuilderMethod(cfv, builderClassName, builderImplClassName, tdParent, typeParams, ast));
|
||||
break;
|
||||
default:
|
||||
// Should not happen.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Create the self() and build() methods in the BuilderImpl.
|
||||
injectMethod(builderImplType, generateSelfMethod(cfv, builderImplType, typeParams, p));
|
||||
|
||||
if (methodExists(buildMethodName, builderImplType, -1) == MemberExistsResult.NOT_EXISTS) {
|
||||
injectMethod(builderImplType, generateBuildMethod(cfv, builderImplType, buildMethodName, returnType, builderFields, ast));
|
||||
}
|
||||
@@ -416,7 +420,7 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private EclipseNode generateBuilderAbstractClass(EclipseNode tdParent, String builderClass,
|
||||
TypeReference superclassBuilderClass, TypeParameter[] typeParams,
|
||||
ASTNode source, String classGenericName, String builderGenericName) {
|
||||
@@ -445,7 +449,7 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
|
||||
builder.superclass = copyType(superclassBuilderClass, source);
|
||||
|
||||
builder.createDefaultConstructor(false, true);
|
||||
|
||||
|
||||
builder.traverse(new SetGeneratedByVisitor(source), (ClassScope) null);
|
||||
return injectType(tdParent, builder);
|
||||
}
|
||||
@@ -803,8 +807,8 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
|
||||
out.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
|
||||
out.modifiers = ClassFileConstants.AccProtected;
|
||||
Annotation overrideAnn = makeMarkerAnnotation(TypeConstants.JAVA_LANG_OVERRIDE, builderImplType.get());
|
||||
Annotation rrAnn = cfv.generateReturnsReceiver() ? generateNamedAnnotation(builderImplType.get(), CheckerFrameworkVersion.NAME__RETURNS_RECEIVER): null;
|
||||
Annotation sefAnn = cfv.generatePure() ? generateNamedAnnotation(builderImplType.get(), CheckerFrameworkVersion.NAME__PURE): null;
|
||||
Annotation rrAnn = cfv.generateReturnsReceiver() ? generateNamedAnnotation(builderImplType.get(), CheckerFrameworkVersion.NAME__RETURNS_RECEIVER) : null;
|
||||
Annotation sefAnn = cfv.generatePure() ? generateNamedAnnotation(builderImplType.get(), CheckerFrameworkVersion.NAME__PURE) : null;
|
||||
if (rrAnn != null && sefAnn != null) out.annotations = new Annotation[] {overrideAnn, rrAnn, sefAnn};
|
||||
else if (rrAnn != null) out.annotations = new Annotation[] {overrideAnn, rrAnn};
|
||||
else if (sefAnn != null) out.annotations = new Annotation[] {overrideAnn, sefAnn};
|
||||
@@ -829,7 +833,7 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
|
||||
if (overrideAnn != null && sefAnn != null) out.annotations = new Annotation[] {overrideAnn, sefAnn};
|
||||
else if (overrideAnn != null) out.annotations = new Annotation[] {overrideAnn};
|
||||
else if (sefAnn != null) out.annotations = new Annotation[] {sefAnn};
|
||||
out.arguments = HandleBuilder.generateBuildArgs(cfv, builderType, builderFields, source);
|
||||
out.receiver = HandleBuilder.generateBuildReceiver(cfv, builderType, builderFields, source);
|
||||
out.traverse(new SetGeneratedByVisitor(source), (ClassScope) null);
|
||||
return out;
|
||||
}
|
||||
@@ -854,7 +858,7 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
|
||||
allocationStatement.arguments = new Expression[] {new ThisReference(0, 0)};
|
||||
statements.add(new ReturnStatement(allocationStatement, 0, 0));
|
||||
out.statements = statements.isEmpty() ? null : statements.toArray(new Statement[0]);
|
||||
out.arguments = HandleBuilder.generateBuildArgs(cfv, builderType, builderFields, source);
|
||||
out.receiver = HandleBuilder.generateBuildReceiver(cfv, builderType, builderFields, source);
|
||||
createRelevantNonNullAnnotation(builderType, out);
|
||||
out.traverse(new SetGeneratedByVisitor(source), (ClassScope) null);
|
||||
return out;
|
||||
@@ -968,15 +972,14 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
|
||||
MethodDeclaration setter = HandleSetter.createSetter(td, deprecate, fieldNode, setterName, paramName, nameOfSetFlag, returnType, returnStatement, ClassFileConstants.AccPublic,
|
||||
sourceNode, methodAnnsList, annosOnParam != null ? Arrays.asList(copyAnnotations(source, annosOnParam)) : Collections.<Annotation>emptyList());
|
||||
if (cfv.generateCalledMethods()) {
|
||||
Argument[] arr = setter.arguments == null ? new Argument[0] : setter.arguments;
|
||||
Argument[] newArr = new Argument[arr.length + 1];
|
||||
System.arraycopy(arr, 0, newArr, 1, arr.length);
|
||||
newArr[0] = new Argument(new char[] { 't', 'h', 'i', 's' }, 0, generateTypeReference(builderType, 0), Modifier.FINAL);
|
||||
char[][] nameNotCalled = fromQualifiedName(CheckerFrameworkVersion.NAME__NOT_CALLED);
|
||||
SingleMemberAnnotation ann = new SingleMemberAnnotation(new QualifiedTypeReference(nameNotCalled, poss(source, nameNotCalled.length)), source.sourceStart);
|
||||
ann.memberValue = new StringLiteral(setterName.toCharArray(), 0, 0, 0);
|
||||
newArr[0].annotations = new Annotation[] {ann};
|
||||
setter.arguments = newArr;
|
||||
|
||||
QualifiedTypeReference typeReference = (QualifiedTypeReference) generateTypeReference(builderType, 0);
|
||||
typeReference.annotations = new Annotation[typeReference.tokens.length][];
|
||||
typeReference.annotations[0] = new Annotation[] {ann};
|
||||
setter.receiver = new Receiver(new char[] { 't', 'h', 'i', 's' }, 0, typeReference, null, Modifier.FINAL);
|
||||
}
|
||||
injectMethod(builderType, setter);
|
||||
}
|
||||
@@ -1159,4 +1162,26 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
|
||||
System.arraycopy(name, 0, out, prefix.length, name.length);
|
||||
return out;
|
||||
}
|
||||
|
||||
private boolean constructorExists(EclipseNode type, String builderClassName) {
|
||||
if (type != null && type.get() instanceof TypeDeclaration) {
|
||||
TypeDeclaration typeDecl = (TypeDeclaration)type.get();
|
||||
if (typeDecl.methods != null) for (AbstractMethodDeclaration def : typeDecl.methods) {
|
||||
if (def instanceof ConstructorDeclaration) {
|
||||
if ((def.bits & ASTNode.IsDefaultConstructor) != 0) continue;
|
||||
if (!def.isConstructor()) continue;
|
||||
if (isTolerate(type, def)) continue;
|
||||
if (def.arguments.length != 1) continue;
|
||||
|
||||
// Cannot use typeMatches() here, because the parameter could be fully-qualified, partially-qualified, or not qualified.
|
||||
// A string-compare of the last part should work. If it's a false-positive, users could still @Tolerate it.
|
||||
char[] typeName = def.arguments[0].type.getLastToken();
|
||||
if (builderClassName.equals(String.valueOf(typeName)))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -113,7 +113,7 @@ public class HandleUtilityClass extends EclipseAnnotationHandler<UtilityClass> {
|
||||
if (typeNode.up().getKind() == Kind.COMPILATION_UNIT) markStatic = false;
|
||||
if (markStatic && typeNode.up().getKind() == Kind.TYPE) {
|
||||
TypeDeclaration typeDecl = (TypeDeclaration) typeNode.up().get();
|
||||
if ((typeDecl.modifiers & (ClassFileConstants.AccInterface | ClassFileConstants.AccAnnotation | ClassFileConstants.AccEnum)) != 0) markStatic = false;
|
||||
if ((typeDecl.modifiers & (ClassFileConstants.AccInterface | ClassFileConstants.AccAnnotation)) != 0) markStatic = false;
|
||||
}
|
||||
|
||||
if (markStatic) classDecl.modifiers |= ClassFileConstants.AccStatic;
|
||||
|
||||
@@ -175,8 +175,10 @@ abstract class EclipseGuavaSingularizer extends EclipseSingularizer {
|
||||
md.returnType = returnType;
|
||||
char[] prefixedSingularName = data.getSetterPrefix().length == 0 ? data.getSingularName() : HandlerUtil.buildAccessorName(new String(data.getSetterPrefix()), new String(data.getSingularName())).toCharArray();
|
||||
md.selector = fluent ? prefixedSingularName : HandlerUtil.buildAccessorName("add", new String(data.getSingularName())).toCharArray();
|
||||
md.annotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource());
|
||||
|
||||
Annotation[] selfReturnAnnotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource());
|
||||
Annotation[] copyToSetterAnnotations = copyAnnotations(md, findCopyableToBuilderSingularSetterAnnotations(data.getAnnotation().up()));
|
||||
md.annotations = concat(selfReturnAnnotations, copyToSetterAnnotations, Annotation.class);
|
||||
|
||||
if (returnStatement != null) createRelevantNonNullAnnotation(builderType, md);
|
||||
data.setGeneratedByRecursive(md);
|
||||
HandleNonNull.INSTANCE.fix(injectMethod(builderType, md));
|
||||
@@ -213,8 +215,10 @@ abstract class EclipseGuavaSingularizer extends EclipseSingularizer {
|
||||
md.returnType = returnType;
|
||||
char[] prefixedSelector = data.getSetterPrefix().length == 0 ? data.getPluralName() : HandlerUtil.buildAccessorName(new String(data.getSetterPrefix()), new String(data.getPluralName())).toCharArray();
|
||||
md.selector = fluent ? prefixedSelector : HandlerUtil.buildAccessorName("addAll", new String(data.getPluralName())).toCharArray();
|
||||
md.annotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource());
|
||||
|
||||
Annotation[] selfReturnAnnotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource());
|
||||
Annotation[] copyToSetterAnnotations = copyAnnotations(md, findCopyableToSetterAnnotations(data.getAnnotation().up()));
|
||||
md.annotations = concat(selfReturnAnnotations, copyToSetterAnnotations, Annotation.class);
|
||||
|
||||
if (returnStatement != null) createRelevantNonNullAnnotation(builderType, md);
|
||||
data.setGeneratedByRecursive(md);
|
||||
injectMethod(builderType, md);
|
||||
|
||||
@@ -153,8 +153,10 @@ abstract class EclipseJavaUtilListSetSingularizer extends EclipseJavaUtilSingula
|
||||
md.returnType = returnType;
|
||||
char[] prefixedSingularName = data.getSetterPrefix().length == 0 ? data.getSingularName() : HandlerUtil.buildAccessorName(new String(data.getSetterPrefix()), new String(data.getSingularName())).toCharArray();
|
||||
md.selector = fluent ? prefixedSingularName : HandlerUtil.buildAccessorName("add", new String(data.getSingularName())).toCharArray();
|
||||
md.annotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource());
|
||||
|
||||
Annotation[] selfReturnAnnotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource());
|
||||
Annotation[] copyToSetterAnnotations = copyAnnotations(md, findCopyableToBuilderSingularSetterAnnotations(data.getAnnotation().up()));
|
||||
md.annotations = concat(selfReturnAnnotations, copyToSetterAnnotations, Annotation.class);
|
||||
|
||||
if (returnStatement != null) createRelevantNonNullAnnotation(builderType, md);
|
||||
data.setGeneratedByRecursive(md);
|
||||
HandleNonNull.INSTANCE.fix(injectMethod(builderType, md));
|
||||
@@ -189,8 +191,10 @@ abstract class EclipseJavaUtilListSetSingularizer extends EclipseJavaUtilSingula
|
||||
md.returnType = returnType;
|
||||
char[] prefixedSelector = data.getSetterPrefix().length == 0 ? data.getPluralName() : HandlerUtil.buildAccessorName(new String(data.getSetterPrefix()), new String(data.getPluralName())).toCharArray();
|
||||
md.selector = fluent ? prefixedSelector : HandlerUtil.buildAccessorName("addAll", new String(data.getPluralName())).toCharArray();
|
||||
md.annotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource());
|
||||
|
||||
Annotation[] selfReturnAnnotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource());
|
||||
Annotation[] copyToSetterAnnotations = copyAnnotations(md, findCopyableToSetterAnnotations(data.getAnnotation().up()));
|
||||
md.annotations = concat(selfReturnAnnotations, copyToSetterAnnotations, Annotation.class);
|
||||
|
||||
if (returnStatement != null) createRelevantNonNullAnnotation(builderType, md);
|
||||
data.setGeneratedByRecursive(md);
|
||||
injectMethod(builderType, md);
|
||||
|
||||
@@ -252,7 +252,9 @@ public class EclipseJavaUtilMapSingularizer extends EclipseJavaUtilSingularizer
|
||||
String setterName = HandlerUtil.buildAccessorName(setterPrefix, name);
|
||||
|
||||
md.selector = setterName.toCharArray();
|
||||
md.annotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource());
|
||||
Annotation[] selfReturnAnnotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource());
|
||||
Annotation[] copyToSetterAnnotations = copyAnnotations(md, findCopyableToBuilderSingularSetterAnnotations(data.getAnnotation().up()));
|
||||
md.annotations = concat(selfReturnAnnotations, copyToSetterAnnotations, Annotation.class);
|
||||
|
||||
if (returnStatement != null) createRelevantNonNullAnnotation(builderType, md);
|
||||
data.setGeneratedByRecursive(md);
|
||||
@@ -326,7 +328,9 @@ public class EclipseJavaUtilMapSingularizer extends EclipseJavaUtilSingularizer
|
||||
String setterName = HandlerUtil.buildAccessorName(setterPrefix, name);
|
||||
|
||||
md.selector = setterName.toCharArray();
|
||||
md.annotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource());
|
||||
Annotation[] selfReturnAnnotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource());
|
||||
Annotation[] copyToSetterAnnotations = copyAnnotations(md, findCopyableToSetterAnnotations(data.getAnnotation().up()));
|
||||
md.annotations = concat(selfReturnAnnotations, copyToSetterAnnotations, Annotation.class);
|
||||
|
||||
if (returnStatement != null) createRelevantNonNullAnnotation(builderType, md);
|
||||
data.setGeneratedByRecursive(md);
|
||||
|
||||
@@ -76,7 +76,7 @@ import lombok.AccessLevel;
|
||||
* but with {@code @WithBy}, you'd write:
|
||||
*
|
||||
* <pre>
|
||||
* movie = movie.withDirectorBy(d -> d.withBirthDateBy(bd -> bd.plusDays(1)));
|
||||
* movie = movie.withDirectorBy(d -> d.withBirthDateBy(bd -> bd.plusDays(1)));
|
||||
* </pre>
|
||||
*/
|
||||
@Target({ElementType.FIELD, ElementType.TYPE})
|
||||
|
||||
@@ -79,6 +79,8 @@ public class JavacAST extends AST<JavacAST, JavacNode, JCTree> {
|
||||
private final Log log;
|
||||
private final ErrorLog errorLogger;
|
||||
private final Context context;
|
||||
private static final URI NOT_CALCULATED_MARKER = URI.create("https://projectlombok.org/not/calculated");
|
||||
private URI memoizedAbsoluteFileLocation = NOT_CALCULATED_MARKER;
|
||||
|
||||
/**
|
||||
* Creates a new JavacAST of the provided Compilation Unit.
|
||||
@@ -102,7 +104,10 @@ public class JavacAST extends AST<JavacAST, JavacNode, JCTree> {
|
||||
}
|
||||
|
||||
@Override public URI getAbsoluteFileLocation() {
|
||||
return getAbsoluteFileLocation((JCCompilationUnit) top().get());
|
||||
if (memoizedAbsoluteFileLocation == NOT_CALCULATED_MARKER) {
|
||||
memoizedAbsoluteFileLocation = getAbsoluteFileLocation((JCCompilationUnit) top().get());
|
||||
}
|
||||
return memoizedAbsoluteFileLocation;
|
||||
}
|
||||
|
||||
public static URI getAbsoluteFileLocation(JCCompilationUnit cu) {
|
||||
@@ -258,7 +263,7 @@ public class JavacAST extends AST<JavacAST, JavacNode, JCTree> {
|
||||
|
||||
if (typeUse == null) return null;
|
||||
|
||||
if (typeUse.getClass().getSimpleName().equals("JCAnnotatedType")) {
|
||||
if (typeUse.getClass().getName().equals("com.sun.tools.javac.tree.JCTree$JCAnnotatedType")) {
|
||||
initJcAnnotatedType(typeUse.getClass());
|
||||
Collection<?> anns = Permit.permissiveReadField(Collection.class, JCANNOTATEDTYPE_ANNOTATIONS, typeUse);
|
||||
JCExpression underlying = Permit.permissiveReadField(JCExpression.class, JCANNOTATEDTYPE_UNDERLYINGTYPE, typeUse);
|
||||
@@ -381,7 +386,7 @@ public class JavacAST extends AST<JavacAST, JavacNode, JCTree> {
|
||||
if (statement instanceof JCClassDecl) return buildType((JCClassDecl) statement);
|
||||
if (statement instanceof JCVariableDecl) return buildLocalVar((JCVariableDecl) statement, Kind.LOCAL);
|
||||
if (statement instanceof JCTry) return buildTry((JCTry) statement);
|
||||
if (statement.getClass().getSimpleName().equals("JCLambda")) return buildLambda(statement);
|
||||
if (statement.getClass().getName().equals("com.sun.tools.javac.tree.JCTree$JCLambda")) return buildLambda(statement);
|
||||
if (setAndGetAsHandled(statement)) return null;
|
||||
|
||||
return drill(statement);
|
||||
|
||||
@@ -27,10 +27,6 @@ import java.util.List;
|
||||
import javax.lang.model.element.Element;
|
||||
import javax.tools.Diagnostic;
|
||||
|
||||
import lombok.core.AnnotationValues;
|
||||
import lombok.core.AST.Kind;
|
||||
import lombok.javac.handlers.JavacHandlerUtil;
|
||||
|
||||
import com.sun.tools.javac.code.Flags;
|
||||
import com.sun.tools.javac.code.Symtab;
|
||||
import com.sun.tools.javac.model.JavacTypes;
|
||||
@@ -43,8 +39,12 @@ import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
|
||||
import com.sun.tools.javac.tree.JCTree.JCModifiers;
|
||||
import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
|
||||
import com.sun.tools.javac.util.Context;
|
||||
import com.sun.tools.javac.util.Name;
|
||||
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
|
||||
import com.sun.tools.javac.util.Name;
|
||||
|
||||
import lombok.core.AST.Kind;
|
||||
import lombok.core.AnnotationValues;
|
||||
import lombok.javac.handlers.JavacHandlerUtil;
|
||||
|
||||
/**
|
||||
* Javac specific version of the LombokNode class.
|
||||
@@ -345,6 +345,29 @@ public class JavacNode extends lombok.core.LombokNode<JavacAST, JavacNode, JCTre
|
||||
return mods != null && (Flags.ENUM & mods.flags) != 0;
|
||||
}
|
||||
|
||||
@Override public boolean isPrimitive() {
|
||||
if (node instanceof JCVariableDecl && !isEnumMember()) {
|
||||
return Javac.isPrimitive(((JCVariableDecl) node).vartype);
|
||||
}
|
||||
if (node instanceof JCMethodDecl) {
|
||||
return Javac.isPrimitive(((JCMethodDecl) node).restype);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override public String fieldOrMethodBaseType() {
|
||||
if (node instanceof JCVariableDecl && !isEnumMember()) {
|
||||
return (((JCVariableDecl) node).vartype).toString();
|
||||
}
|
||||
if (node instanceof JCMethodDecl) {
|
||||
return (((JCMethodDecl) node).restype).toString();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override public boolean isTransient() {
|
||||
if (getKind() != Kind.FIELD) return false;
|
||||
JCModifiers mods = getModifiers();
|
||||
|
||||
@@ -28,7 +28,10 @@ import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
import javax.lang.model.type.TypeKind;
|
||||
import javax.tools.JavaFileObject;
|
||||
@@ -40,6 +43,7 @@ import com.sun.tools.javac.code.Type;
|
||||
import com.sun.tools.javac.code.Type.ArrayType;
|
||||
import com.sun.tools.javac.code.Type.CapturedType;
|
||||
import com.sun.tools.javac.code.Type.ClassType;
|
||||
import com.sun.tools.javac.code.Type.TypeVar;
|
||||
import com.sun.tools.javac.code.Type.WildcardType;
|
||||
import com.sun.tools.javac.code.Types;
|
||||
import com.sun.tools.javac.comp.Attr;
|
||||
@@ -59,6 +63,7 @@ import com.sun.tools.javac.util.Context;
|
||||
import com.sun.tools.javac.util.List;
|
||||
import com.sun.tools.javac.util.ListBuffer;
|
||||
import com.sun.tools.javac.util.Log;
|
||||
import com.sun.tools.javac.util.Name;
|
||||
|
||||
import lombok.Lombok;
|
||||
import lombok.core.debug.AssertionLogger;
|
||||
@@ -314,6 +319,41 @@ public class JavacResolution {
|
||||
return result;
|
||||
}
|
||||
|
||||
private static Iterable<? extends Type> concat(final Type t, final Collection<? extends Type> ts) {
|
||||
if (t == null) return ts;
|
||||
|
||||
return new Iterable<Type>() {
|
||||
@Override public Iterator<Type> iterator() {
|
||||
return new Iterator<Type>() {
|
||||
private boolean first = true;
|
||||
private Iterator<? extends Type> wrap = ts == null ? null : ts.iterator();
|
||||
@Override public boolean hasNext() {
|
||||
if (first) return true;
|
||||
if (wrap == null) return false;
|
||||
return wrap.hasNext();
|
||||
}
|
||||
|
||||
@Override public Type next() {
|
||||
if (first) {
|
||||
first = false;
|
||||
return t;
|
||||
}
|
||||
if (wrap == null) throw new NoSuchElementException();
|
||||
return wrap.next();
|
||||
}
|
||||
|
||||
@Override public void remove() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static int compare(Name a, Name b) {
|
||||
return a.compareTo(b);
|
||||
}
|
||||
|
||||
private static JCExpression typeToJCTree0(Type type, JavacAST ast, boolean allowCompound, boolean allowVoid, boolean allowCapture) throws TypeNotConvertibleException {
|
||||
// NB: There's such a thing as maker.Type(type), but this doesn't work very well; it screws up anonymous classes, captures, and adds an extra prefix dot for some reason too.
|
||||
// -- so we write our own take on that here.
|
||||
@@ -335,12 +375,30 @@ public class JavacResolution {
|
||||
if (symbol.name.length() == 0) {
|
||||
// Anonymous inner class
|
||||
if (type instanceof ClassType) {
|
||||
List<Type> ifaces = ((ClassType) type).interfaces_field;
|
||||
Type winner = null;
|
||||
int winLevel = 0; // 100 = array, 50 = class, 20 = typevar, 15 = wildcard, 10 = interface, 1 = Object.
|
||||
Type supertype = ((ClassType) type).supertype_field;
|
||||
if (isObject(supertype) && ifaces != null && ifaces.length() > 0) {
|
||||
return typeToJCTree(ifaces.get(0), ast, allowCompound, allowVoid, allowCapture);
|
||||
List<Type> ifaces = ((ClassType) type).interfaces_field;
|
||||
for (Type t : concat(supertype, ifaces)) {
|
||||
int level = 0;
|
||||
if (t instanceof ArrayType) level = 100;
|
||||
else if (t instanceof TypeVar) level = 20;
|
||||
else if (t instanceof WildcardType) level = 15;
|
||||
else if (t.isInterface()) level = 10;
|
||||
else if (isObject(t)) level = 1;
|
||||
else if (t instanceof ClassType) level = 50;
|
||||
else level = 5;
|
||||
|
||||
if (winLevel > level) continue;
|
||||
if (winLevel < level) {
|
||||
winner = t;
|
||||
winLevel = level;
|
||||
continue;
|
||||
}
|
||||
if (compare(winner.tsym.getQualifiedName(), t.tsym.getQualifiedName()) < 0) winner = t;
|
||||
}
|
||||
if (supertype != null) return typeToJCTree(supertype, ast, allowCompound, allowVoid, allowCapture);
|
||||
if (winner == null) return createJavaLangObject(ast);
|
||||
return typeToJCTree(winner, ast, allowCompound, allowVoid, allowCapture);
|
||||
}
|
||||
throw new TypeNotConvertibleException("Anonymous inner class");
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
*/
|
||||
package lombok.javac;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.SortedSet;
|
||||
|
||||
import javax.annotation.processing.Messager;
|
||||
@@ -34,7 +34,6 @@ import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
|
||||
import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
|
||||
import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
|
||||
import com.sun.tools.javac.util.Context;
|
||||
import com.sun.tools.javac.util.List;
|
||||
|
||||
import lombok.ConfigurationKeys;
|
||||
import lombok.core.CleanupRegistry;
|
||||
@@ -57,31 +56,15 @@ public class JavacTransformer {
|
||||
return handlers.getPrioritiesRequiringResolutionReset();
|
||||
}
|
||||
|
||||
public void transform(long priority, Context context, java.util.List<JCCompilationUnit> compilationUnitsRaw, CleanupRegistry cleanup) {
|
||||
List<JCCompilationUnit> compilationUnits;
|
||||
if (compilationUnitsRaw instanceof List<?>) {
|
||||
compilationUnits = (List<JCCompilationUnit>) compilationUnitsRaw;
|
||||
} else {
|
||||
compilationUnits = List.nil();
|
||||
for (int i = compilationUnitsRaw.size() -1; i >= 0; i--) {
|
||||
compilationUnits = compilationUnits.prepend(compilationUnitsRaw.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
java.util.List<JavacAST> asts = new ArrayList<JavacAST>();
|
||||
|
||||
public void transform(long priority, Context context, List<JCCompilationUnit> compilationUnits, CleanupRegistry cleanup) {
|
||||
for (JCCompilationUnit unit : compilationUnits) {
|
||||
if (!Boolean.TRUE.equals(LombokConfiguration.read(ConfigurationKeys.LOMBOK_DISABLE, JavacAST.getAbsoluteFileLocation(unit)))) {
|
||||
asts.add(new JavacAST(messager, context, unit, cleanup));
|
||||
JavacAST ast = new JavacAST(messager, context, unit, cleanup);
|
||||
ast.traverse(new AnnotationVisitor(priority));
|
||||
handlers.callASTVisitors(ast, priority);
|
||||
if (ast.isChanged()) LombokOptions.markChanged(context, (JCCompilationUnit) ast.top().get());
|
||||
}
|
||||
}
|
||||
|
||||
for (JavacAST ast : asts) {
|
||||
ast.traverse(new AnnotationVisitor(priority));
|
||||
handlers.callASTVisitors(ast, priority);
|
||||
}
|
||||
|
||||
for (JavacAST ast : asts) if (ast.isChanged()) LombokOptions.markChanged(context, (JCCompilationUnit) ast.top().get());
|
||||
}
|
||||
|
||||
private class AnnotationVisitor extends JavacASTAdapter {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2019 The Project Lombok Authors.
|
||||
* Copyright (C) 2010-2020 The Project Lombok Authors.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -22,23 +22,15 @@
|
||||
|
||||
package lombok.javac.apt;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import javax.tools.FileObject;
|
||||
import javax.tools.JavaFileManager;
|
||||
import javax.tools.JavaFileObject;
|
||||
import javax.tools.JavaFileObject.Kind;
|
||||
|
||||
import com.sun.tools.javac.file.BaseFileManager;
|
||||
|
||||
import lombok.core.DiagnosticsReceiver;
|
||||
import lombok.permit.Permit;
|
||||
@@ -116,22 +108,20 @@ final class LombokFileObjects {
|
||||
if (jfmClassName.equals("com.sun.tools.javac.file.JavacFileManager")) {
|
||||
try {
|
||||
Class<?> superType = Class.forName("com.sun.tools.javac.file.BaseFileManager");
|
||||
if (superType.isInstance(jfm)) {
|
||||
return new Java9Compiler(jfm);
|
||||
}
|
||||
if (superType.isInstance(jfm)) return java9Compiler(jfm);
|
||||
}
|
||||
catch (Throwable e) {}
|
||||
return Compiler.JAVAC7;
|
||||
}
|
||||
if (KNOWN_JAVA9_FILE_MANAGERS.contains(jfmClassName)) {
|
||||
try {
|
||||
return new Java9Compiler(jfm);
|
||||
return java9Compiler(jfm);
|
||||
}
|
||||
catch (Throwable e) {}
|
||||
}
|
||||
try {
|
||||
if (Class.forName("com.sun.tools.javac.file.PathFileObject") == null) throw new NullPointerException();
|
||||
return new Java9Compiler(jfm);
|
||||
return java9Compiler(jfm);
|
||||
} catch (Throwable e) {}
|
||||
try {
|
||||
if (Class.forName("com.sun.tools.javac.file.BaseFileObject") == null) throw new NullPointerException();
|
||||
@@ -156,122 +146,24 @@ final class LombokFileObjects {
|
||||
return compiler.wrap(new InterceptingJavaFileObject(delegate, fileName, diagnostics, compiler.getDecoderMethod()));
|
||||
}
|
||||
|
||||
static class Java9Compiler implements Compiler {
|
||||
private final BaseFileManager fileManager;
|
||||
|
||||
public Java9Compiler(JavaFileManager jfm) {
|
||||
fileManager = asBaseFileManager(jfm);
|
||||
}
|
||||
|
||||
@Override public JavaFileObject wrap(LombokFileObject fileObject) {
|
||||
Path p; try {
|
||||
p = toPath(fileObject);
|
||||
} catch (Exception e) {
|
||||
p = null;
|
||||
}
|
||||
|
||||
// J9BFOW extends javac's internal file base impl of javax.tools.JavaFileObject.
|
||||
// J9JFOW just straight implements it. Probably J9JFOW is fine, but we decided to extend java's internal impl possibly for a reason.
|
||||
// Some exotic build environments don't _have_ file objects and crash with FileNotFoundEx, so if that happens, let's try the alternative.
|
||||
if (p != null) return new Javac9BaseFileObjectWrapper(fileManager, p, fileObject);
|
||||
return new Javac9JavaFileObjectWrapper(fileObject);
|
||||
}
|
||||
|
||||
@Override public Method getDecoderMethod() {
|
||||
private static Constructor<?> j9CompilerConstructor = null;
|
||||
private static Compiler java9Compiler(JavaFileManager jfm) {
|
||||
try {
|
||||
if (j9CompilerConstructor == null) j9CompilerConstructor = Class.forName("lombok.javac.apt.Java9Compiler").getConstructor(JavaFileManager.class);
|
||||
return (Compiler) j9CompilerConstructor.newInstance(jfm);
|
||||
} catch (ClassNotFoundException e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Path toPath(LombokFileObject fileObject) {
|
||||
URI uri = fileObject.toUri();
|
||||
if (uri.getScheme() == null) {
|
||||
uri = URI.create("file:///" + uri);
|
||||
}
|
||||
try {
|
||||
return Paths.get(uri);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new IllegalArgumentException("Problems in URI '" + uri + "' (" + fileObject.toUri() + ")", e);
|
||||
}
|
||||
}
|
||||
|
||||
private static BaseFileManager asBaseFileManager(JavaFileManager jfm) {
|
||||
if (jfm instanceof BaseFileManager) {
|
||||
return (BaseFileManager) jfm;
|
||||
}
|
||||
return new FileManagerWrapper(jfm);
|
||||
}
|
||||
|
||||
static class FileManagerWrapper extends BaseFileManager {
|
||||
JavaFileManager manager;
|
||||
|
||||
public FileManagerWrapper(JavaFileManager manager) {
|
||||
super(null);
|
||||
this.manager = manager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int isSupportedOption(String option) {
|
||||
return manager.isSupportedOption(option);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassLoader getClassLoader(Location location) {
|
||||
return manager.getClassLoader(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<JavaFileObject> list(Location location, String packageName, Set<Kind> kinds, boolean recurse) throws IOException {
|
||||
return manager.list(location, packageName, kinds, recurse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String inferBinaryName(Location location, JavaFileObject file) {
|
||||
return manager.inferBinaryName(location, file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSameFile(FileObject a, FileObject b) {
|
||||
return manager.isSameFile(a, b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleOption(String current, Iterator<String> remaining) {
|
||||
return manager.handleOption(current, remaining);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasLocation(Location location) {
|
||||
return manager.hasLocation(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaFileObject getJavaFileForInput(Location location, String className, Kind kind) throws IOException {
|
||||
return manager.getJavaFileForInput(location, className, kind);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaFileObject getJavaFileForOutput(Location location, String className, Kind kind, FileObject sibling) throws IOException {
|
||||
return manager.getJavaFileForOutput(location, className, kind, sibling);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileObject getFileForInput(Location location, String packageName, String relativeName) throws IOException {
|
||||
return manager.getFileForInput(location, packageName, relativeName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileObject getFileForOutput(Location location, String packageName, String relativeName, FileObject sibling) throws IOException {
|
||||
return manager.getFileForOutput(location, packageName, relativeName, sibling);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() throws IOException {
|
||||
manager.flush();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
manager.close();
|
||||
}
|
||||
} catch (NoSuchMethodException e) {
|
||||
return null;
|
||||
} catch (InvocationTargetException e) {
|
||||
Throwable t = e.getCause();
|
||||
if (t instanceof RuntimeException) throw (RuntimeException) t;
|
||||
if (t instanceof Error) throw (Error) t;
|
||||
throw new RuntimeException(t);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (InstantiationException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@ package lombok.javac.apt;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
@@ -42,7 +43,6 @@ import javax.annotation.processing.RoundEnvironment;
|
||||
import javax.annotation.processing.SupportedAnnotationTypes;
|
||||
import javax.lang.model.SourceVersion;
|
||||
import javax.lang.model.element.Element;
|
||||
import javax.lang.model.element.QualifiedNameable;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
import javax.tools.Diagnostic.Kind;
|
||||
import javax.tools.JavaFileManager;
|
||||
@@ -371,7 +371,7 @@ public class LombokProcessor extends AbstractProcessor {
|
||||
|
||||
private String getModuleNameFor(Element element) {
|
||||
while (element != null) {
|
||||
if (element.getKind().name().equals("MODULE")) return ModuleNameOracle.getModuleName(element);
|
||||
if (element.getKind().name().equals("MODULE")) return getModuleName(element);
|
||||
Element n = element.getEnclosingElement();
|
||||
if (n == element) return null;
|
||||
element = n;
|
||||
@@ -379,12 +379,24 @@ public class LombokProcessor extends AbstractProcessor {
|
||||
return null;
|
||||
}
|
||||
|
||||
// QualifiedNameable is a java7 thing, so to remain compatible with java6, shove this into an inner class to avoid the ClassNotFoundError.
|
||||
private static class ModuleNameOracle {
|
||||
static String getModuleName(Element element) {
|
||||
if (!(element instanceof QualifiedNameable)) return null;
|
||||
String name = ((QualifiedNameable) element).getQualifiedName().toString().trim();
|
||||
private static Class<?> qualifiedNamableClass = null;
|
||||
private static Method qualifiedNamableQualifiedNameMethod = null;
|
||||
// QualifiedNameable isn't in java 6, so to remain compatible with java6, use reflection.
|
||||
private static String getModuleName(Element element) {
|
||||
try {
|
||||
if (qualifiedNamableClass == null) qualifiedNamableClass = Class.forName("javax.lang.model.element.QualifiedNamable");
|
||||
if (!qualifiedNamableClass.isInstance(element)) return null;
|
||||
if (qualifiedNamableQualifiedNameMethod == null) qualifiedNamableQualifiedNameMethod = qualifiedNamableClass.getMethod("getQualifiedName");
|
||||
String name = qualifiedNamableQualifiedNameMethod.invoke(element).toString().trim();
|
||||
return name.isEmpty() ? null : name;
|
||||
} catch (ClassNotFoundException e) {
|
||||
return null;
|
||||
} catch (NoSuchMethodException e) {
|
||||
return null;
|
||||
} catch (InvocationTargetException e) {
|
||||
return null;
|
||||
} catch (IllegalAccessException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,8 @@ import static lombok.javac.JavacTreeMaker.TypeTag.typeTag;
|
||||
import static lombok.javac.handlers.JavacHandlerUtil.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.lang.model.element.Modifier;
|
||||
|
||||
@@ -38,6 +40,7 @@ import com.sun.tools.javac.tree.JCTree.JCAnnotation;
|
||||
import com.sun.tools.javac.tree.JCTree.JCArrayTypeTree;
|
||||
import com.sun.tools.javac.tree.JCTree.JCBlock;
|
||||
import com.sun.tools.javac.tree.JCTree.JCClassDecl;
|
||||
import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
|
||||
import com.sun.tools.javac.tree.JCTree.JCExpression;
|
||||
import com.sun.tools.javac.tree.JCTree.JCFieldAccess;
|
||||
import com.sun.tools.javac.tree.JCTree.JCIdent;
|
||||
@@ -432,7 +435,7 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
|
||||
java.util.List<Included<JavacNode, ToString.Include>> fieldNodes = new ArrayList<Included<JavacNode, ToString.Include>>();
|
||||
for (BuilderFieldData bfd : builderFields) {
|
||||
for (JavacNode f : bfd.createdFields) {
|
||||
fieldNodes.add(new Included<JavacNode, ToString.Include>(f, null, true));
|
||||
fieldNodes.add(new Included<JavacNode, ToString.Include>(f, null, true, false));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -845,11 +848,30 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
|
||||
newMethod.params = List.of(recv, newMethod.params.get(0));
|
||||
}
|
||||
recursiveSetGeneratedBy(newMethod, source.get(), builderType.getContext());
|
||||
copyJavadoc(originalFieldNode, newMethod, CopyJavadoc.SETTER, true);
|
||||
if (source.up().getKind() == Kind.METHOD) {
|
||||
copyJavadocFromParam(originalFieldNode.up(), newMethod, paramName.toString());
|
||||
} else {
|
||||
copyJavadoc(originalFieldNode, newMethod, CopyJavadoc.SETTER, true);
|
||||
}
|
||||
|
||||
injectMethod(builderType, newMethod);
|
||||
}
|
||||
|
||||
private void copyJavadocFromParam(JavacNode from, JCMethodDecl to, String param) {
|
||||
try {
|
||||
JCCompilationUnit cu = ((JCCompilationUnit) from.top().get());
|
||||
String methodComment = Javac.getDocComment(cu, from.get());
|
||||
if (methodComment == null) return;
|
||||
|
||||
Pattern pattern = Pattern.compile("@param " + param + " (\\S|\\s)+?(?=^ ?@)", Pattern.MULTILINE | Pattern.CASE_INSENSITIVE);
|
||||
Matcher matcher = pattern.matcher(methodComment);
|
||||
if (matcher.find()) {
|
||||
String newJavadoc = addReturnsThisIfNeeded(matcher.group());
|
||||
Javac.setDocComment(cu, to, newJavadoc);
|
||||
}
|
||||
} catch (Exception ignore) {}
|
||||
}
|
||||
|
||||
public JavacNode makeBuilderClass(boolean isStatic, JavacNode source, JavacNode tdParent, String builderClassName, List<JCTypeParameter> typeParams, JCAnnotation ast, AccessLevel access) {
|
||||
JavacTreeMaker maker = tdParent.getTreeMaker();
|
||||
int modifiers = toJavacModifier(access);
|
||||
|
||||
@@ -68,6 +68,7 @@ import lombok.javac.handlers.JavacHandlerUtil.MemberExistsResult;
|
||||
public class HandleConstructor {
|
||||
@ProviderFor(JavacAnnotationHandler.class)
|
||||
public static class HandleNoArgsConstructor extends JavacAnnotationHandler<NoArgsConstructor> {
|
||||
private static final String NAME = NoArgsConstructor.class.getSimpleName();
|
||||
private HandleConstructor handleConstructor = new HandleConstructor();
|
||||
|
||||
@Override public void handle(AnnotationValues<NoArgsConstructor> annotation, JCAnnotation ast, JavacNode annotationNode) {
|
||||
@@ -76,7 +77,7 @@ public class HandleConstructor {
|
||||
deleteAnnotationIfNeccessary(annotationNode, NoArgsConstructor.class);
|
||||
deleteImportFromCompilationUnit(annotationNode, "lombok.AccessLevel");
|
||||
JavacNode typeNode = annotationNode.up();
|
||||
if (!checkLegality(typeNode, annotationNode, NoArgsConstructor.class.getSimpleName())) return;
|
||||
if (!checkLegality(typeNode, annotationNode, NAME)) return;
|
||||
List<JCAnnotation> onConstructor = unboxAndRemoveAnnotationParameter(ast, "onConstructor", "@NoArgsConstructor(onConstructor", annotationNode);
|
||||
NoArgsConstructor ann = annotation.getInstance();
|
||||
AccessLevel level = ann.access();
|
||||
@@ -89,6 +90,7 @@ public class HandleConstructor {
|
||||
|
||||
@ProviderFor(JavacAnnotationHandler.class)
|
||||
public static class HandleRequiredArgsConstructor extends JavacAnnotationHandler<RequiredArgsConstructor> {
|
||||
private static final String NAME = RequiredArgsConstructor.class.getSimpleName();
|
||||
private HandleConstructor handleConstructor = new HandleConstructor();
|
||||
|
||||
@Override public void handle(AnnotationValues<RequiredArgsConstructor> annotation, JCAnnotation ast, JavacNode annotationNode) {
|
||||
@@ -97,7 +99,7 @@ public class HandleConstructor {
|
||||
deleteAnnotationIfNeccessary(annotationNode, RequiredArgsConstructor.class);
|
||||
deleteImportFromCompilationUnit(annotationNode, "lombok.AccessLevel");
|
||||
JavacNode typeNode = annotationNode.up();
|
||||
if (!checkLegality(typeNode, annotationNode, RequiredArgsConstructor.class.getSimpleName())) return;
|
||||
if (!checkLegality(typeNode, annotationNode, NAME)) return;
|
||||
List<JCAnnotation> onConstructor = unboxAndRemoveAnnotationParameter(ast, "onConstructor", "@RequiredArgsConstructor(onConstructor", annotationNode);
|
||||
RequiredArgsConstructor ann = annotation.getInstance();
|
||||
AccessLevel level = ann.access();
|
||||
@@ -138,6 +140,7 @@ public class HandleConstructor {
|
||||
|
||||
@ProviderFor(JavacAnnotationHandler.class)
|
||||
public static class HandleAllArgsConstructor extends JavacAnnotationHandler<AllArgsConstructor> {
|
||||
private static final String NAME = AllArgsConstructor.class.getSimpleName();
|
||||
private HandleConstructor handleConstructor = new HandleConstructor();
|
||||
|
||||
@Override public void handle(AnnotationValues<AllArgsConstructor> annotation, JCAnnotation ast, JavacNode annotationNode) {
|
||||
@@ -146,7 +149,7 @@ public class HandleConstructor {
|
||||
deleteAnnotationIfNeccessary(annotationNode, AllArgsConstructor.class);
|
||||
deleteImportFromCompilationUnit(annotationNode, "lombok.AccessLevel");
|
||||
JavacNode typeNode = annotationNode.up();
|
||||
if (!checkLegality(typeNode, annotationNode, AllArgsConstructor.class.getSimpleName())) return;
|
||||
if (!checkLegality(typeNode, annotationNode, NAME)) return;
|
||||
List<JCAnnotation> onConstructor = unboxAndRemoveAnnotationParameter(ast, "onConstructor", "@AllArgsConstructor(onConstructor", annotationNode);
|
||||
AllArgsConstructor ann = annotation.getInstance();
|
||||
AccessLevel level = ann.access();
|
||||
|
||||
@@ -48,6 +48,7 @@ import org.mangosdk.spi.ProviderFor;
|
||||
import com.sun.tools.javac.code.Attribute.Compound;
|
||||
import com.sun.tools.javac.code.Flags;
|
||||
import com.sun.tools.javac.code.Symbol;
|
||||
import com.sun.tools.javac.code.Symbol.MethodSymbol;
|
||||
import com.sun.tools.javac.code.Symbol.TypeSymbol;
|
||||
import com.sun.tools.javac.code.Type;
|
||||
import com.sun.tools.javac.code.Type.ClassType;
|
||||
@@ -175,14 +176,14 @@ public class HandleDelegate extends JavacAnnotationHandler<Delegate> {
|
||||
List<MethodSig> signaturesToExclude = new ArrayList<MethodSig>();
|
||||
Set<String> banList = new HashSet<String>();
|
||||
banList.addAll(METHODS_IN_OBJECT);
|
||||
/* To exclude all methods in the class itself, try this:
|
||||
for (Symbol member : ((JCClassDecl)typeNode.get()).sym.getEnclosedElements()) {
|
||||
if (member instanceof MethodSymbol) {
|
||||
MethodSymbol method = (MethodSymbol) member;
|
||||
banList.add(printSig((ExecutableType) method.asType(), method.name, annotationNode.getTypesUtil()));
|
||||
|
||||
// Add already implemented methods to ban list
|
||||
JavacNode typeNode = upToTypeNode(annotationNode);
|
||||
for (Symbol m : ((JCClassDecl)typeNode.get()).sym.getEnclosedElements()) {
|
||||
if (m instanceof MethodSymbol) {
|
||||
banList.add(printSig((ExecutableType) m.asType(), m.name, annotationNode.getTypesUtil()));
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
try {
|
||||
for (Type t : toExclude) {
|
||||
@@ -389,10 +390,11 @@ public class HandleDelegate extends JavacAnnotationHandler<Delegate> {
|
||||
boolean isDeprecated = (member.flags() & DEPRECATED) != 0;
|
||||
signatures.add(new MethodSig(member.name, methodType, isDeprecated, exElem));
|
||||
}
|
||||
|
||||
if (ct.supertype_field instanceof ClassType) addMethodBindings(signatures, (ClassType) ct.supertype_field, types, banList);
|
||||
if (ct.interfaces_field != null) for (Type iface : ct.interfaces_field) {
|
||||
if (iface instanceof ClassType) addMethodBindings(signatures, (ClassType) iface, types, banList);
|
||||
|
||||
for (Type type : types.directSupertypes(ct)) {
|
||||
if (type instanceof ClassType) {
|
||||
addMethodBindings(signatures, (ClassType) type, types, banList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -232,9 +232,17 @@ public class HandleGetter extends JavacAnnotationHandler<Getter> {
|
||||
|
||||
List<JCStatement> statements;
|
||||
JCTree toClearOfMarkers = null;
|
||||
int[] methodArgPos = null;
|
||||
boolean addSuppressWarningsUnchecked = false;
|
||||
if (lazy && !inNetbeansEditor(field)) {
|
||||
toClearOfMarkers = fieldNode.init;
|
||||
if (toClearOfMarkers instanceof JCMethodInvocation) {
|
||||
List<JCExpression> args = ((JCMethodInvocation) toClearOfMarkers).args;
|
||||
methodArgPos = new int[args.length()];
|
||||
for (int i = 0; i < methodArgPos.length; i++) {
|
||||
methodArgPos[i] = args.get(i).pos;
|
||||
}
|
||||
}
|
||||
statements = createLazyGetterBody(treeMaker, field, source);
|
||||
addSuppressWarningsUnchecked = LombokOptionsFactory.getDelombokOptions(field.getContext()).getFormatPreferences().generateSuppressWarnings();
|
||||
} else {
|
||||
@@ -262,10 +270,20 @@ public class HandleGetter extends JavacAnnotationHandler<Getter> {
|
||||
methodGenericParams, parameters, throwsClauses, methodBody, annotationMethodDefaultValue), source, field.getContext());
|
||||
|
||||
if (toClearOfMarkers != null) recursiveSetGeneratedBy(toClearOfMarkers, null, null);
|
||||
if (methodArgPos != null) {
|
||||
for (int i = 0; i < methodArgPos.length; i++) {
|
||||
((JCMethodInvocation) toClearOfMarkers).args.get(i).pos = methodArgPos[i];
|
||||
}
|
||||
}
|
||||
decl.mods.annotations = decl.mods.annotations.appendList(delegates);
|
||||
|
||||
if (addSuppressWarningsUnchecked) {
|
||||
addAnnotation(decl.mods, field, source.pos, source, field.getContext(), "java.lang.SuppressWarnings", treeMaker.NewArray(null, List.<JCExpression>nil(), List.<JCExpression>of(treeMaker.Literal("all"), treeMaker.Literal("unchecked"))));
|
||||
ListBuffer<JCExpression> suppressions = new ListBuffer<JCExpression>();
|
||||
if (!Boolean.FALSE.equals(field.getAst().readConfiguration(ConfigurationKeys.ADD_SUPPRESSWARNINGS_ANNOTATIONS))) {
|
||||
suppressions.add(treeMaker.Literal("all"));
|
||||
}
|
||||
suppressions.add(treeMaker.Literal("unchecked"));
|
||||
addAnnotation(decl.mods, field, source.pos, source, field.getContext(), "java.lang.SuppressWarnings", treeMaker.NewArray(null, List.<JCExpression>nil(), suppressions.toList()));
|
||||
}
|
||||
|
||||
copyJavadoc(field, decl, CopyJavadoc.GETTER);
|
||||
|
||||
@@ -149,7 +149,6 @@ public class HandleJacksonized extends JavacAnnotationHandler<Jacksonized> {
|
||||
// @SuperBuilder? Make it package-private!
|
||||
if (superBuilderAnnotationNode != null)
|
||||
builderClass.mods.flags = builderClass.mods.flags & ~Flags.PRIVATE;
|
||||
|
||||
}
|
||||
|
||||
private String getBuilderClassName(JCAnnotation ast, JavacNode annotationNode, JavacNode annotatedNode, JCClassDecl td, AnnotationValues<Builder> builderAnnotation, JavacTreeMaker maker) {
|
||||
|
||||
@@ -56,7 +56,7 @@ public class HandleLog {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public static void processAnnotation(LoggingFramework framework, AnnotationValues<?> annotation, JavacNode annotationNode, String loggerTopic) {
|
||||
public static void processAnnotation(LoggingFramework framework, AnnotationValues<?> annotation, JavacNode annotationNode) {
|
||||
deleteAnnotationIfNeccessary(annotationNode, framework.getAnnotationClass());
|
||||
|
||||
JavacNode typeNode = annotationNode.up();
|
||||
@@ -76,14 +76,17 @@ public class HandleLog {
|
||||
return;
|
||||
}
|
||||
|
||||
if (loggerTopic != null && loggerTopic.trim().isEmpty()) loggerTopic = null;
|
||||
Object valueGuess = annotation.getValueGuess("topic");
|
||||
JCExpression loggerTopic = (JCExpression) annotation.getActualExpression("topic");
|
||||
|
||||
if (valueGuess instanceof String && ((String) valueGuess).trim().isEmpty()) loggerTopic = null;
|
||||
if (framework.getDeclaration().getParametersWithTopic() == null && loggerTopic != null) {
|
||||
annotationNode.addError(framework.getAnnotationAsString() + " does not allow a topic.");
|
||||
loggerTopic = null;
|
||||
}
|
||||
if (framework.getDeclaration().getParametersWithoutTopic() == null && loggerTopic == null) {
|
||||
annotationNode.addError(framework.getAnnotationAsString() + " requires a topic.");
|
||||
loggerTopic = "";
|
||||
loggerTopic = typeNode.getTreeMaker().Literal("");
|
||||
}
|
||||
|
||||
JCFieldAccess loggingType = selfType(typeNode);
|
||||
@@ -101,7 +104,7 @@ public class HandleLog {
|
||||
return maker.Select(maker.Ident(name), typeNode.toName("class"));
|
||||
}
|
||||
|
||||
private static boolean createField(LoggingFramework framework, JavacNode typeNode, JCFieldAccess loggingType, JCTree source, String logFieldName, boolean useStatic, String loggerTopic) {
|
||||
private static boolean createField(LoggingFramework framework, JavacNode typeNode, JCFieldAccess loggingType, JCTree source, String logFieldName, boolean useStatic, JCExpression loggerTopic) {
|
||||
JavacTreeMaker maker = typeNode.getTreeMaker();
|
||||
|
||||
LogDeclaration logDeclaration = framework.getDeclaration();
|
||||
@@ -121,7 +124,7 @@ public class HandleLog {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static JCExpression[] createFactoryParameters(JavacNode typeNode, JCFieldAccess loggingType, java.util.List<LogFactoryParameter> parameters, String loggerTopic) {
|
||||
private static JCExpression[] createFactoryParameters(JavacNode typeNode, JCFieldAccess loggingType, java.util.List<LogFactoryParameter> parameters, JCExpression loggerTopic) {
|
||||
JCExpression[] expressions = new JCExpression[parameters.size()];
|
||||
JavacTreeMaker maker = typeNode.getTreeMaker();
|
||||
|
||||
@@ -136,7 +139,7 @@ public class HandleLog {
|
||||
expressions[i] = maker.Apply(List.<JCExpression>nil(), method, List.<JCExpression>nil());
|
||||
break;
|
||||
case TOPIC:
|
||||
expressions[i] = maker.Literal(loggerTopic);
|
||||
expressions[i] = (JCExpression) loggerTopic.clone();
|
||||
break;
|
||||
case NULL:
|
||||
expressions[i] = maker.Literal(CTC_BOT, null);
|
||||
@@ -156,7 +159,7 @@ public class HandleLog {
|
||||
public static class HandleCommonsLog extends JavacAnnotationHandler<lombok.extern.apachecommons.CommonsLog> {
|
||||
@Override public void handle(AnnotationValues<lombok.extern.apachecommons.CommonsLog> annotation, JCAnnotation ast, JavacNode annotationNode) {
|
||||
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_COMMONS_FLAG_USAGE, "@apachecommons.CommonsLog", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
|
||||
processAnnotation(LoggingFramework.COMMONS, annotation, annotationNode, annotation.getInstance().topic());
|
||||
processAnnotation(LoggingFramework.COMMONS, annotation, annotationNode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,7 +170,7 @@ public class HandleLog {
|
||||
public static class HandleJulLog extends JavacAnnotationHandler<lombok.extern.java.Log> {
|
||||
@Override public void handle(AnnotationValues<lombok.extern.java.Log> annotation, JCAnnotation ast, JavacNode annotationNode) {
|
||||
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_JUL_FLAG_USAGE, "@java.Log", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
|
||||
processAnnotation(LoggingFramework.JUL, annotation, annotationNode, annotation.getInstance().topic());
|
||||
processAnnotation(LoggingFramework.JUL, annotation, annotationNode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,7 +181,7 @@ public class HandleLog {
|
||||
public static class HandleLog4jLog extends JavacAnnotationHandler<lombok.extern.log4j.Log4j> {
|
||||
@Override public void handle(AnnotationValues<lombok.extern.log4j.Log4j> annotation, JCAnnotation ast, JavacNode annotationNode) {
|
||||
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_LOG4J_FLAG_USAGE, "@Log4j", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
|
||||
processAnnotation(LoggingFramework.LOG4J, annotation, annotationNode, annotation.getInstance().topic());
|
||||
processAnnotation(LoggingFramework.LOG4J, annotation, annotationNode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,7 +192,7 @@ public class HandleLog {
|
||||
public static class HandleLog4j2Log extends JavacAnnotationHandler<lombok.extern.log4j.Log4j2> {
|
||||
@Override public void handle(AnnotationValues<lombok.extern.log4j.Log4j2> annotation, JCAnnotation ast, JavacNode annotationNode) {
|
||||
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_LOG4J2_FLAG_USAGE, "@Log4j2", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
|
||||
processAnnotation(LoggingFramework.LOG4J2, annotation, annotationNode, annotation.getInstance().topic());
|
||||
processAnnotation(LoggingFramework.LOG4J2, annotation, annotationNode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,7 +203,7 @@ public class HandleLog {
|
||||
public static class HandleSlf4jLog extends JavacAnnotationHandler<lombok.extern.slf4j.Slf4j> {
|
||||
@Override public void handle(AnnotationValues<lombok.extern.slf4j.Slf4j> annotation, JCAnnotation ast, JavacNode annotationNode) {
|
||||
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_SLF4J_FLAG_USAGE, "@Slf4j", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
|
||||
processAnnotation(LoggingFramework.SLF4J, annotation, annotationNode, annotation.getInstance().topic());
|
||||
processAnnotation(LoggingFramework.SLF4J, annotation, annotationNode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,7 +214,7 @@ public class HandleLog {
|
||||
public static class HandleXSlf4jLog extends JavacAnnotationHandler<lombok.extern.slf4j.XSlf4j> {
|
||||
@Override public void handle(AnnotationValues<lombok.extern.slf4j.XSlf4j> annotation, JCAnnotation ast, JavacNode annotationNode) {
|
||||
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_XSLF4J_FLAG_USAGE, "@XSlf4j", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
|
||||
processAnnotation(LoggingFramework.XSLF4J, annotation, annotationNode, annotation.getInstance().topic());
|
||||
processAnnotation(LoggingFramework.XSLF4J, annotation, annotationNode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,7 +225,7 @@ public class HandleLog {
|
||||
public static class HandleJBossLog extends JavacAnnotationHandler<lombok.extern.jbosslog.JBossLog> {
|
||||
@Override public void handle(AnnotationValues<lombok.extern.jbosslog.JBossLog> annotation, JCAnnotation ast, JavacNode annotationNode) {
|
||||
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_JBOSSLOG_FLAG_USAGE, "@JBossLog", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
|
||||
processAnnotation(LoggingFramework.JBOSSLOG, annotation, annotationNode, annotation.getInstance().topic());
|
||||
processAnnotation(LoggingFramework.JBOSSLOG, annotation, annotationNode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,7 +236,7 @@ public class HandleLog {
|
||||
public static class HandleFloggerLog extends JavacAnnotationHandler<lombok.extern.flogger.Flogger> {
|
||||
@Override public void handle(AnnotationValues<lombok.extern.flogger.Flogger> annotation, JCAnnotation ast, JavacNode annotationNode) {
|
||||
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_FLOGGER_FLAG_USAGE, "@Flogger", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
|
||||
processAnnotation(LoggingFramework.FLOGGER, annotation, annotationNode, "");
|
||||
processAnnotation(LoggingFramework.FLOGGER, annotation, annotationNode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -250,7 +253,7 @@ public class HandleLog {
|
||||
return;
|
||||
}
|
||||
LoggingFramework framework = new LoggingFramework(lombok.CustomLog.class, logDeclaration);
|
||||
processAnnotation(framework, annotation, annotationNode, annotation.getInstance().topic());
|
||||
processAnnotation(framework, annotation, annotationNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -304,7 +304,7 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
|
||||
java.util.List<Included<JavacNode, ToString.Include>> fieldNodes = new ArrayList<Included<JavacNode, ToString.Include>>();
|
||||
for (BuilderFieldData bfd : builderFields) {
|
||||
for (JavacNode f : bfd.createdFields) {
|
||||
fieldNodes.add(new Included<JavacNode, ToString.Include>(f, null, true));
|
||||
fieldNodes.add(new Included<JavacNode, ToString.Include>(f, null, true, false));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -354,8 +354,10 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
|
||||
}
|
||||
|
||||
// Generate a constructor in the annotated class that takes a builder as argument.
|
||||
generateBuilderBasedConstructor(cfv, tdParent, typeParams, builderFields, annotationNode, builderClassName,
|
||||
superclassBuilderClassExpression != null);
|
||||
if (!constructorExists(tdParent, builderClassName)) {
|
||||
generateBuilderBasedConstructor(cfv, tdParent, typeParams, builderFields, annotationNode, builderClassName,
|
||||
superclassBuilderClassExpression != null);
|
||||
}
|
||||
|
||||
if (isAbstract) {
|
||||
// Only non-abstract classes get the builder() and toBuilder() methods.
|
||||
@@ -375,14 +377,14 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
|
||||
if (toBuilder) {
|
||||
switch (methodExists(TO_BUILDER_METHOD_NAME, tdParent, 0)) {
|
||||
case EXISTS_BY_USER:
|
||||
annotationNode.addWarning("Not generating toBuilder() as it already exists.");
|
||||
return;
|
||||
break;
|
||||
case NOT_EXISTS:
|
||||
JCMethodDecl md = generateToBuilderMethod(cfv, builderClassName, builderImplClassName, annotationNode, tdParent, typeParams);
|
||||
if (md != null) {
|
||||
recursiveSetGeneratedBy(md, ast, annotationNode.getContext());
|
||||
injectMethod(tdParent, md);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// Should not happen.
|
||||
}
|
||||
@@ -1070,4 +1072,33 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
|
||||
}
|
||||
return typeParameter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if there is a manual constructor in the given type with a single parameter (builder).
|
||||
*/
|
||||
private boolean constructorExists(JavacNode type, String builderClassName) {
|
||||
if (type != null && type.get() instanceof JCClassDecl) {
|
||||
for (JCTree def : ((JCClassDecl)type.get()).defs) {
|
||||
if (def instanceof JCMethodDecl) {
|
||||
JCMethodDecl md = (JCMethodDecl) def;
|
||||
String name = md.name.toString();
|
||||
boolean matches = name.equals("<init>");
|
||||
if (isTolerate(type, md))
|
||||
continue;
|
||||
if (matches && md.params != null && md.params.length() == 1) {
|
||||
// Cannot use typeMatches() here, because the parameter could be fully-qualified, partially-qualified, or not qualified.
|
||||
// A string-compare of the last part should work. If it's a false-positive, users could still @Tolerate it.
|
||||
String typeName = md.params.get(0).getType().toString();
|
||||
int lastIndexOfDot = typeName.lastIndexOf('.');
|
||||
if (lastIndexOfDot >= 0) {
|
||||
typeName = typeName.substring(lastIndexOfDot+1);
|
||||
}
|
||||
if ((builderClassName+"<?, ?>").equals(typeName))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -110,7 +110,7 @@ public class HandleUtilityClass extends JavacAnnotationHandler<UtilityClass> {
|
||||
if (typeNode.up().getKind() == Kind.COMPILATION_UNIT) markStatic = false;
|
||||
if (markStatic && typeNode.up().getKind() == Kind.TYPE) {
|
||||
JCClassDecl typeDecl = (JCClassDecl) typeNode.up().get();
|
||||
if ((typeDecl.mods.flags & (Flags.INTERFACE | Flags.ANNOTATION | Flags.ENUM)) != 0) markStatic = false;
|
||||
if ((typeDecl.mods.flags & (Flags.INTERFACE | Flags.ANNOTATION)) != 0) markStatic = false;
|
||||
}
|
||||
|
||||
if (markStatic) classDecl.mods.flags |= Flags.STATIC;
|
||||
|
||||
@@ -234,7 +234,8 @@ public class HandleWith extends JavacAnnotationHandler<With> {
|
||||
long flags = JavacHandlerUtil.addFinalIfNeeded(Flags.PARAMETER, field.getContext());
|
||||
List<JCAnnotation> annsOnParam = copyAnnotations(onParam).appendList(copyableAnnotations);
|
||||
|
||||
JCVariableDecl param = maker.VarDef(maker.Modifiers(flags, annsOnParam), fieldDecl.name, fieldDecl.vartype, null);
|
||||
JCExpression pType = cloneType(maker, fieldDecl.vartype, source.get(), source.getContext());
|
||||
JCVariableDecl param = maker.VarDef(maker.Modifiers(flags, annsOnParam), fieldDecl.name, pType, null);
|
||||
|
||||
if (!makeAbstract) {
|
||||
ListBuffer<JCStatement> statements = new ListBuffer<JCStatement>();
|
||||
|
||||
@@ -40,6 +40,7 @@ import java.util.regex.Pattern;
|
||||
|
||||
import javax.lang.model.element.Element;
|
||||
|
||||
import com.sun.tools.javac.code.Attribute;
|
||||
import com.sun.tools.javac.code.BoundKind;
|
||||
import com.sun.tools.javac.code.Flags;
|
||||
import com.sun.tools.javac.code.Scope;
|
||||
@@ -1127,7 +1128,25 @@ public class JavacHandlerUtil {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static class JCAnnotationReflect {
|
||||
private static Field ATTRIBUTE;
|
||||
|
||||
static {
|
||||
try {
|
||||
ATTRIBUTE = Permit.getField(JCAnnotation.class, "attribute");
|
||||
} catch (Exception ignore) {}
|
||||
}
|
||||
|
||||
static Attribute.Compound getAttribute(JCAnnotation jcAnnotation) {
|
||||
try {
|
||||
return (Attribute.Compound) ATTRIBUTE.get(jcAnnotation);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// jdk9 support, types have changed, names stay the same
|
||||
static class ClassSymbolMembersField {
|
||||
private static final Field membersField;
|
||||
@@ -1178,8 +1197,10 @@ public class JavacHandlerUtil {
|
||||
* Also takes care of updating the JavacAST.
|
||||
*/
|
||||
public static void injectMethod(JavacNode typeNode, JCMethodDecl method, List<Type> paramTypes, Type returnType) {
|
||||
Context context = typeNode.getContext();
|
||||
Symtab symtab = Symtab.instance(context);
|
||||
JCClassDecl type = (JCClassDecl) typeNode.get();
|
||||
|
||||
|
||||
if (method.getName().contentEquals("<init>")) {
|
||||
//Scan for default constructor, and remove it.
|
||||
int idx = 0;
|
||||
@@ -1196,20 +1217,53 @@ public class JavacHandlerUtil {
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
addSuppressWarningsAll(method.mods, typeNode, method.pos, getGeneratedBy(method), typeNode.getContext());
|
||||
addGenerated(method.mods, typeNode, method.pos, getGeneratedBy(method), typeNode.getContext());
|
||||
type.defs = type.defs.append(method);
|
||||
|
||||
fixMethodMirror(typeNode.getContext(), typeNode.getElement(), method.getModifiers().flags, method.getName(), paramTypes, returnType);
|
||||
|
||||
|
||||
List<Symbol.VarSymbol> params = null;
|
||||
if (method.getParameters() != null && !method.getParameters().isEmpty()) {
|
||||
ListBuffer<Symbol.VarSymbol> newParams = new ListBuffer<Symbol.VarSymbol>();
|
||||
for (int i = 0; i < method.getParameters().size(); i++) {
|
||||
JCTree.JCVariableDecl param = method.getParameters().get(i);
|
||||
if (param.sym == null) {
|
||||
Type paramType = paramTypes == null ? param.getType().type : paramTypes.get(i);
|
||||
VarSymbol varSymbol = new VarSymbol(param.mods.flags, param.name, paramType, symtab.noSymbol);
|
||||
List<JCAnnotation> annotations = param.getModifiers().getAnnotations();
|
||||
if (annotations != null && !annotations.isEmpty()) {
|
||||
ListBuffer<Attribute.Compound> newAnnotations = new ListBuffer<Attribute.Compound>();
|
||||
for (JCAnnotation jcAnnotation : annotations) {
|
||||
Attribute.Compound attribute = JCAnnotationReflect.getAttribute(jcAnnotation);
|
||||
if (attribute != null) {
|
||||
newAnnotations.append(attribute);
|
||||
}
|
||||
}
|
||||
if (annotations.length() == newAnnotations.length()) {
|
||||
varSymbol.appendAttributes(newAnnotations.toList());
|
||||
}
|
||||
}
|
||||
newParams.append(varSymbol);
|
||||
} else {
|
||||
newParams.append(param.sym);
|
||||
}
|
||||
}
|
||||
params = newParams.toList();
|
||||
if (params.length() != method.getParameters().length()) params = null;
|
||||
}
|
||||
|
||||
fixMethodMirror(typeNode.getContext(), typeNode.getElement(), method.getModifiers().flags, method.getName(), paramTypes, params, returnType);
|
||||
|
||||
typeNode.add(method, Kind.METHOD);
|
||||
}
|
||||
|
||||
private static void fixMethodMirror(Context context, Element typeMirror, long access, Name methodName, List<Type> paramTypes, Type returnType) {
|
||||
|
||||
private static void fixMethodMirror(Context context, Element typeMirror, long access, Name methodName, List<Type> paramTypes, List<Symbol.VarSymbol> params, Type returnType) {
|
||||
if (typeMirror == null || paramTypes == null || returnType == null) return;
|
||||
ClassSymbol cs = (ClassSymbol) typeMirror;
|
||||
MethodSymbol methodSymbol = new MethodSymbol(access, methodName, new MethodType(paramTypes, returnType, List.<Type>nil(), Symtab.instance(context).methodClass), cs);
|
||||
if (params != null && !params.isEmpty()) {
|
||||
methodSymbol.params = params;
|
||||
}
|
||||
ClassSymbolMembersField.enter(cs, methodSymbol);
|
||||
}
|
||||
|
||||
@@ -1265,15 +1319,17 @@ public class JavacHandlerUtil {
|
||||
public static void addSuppressWarningsAll(JCModifiers mods, JavacNode node, int pos, JCTree source, Context context) {
|
||||
if (!LombokOptionsFactory.getDelombokOptions(context).getFormatPreferences().generateSuppressWarnings()) return;
|
||||
|
||||
boolean addJLSuppress = true;
|
||||
boolean addJLSuppress = !Boolean.FALSE.equals(node.getAst().readConfiguration(ConfigurationKeys.ADD_SUPPRESSWARNINGS_ANNOTATIONS));
|
||||
|
||||
for (JCAnnotation ann : mods.annotations) {
|
||||
JCTree type = ann.getAnnotationType();
|
||||
Name n = null;
|
||||
if (type instanceof JCIdent) n = ((JCIdent) type).name;
|
||||
else if (type instanceof JCFieldAccess) n = ((JCFieldAccess) type).name;
|
||||
if (n != null && n.contentEquals("SuppressWarnings")) {
|
||||
addJLSuppress = false;
|
||||
if (addJLSuppress) {
|
||||
for (JCAnnotation ann : mods.annotations) {
|
||||
JCTree type = ann.getAnnotationType();
|
||||
Name n = null;
|
||||
if (type instanceof JCIdent) n = ((JCIdent) type).name;
|
||||
else if (type instanceof JCFieldAccess) n = ((JCFieldAccess) type).name;
|
||||
if (n != null && n.contentEquals("SuppressWarnings")) {
|
||||
addJLSuppress = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (addJLSuppress) addAnnotation(mods, node, pos, source, context, "java.lang.SuppressWarnings", node.getTreeMaker().Literal("all"));
|
||||
@@ -1520,6 +1576,20 @@ public class JavacHandlerUtil {
|
||||
* Searches the given field node for annotations that are specifically intentioned to be copied to the setter.
|
||||
*/
|
||||
public static List<JCAnnotation> findCopyableToSetterAnnotations(JavacNode node) {
|
||||
return findAnnotationsInList(node, COPY_TO_SETTER_ANNOTATIONS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches the given field node for annotations that are specifically intentioned to be copied to the builder's singular method.
|
||||
*/
|
||||
public static List<JCAnnotation> findCopyableToBuilderSingularSetterAnnotations(JavacNode node) {
|
||||
return findAnnotationsInList(node, COPY_TO_BUILDER_SINGULAR_SETTER_ANNOTATIONS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches the given field node for annotations that are in the given list, and returns those.
|
||||
*/
|
||||
private static List<JCAnnotation> findAnnotationsInList(JavacNode node, java.util.List<String> annotationsToFind) {
|
||||
JCAnnotation anno = null;
|
||||
String annoName = null;
|
||||
for (JavacNode child : node.down()) {
|
||||
@@ -1537,7 +1607,7 @@ public class JavacHandlerUtil {
|
||||
if (annoName == null) return List.nil();
|
||||
|
||||
if (!annoName.isEmpty()) {
|
||||
for (String bn : COPY_TO_SETTER_ANNOTATIONS) if (typeMatches(bn, node, anno.annotationType)) return List.of(anno);
|
||||
for (String bn : annotationsToFind) if (typeMatches(bn, node, anno.annotationType)) return List.of(anno);
|
||||
}
|
||||
|
||||
ListBuffer<JCAnnotation> result = new ListBuffer<JCAnnotation>();
|
||||
@@ -1545,7 +1615,7 @@ public class JavacHandlerUtil {
|
||||
if (child.getKind() == Kind.ANNOTATION) {
|
||||
JCAnnotation annotation = (JCAnnotation) child.get();
|
||||
boolean match = false;
|
||||
if (!match) for (String bn : COPY_TO_SETTER_ANNOTATIONS) if (typeMatches(bn, node, annotation.annotationType)) {
|
||||
if (!match) for (String bn : annotationsToFind) if (typeMatches(bn, node, annotation.annotationType)) {
|
||||
result.append(annotation);
|
||||
break;
|
||||
}
|
||||
@@ -1935,6 +2005,7 @@ public class JavacHandlerUtil {
|
||||
}
|
||||
|
||||
private static final Pattern SECTION_FINDER = Pattern.compile("^\\s*\\**\\s*[-*][-*]+\\s*([GS]ETTER|WITH(?:ER)?)\\s*[-*][-*]+\\s*\\**\\s*$", Pattern.MULTILINE | Pattern.CASE_INSENSITIVE);
|
||||
private static final Pattern LINE_BREAK_FINDER = Pattern.compile("(\\r?\\n)?");
|
||||
|
||||
public static String stripLinesWithTagFromJavadoc(String javadoc, String regexpFragment) {
|
||||
Pattern p = Pattern.compile("^\\s*\\**\\s*" + regexpFragment + "\\s*\\**\\s*$", Pattern.MULTILINE | Pattern.CASE_INSENSITIVE);
|
||||
@@ -1943,27 +2014,29 @@ public class JavacHandlerUtil {
|
||||
}
|
||||
|
||||
public static String stripSectionsFromJavadoc(String javadoc) {
|
||||
Matcher m = SECTION_FINDER.matcher(javadoc);
|
||||
if (!m.find()) return javadoc;
|
||||
Matcher sectionMatcher = SECTION_FINDER.matcher(javadoc);
|
||||
if (!sectionMatcher.find()) return javadoc;
|
||||
|
||||
return javadoc.substring(0, m.start());
|
||||
return javadoc.substring(0, sectionMatcher.start());
|
||||
}
|
||||
|
||||
public static String getJavadocSection(String javadoc, String sectionNameSpec) {
|
||||
String[] sectionNames = sectionNameSpec.split("\\|");
|
||||
Matcher m = SECTION_FINDER.matcher(javadoc);
|
||||
Matcher sectionMatcher = SECTION_FINDER.matcher(javadoc);
|
||||
Matcher lineBreakMatcher = LINE_BREAK_FINDER.matcher(javadoc);
|
||||
int sectionStart = -1;
|
||||
int sectionEnd = -1;
|
||||
while (m.find()) {
|
||||
while (sectionMatcher.find()) {
|
||||
boolean found = false;
|
||||
for (String sectionName : sectionNames) if (m.group(1).equalsIgnoreCase(sectionName)) {
|
||||
for (String sectionName : sectionNames) if (sectionMatcher.group(1).equalsIgnoreCase(sectionName)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
if (found) {
|
||||
sectionStart = m.end() + 1;
|
||||
lineBreakMatcher.find(sectionMatcher.end());
|
||||
sectionStart = lineBreakMatcher.end();
|
||||
} else if (sectionStart != -1) {
|
||||
sectionEnd = m.start();
|
||||
sectionEnd = sectionMatcher.start();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -182,11 +182,12 @@ public class JavacSingularsRecipes {
|
||||
return this;
|
||||
}
|
||||
|
||||
protected JCModifiers makeMods(JavacTreeMaker maker, CheckerFrameworkVersion cfv, JavacNode node, boolean deprecate, AccessLevel access) {
|
||||
protected JCModifiers makeMods(JavacTreeMaker maker, CheckerFrameworkVersion cfv, JavacNode node, boolean deprecate, AccessLevel access, List<JCAnnotation> methodAnnotations) {
|
||||
JCAnnotation deprecateAnn = deprecate ? maker.Annotation(genJavaLangTypeRef(node, "Deprecated"), List.<JCExpression>nil()) : null;
|
||||
JCAnnotation rrAnn = cfv.generateReturnsReceiver() ? maker.Annotation(genTypeRef(node, CheckerFrameworkVersion.NAME__RETURNS_RECEIVER), List.<JCExpression>nil()) : null;
|
||||
|
||||
List<JCAnnotation> annsOnMethod = (deprecateAnn != null && rrAnn != null) ? List.of(deprecateAnn, rrAnn) : deprecateAnn != null ? List.of(deprecateAnn) : rrAnn != null ? List.of(rrAnn) : List.<JCAnnotation>nil();
|
||||
annsOnMethod = mergeAnnotations(annsOnMethod,methodAnnotations);
|
||||
return maker.Modifiers(toJavacModifier(access), annsOnMethod);
|
||||
}
|
||||
|
||||
@@ -271,10 +272,10 @@ public class JavacSingularsRecipes {
|
||||
generateClearMethod(cfv, deprecate, maker, returnTypeMaker.make(), returnStatementMaker.make(), data, builderType, source, access);
|
||||
}
|
||||
|
||||
private void finishAndInjectMethod(CheckerFrameworkVersion cfv, JavacTreeMaker maker, JCExpression returnType, JCStatement returnStatement, SingularData data, JavacNode builderType, JCTree source, boolean deprecate, ListBuffer<JCStatement> statements, Name methodName, List<JCVariableDecl> jcVariableDecls, AccessLevel access, Boolean ignoreNullCollections) {
|
||||
private void finishAndInjectMethod(CheckerFrameworkVersion cfv, JavacTreeMaker maker, JCExpression returnType, JCStatement returnStatement, SingularData data, JavacNode builderType, JCTree source, boolean deprecate, ListBuffer<JCStatement> statements, Name methodName, List<JCVariableDecl> jcVariableDecls, List<JCAnnotation> methodAnnotations, AccessLevel access, Boolean ignoreNullCollections) {
|
||||
if (returnStatement != null) statements.append(returnStatement);
|
||||
JCBlock body = maker.Block(0, statements.toList());
|
||||
JCModifiers mods = makeMods(maker, cfv, builderType, deprecate, access);
|
||||
JCModifiers mods = makeMods(maker, cfv, builderType, deprecate, access, methodAnnotations);
|
||||
List<JCTypeParameter> typeParams = List.nil();
|
||||
List<JCExpression> thrown = List.nil();
|
||||
|
||||
@@ -298,7 +299,7 @@ public class JavacSingularsRecipes {
|
||||
statements.add(clearStatement);
|
||||
|
||||
Name methodName = builderType.toName(HandlerUtil.buildAccessorName("clear", data.getPluralName().toString()));
|
||||
finishAndInjectMethod(cfv, maker, returnType, returnStatement, data, builderType, source, deprecate, statements, methodName, List.<JCVariableDecl>nil(), access, null);
|
||||
finishAndInjectMethod(cfv, maker, returnType, returnStatement, data, builderType, source, deprecate, statements, methodName, List.<JCVariableDecl>nil(), List.<JCAnnotation>nil(), access, null);
|
||||
}
|
||||
|
||||
protected abstract JCStatement generateClearStatements(JavacTreeMaker maker, SingularData data, JavacNode builderType);
|
||||
@@ -312,7 +313,8 @@ public class JavacSingularsRecipes {
|
||||
if (!setterPrefix.isEmpty()) name = builderType.toName(HandlerUtil.buildAccessorName(setterPrefix, name.toString()));
|
||||
|
||||
statements.prepend(createConstructBuilderVarIfNeeded(maker, data, builderType, source));
|
||||
finishAndInjectMethod(cfv, maker, returnType, returnStatement, data, builderType, source, deprecate, statements, name, params, access, null);
|
||||
List<JCAnnotation> methodAnnotations = copyAnnotations(findCopyableToBuilderSingularSetterAnnotations(data.annotation.up()));
|
||||
finishAndInjectMethod(cfv, maker, returnType, returnStatement, data, builderType, source, deprecate, statements, name, params, methodAnnotations, access, null);
|
||||
}
|
||||
|
||||
protected JCVariableDecl generateSingularMethodParameter(int typeIndex, JavacTreeMaker maker, SingularData data, JavacNode builderType, JCTree source, Name name) {
|
||||
@@ -357,8 +359,10 @@ public class JavacSingularsRecipes {
|
||||
} else {
|
||||
statements.prepend(JavacHandlerUtil.generateNullCheck(maker, null, data.getPluralName(), builderType, "%s cannot be null"));
|
||||
}
|
||||
|
||||
List<JCAnnotation> methodAnnotations = copyAnnotations(findCopyableToSetterAnnotations(data.annotation.up()));
|
||||
|
||||
finishAndInjectMethod(cfv, maker, returnType, returnStatement, data, builderType, source, deprecate, statements, name, List.of(param), access, ignoreNullCollections);
|
||||
finishAndInjectMethod(cfv, maker, returnType, returnStatement, data, builderType, source, deprecate, statements, name, List.of(param), methodAnnotations, access, ignoreNullCollections);
|
||||
}
|
||||
|
||||
protected ListBuffer<JCStatement> generatePluralMethodStatements(JavacTreeMaker maker, SingularData data, JavacNode builderType, JCTree source) {
|
||||
|
||||
File renamed without changes.
@@ -0,0 +1,157 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2020 The Project Lombok Authors.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package lombok.javac.apt;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.tools.FileObject;
|
||||
import javax.tools.JavaFileManager;
|
||||
import javax.tools.JavaFileObject;
|
||||
import javax.tools.JavaFileObject.Kind;
|
||||
|
||||
import com.sun.tools.javac.file.BaseFileManager;
|
||||
|
||||
class Java9Compiler implements lombok.javac.apt.LombokFileObjects.Compiler {
|
||||
private final BaseFileManager fileManager;
|
||||
|
||||
public Java9Compiler(JavaFileManager jfm) {
|
||||
fileManager = asBaseFileManager(jfm);
|
||||
}
|
||||
|
||||
@Override public JavaFileObject wrap(LombokFileObject fileObject) {
|
||||
Path p; try {
|
||||
p = toPath(fileObject);
|
||||
} catch (Exception e) {
|
||||
p = null;
|
||||
}
|
||||
|
||||
// J9BFOW extends javac's internal file base impl of javax.tools.JavaFileObject.
|
||||
// J9JFOW just straight implements it. Probably J9JFOW is fine, but we decided to extend java's internal impl possibly for a reason.
|
||||
// Some exotic build environments don't _have_ file objects and crash with FileNotFoundEx, so if that happens, let's try the alternative.
|
||||
if (p != null) return new Javac9BaseFileObjectWrapper(fileManager, p, fileObject);
|
||||
return new Javac9JavaFileObjectWrapper(fileObject);
|
||||
}
|
||||
|
||||
@Override public Method getDecoderMethod() {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Path toPath(LombokFileObject fileObject) {
|
||||
URI uri = fileObject.toUri();
|
||||
if (uri.getScheme() == null) {
|
||||
uri = URI.create("file:///" + uri);
|
||||
}
|
||||
try {
|
||||
return Paths.get(uri);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new IllegalArgumentException("Problems in URI '" + uri + "' (" + fileObject.toUri() + ")", e);
|
||||
}
|
||||
}
|
||||
|
||||
private static BaseFileManager asBaseFileManager(JavaFileManager jfm) {
|
||||
if (jfm instanceof BaseFileManager) {
|
||||
return (BaseFileManager) jfm;
|
||||
}
|
||||
return new FileManagerWrapper(jfm);
|
||||
}
|
||||
|
||||
static class FileManagerWrapper extends BaseFileManager {
|
||||
JavaFileManager manager;
|
||||
|
||||
public FileManagerWrapper(JavaFileManager manager) {
|
||||
super(null);
|
||||
this.manager = manager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int isSupportedOption(String option) {
|
||||
return manager.isSupportedOption(option);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassLoader getClassLoader(Location location) {
|
||||
return manager.getClassLoader(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<JavaFileObject> list(Location location, String packageName, Set<Kind> kinds, boolean recurse) throws IOException {
|
||||
return manager.list(location, packageName, kinds, recurse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String inferBinaryName(Location location, JavaFileObject file) {
|
||||
return manager.inferBinaryName(location, file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSameFile(FileObject a, FileObject b) {
|
||||
return manager.isSameFile(a, b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleOption(String current, Iterator<String> remaining) {
|
||||
return manager.handleOption(current, remaining);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasLocation(Location location) {
|
||||
return manager.hasLocation(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaFileObject getJavaFileForInput(Location location, String className, Kind kind) throws IOException {
|
||||
return manager.getJavaFileForInput(location, className, kind);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaFileObject getJavaFileForOutput(Location location, String className, Kind kind, FileObject sibling) throws IOException {
|
||||
return manager.getJavaFileForOutput(location, className, kind, sibling);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileObject getFileForInput(Location location, String packageName, String relativeName) throws IOException {
|
||||
return manager.getFileForInput(location, packageName, relativeName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileObject getFileForOutput(Location location, String packageName, String relativeName, FileObject sibling) throws IOException {
|
||||
return manager.getFileForOutput(location, packageName, relativeName, sibling);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() throws IOException {
|
||||
manager.flush();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
manager.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -188,12 +188,6 @@ public class PrettyPrinter extends JCTree.Visitor {
|
||||
return getEndPosition(tree, compilationUnit);
|
||||
}
|
||||
|
||||
private static int lineEndPos(String s, int start) {
|
||||
int pos = s.indexOf('\n', start);
|
||||
if (pos < 0) pos = s.length();
|
||||
return pos;
|
||||
}
|
||||
|
||||
private boolean needsAlign, needsNewLine, onNewLine = true, needsSpace, aligned;
|
||||
|
||||
public static final class UncheckedIOException extends RuntimeException {
|
||||
@@ -434,23 +428,25 @@ public class PrettyPrinter extends JCTree.Visitor {
|
||||
private void printDocComment(JCTree tree) {
|
||||
String dc = getJavadocFor(tree);
|
||||
if (dc == null) return;
|
||||
|
||||
aPrintln("/**");
|
||||
int pos = 0;
|
||||
int endpos = lineEndPos(dc, pos);
|
||||
boolean atStart = true;
|
||||
while (pos < dc.length()) {
|
||||
String line = dc.substring(pos, endpos);
|
||||
if (line.trim().isEmpty() && atStart) {
|
||||
|
||||
for (String line : dc.split("\\r?\\n")) {
|
||||
if (atStart && line.trim().isEmpty()) {
|
||||
atStart = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
atStart = false;
|
||||
aPrint(" *");
|
||||
if (pos < dc.length() && dc.charAt(pos) > ' ') print(" ");
|
||||
println(dc.substring(pos, endpos));
|
||||
pos = endpos + 1;
|
||||
endpos = lineEndPos(dc, pos);
|
||||
if (!line.isEmpty() && !Character.isWhitespace(line.charAt(0))) {
|
||||
print(" ");
|
||||
}
|
||||
|
||||
println(line);
|
||||
}
|
||||
|
||||
aPrintln(" */");
|
||||
}
|
||||
|
||||
@@ -796,8 +792,15 @@ public class PrettyPrinter extends JCTree.Visitor {
|
||||
print(tree.name);
|
||||
}
|
||||
|
||||
print("(");
|
||||
boolean first = true;
|
||||
print("(");
|
||||
|
||||
JCVariableDecl recvparam = readObject(tree, "recvparam", null);
|
||||
if (recvparam != null) {
|
||||
printVarDefInline(recvparam);
|
||||
first = false;
|
||||
}
|
||||
|
||||
for (JCVariableDecl param : tree.params) {
|
||||
if (!first) print(", ");
|
||||
first = false;
|
||||
@@ -1316,7 +1319,7 @@ public class PrettyPrinter extends JCTree.Visitor {
|
||||
print(";");
|
||||
needsNewLine = true;
|
||||
needsAlign = true;
|
||||
} else if (tree.stats.head.getClass().getSimpleName().equals("JCYield")) {
|
||||
} else if (tree.stats.head.getClass().getName().endsWith("$JCYield")) {
|
||||
print((JCExpression) readObject(tree.stats.head, "value", null));
|
||||
print(";");
|
||||
needsNewLine = true;
|
||||
@@ -1593,25 +1596,25 @@ public class PrettyPrinter extends JCTree.Visitor {
|
||||
}
|
||||
|
||||
@Override public void visitTree(JCTree tree) {
|
||||
String simpleName = tree.getClass().getSimpleName();
|
||||
if ("JCTypeUnion".equals(simpleName)) {
|
||||
String className = tree.getClass().getName();
|
||||
if (className.endsWith("$JCTypeUnion")) {
|
||||
List<JCExpression> types = readObject(tree, "alternatives", List.<JCExpression>nil());
|
||||
print(types, " | ");
|
||||
} else if ("JCTypeIntersection".equals(simpleName)) {
|
||||
} else if (className.endsWith("$JCTypeIntersection")) {
|
||||
print(readObject(tree, "bounds", List.<JCExpression>nil()), " & ");
|
||||
} else if ("JCMemberReference".equals(simpleName)) {
|
||||
} else if (className.endsWith("$JCMemberReference")) {
|
||||
printMemberReference0(tree);
|
||||
} else if ("JCLambda".equals(simpleName)) {
|
||||
} else if (className.endsWith("$JCLambda")) {
|
||||
printLambda0(tree);
|
||||
} else if ("JCAnnotatedType".equals(simpleName)) {
|
||||
} else if (className.endsWith("$JCAnnotatedType")) {
|
||||
printAnnotatedType0(tree);
|
||||
} else if ("JCPackageDecl".equals(simpleName)) {
|
||||
} else if (className.endsWith("$JCPackageDecl")) {
|
||||
// Starting with JDK9, this is inside the import list, but we've already printed it. Just ignore it.
|
||||
} else if ("JCSwitchExpression".equals(simpleName)) { // Introduced as preview feature in JDK12
|
||||
} else if (className.endsWith("$JCSwitchExpression")) { // Introduced as preview feature in JDK12
|
||||
printSwitchExpression(tree);
|
||||
} else if ("JCYield".equals(simpleName)) { // Introduced as preview feature in JDK13, part of switch expressions.
|
||||
} else if (className.endsWith("$JCYield")) { // Introduced as preview feature in JDK13, part of switch expressions.
|
||||
printYieldExpression(tree);
|
||||
} else if ("JCBindingPattern".equals(simpleName)) { // Introduced as preview in JDK14
|
||||
} else if (className.endsWith("$JCBindingPattern")) { // Introduced as preview in JDK14
|
||||
printBindingPattern(tree);
|
||||
} else {
|
||||
throw new AssertionError("Unhandled tree type: " + tree.getClass() + ": " + tree);
|
||||
@@ -1631,7 +1634,7 @@ public class PrettyPrinter extends JCTree.Visitor {
|
||||
if (o == null) return false;
|
||||
if (jcAnnotatedTypeInit) return jcAnnotatedTypeClass == o.getClass();
|
||||
Class<?> c = o.getClass();
|
||||
if (c.getSimpleName().equals("JCAnnotatedType")) {
|
||||
if (c.getName().endsWith("$JCAnnotatedType")) {
|
||||
jcAnnotatedTypeClass = c;
|
||||
jcAnnotatedTypeInit = true;
|
||||
return true;
|
||||
|
||||
@@ -103,6 +103,7 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
|
||||
patchIdentifierEndReparse(sm);
|
||||
patchRetrieveEllipsisStartPosition(sm);
|
||||
patchRetrieveRightBraceOrSemiColonPosition(sm);
|
||||
patchRetrieveProperRightBracketPosition(sm);
|
||||
patchSetGeneratedFlag(sm);
|
||||
patchDomAstReparseIssues(sm);
|
||||
patchHideGeneratedNodes(sm);
|
||||
@@ -445,6 +446,16 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
|
||||
// .transplant().request(StackRequest.RETURN_VALUE, StackRequest.PARAM2).build());
|
||||
}
|
||||
|
||||
private static void patchRetrieveProperRightBracketPosition(ScriptManager sm) {
|
||||
sm.addScript(ScriptBuilder.wrapMethodCall()
|
||||
.target(new MethodTarget("org.eclipse.jdt.core.dom.ASTConverter", "extractSubArrayType", "org.eclipse.jdt.core.dom.ArrayType", "org.eclipse.jdt.core.dom.ArrayType", "int", "int"))
|
||||
.methodToWrap(new Hook("org.eclipse.jdt.core.dom.ASTConverter", "retrieveProperRightBracketPosition", "int", "int", "int"))
|
||||
.wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "fixRetrieveProperRightBracketPosition", "int", "int", "org.eclipse.jdt.core.dom.ArrayType"))
|
||||
.requestExtra(StackRequest.PARAM1)
|
||||
.transplant()
|
||||
.build());
|
||||
}
|
||||
|
||||
private static void patchSetGeneratedFlag(ScriptManager sm) {
|
||||
sm.addScript(ScriptBuilder.addField()
|
||||
.targetClass("org.eclipse.jdt.internal.compiler.ast.ASTNode")
|
||||
@@ -564,6 +575,22 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
|
||||
.wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "setIsGeneratedFlagForName", "void",
|
||||
"org.eclipse.jdt.core.dom.Name", "java.lang.Object"))
|
||||
.transplant().build());
|
||||
|
||||
sm.addScript(ScriptBuilder.wrapMethodCall()
|
||||
.target(new MethodTarget("org.eclipse.jdt.core.dom.ASTConverter", "setTypeNameForAnnotation", "void", "org.eclipse.jdt.internal.compiler.ast.Annotation", "org.eclipse.jdt.core.dom.Annotation"))
|
||||
.methodToWrap(new Hook("org.eclipse.jdt.core.dom.SimpleName", "<init>", "void", "org.eclipse.jdt.core.dom.AST"))
|
||||
.requestExtra(StackRequest.PARAM1)
|
||||
.wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "setIsGeneratedFlagForName", "void",
|
||||
"org.eclipse.jdt.core.dom.Name", "java.lang.Object"))
|
||||
.transplant().build());
|
||||
|
||||
sm.addScript(ScriptBuilder.wrapMethodCall()
|
||||
.target(new MethodTarget("org.eclipse.jdt.core.dom.ASTConverter", "setTypeNameForAnnotation", "void", "org.eclipse.jdt.internal.compiler.ast.Annotation", "org.eclipse.jdt.core.dom.Annotation"))
|
||||
.methodToWrap(new Hook("org.eclipse.jdt.core.dom.QualifiedName", "<init>", "void", "org.eclipse.jdt.core.dom.AST"))
|
||||
.requestExtra(StackRequest.PARAM1)
|
||||
.wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "setIsGeneratedFlagForName", "void",
|
||||
"org.eclipse.jdt.core.dom.Name", "java.lang.Object"))
|
||||
.transplant().build());
|
||||
}
|
||||
|
||||
private static void patchAvoidReparsingGeneratedCode(ScriptManager sm) {
|
||||
|
||||
@@ -29,11 +29,14 @@ import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import lombok.core.AST.Kind;
|
||||
import lombok.eclipse.Eclipse;
|
||||
import lombok.eclipse.EclipseAST;
|
||||
import lombok.eclipse.EclipseNode;
|
||||
import lombok.eclipse.TransformEclipseAST;
|
||||
@@ -67,6 +70,7 @@ import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding;
|
||||
import org.eclipse.jdt.internal.compiler.lookup.BaseTypeBinding;
|
||||
import org.eclipse.jdt.internal.compiler.lookup.Binding;
|
||||
import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
|
||||
import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers;
|
||||
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
|
||||
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
|
||||
import org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding;
|
||||
@@ -214,7 +218,7 @@ public class PatchDelegate {
|
||||
addAllMethodBindings(methodsToExclude, cla.type.resolveType(decl.initializerScope), new HashSet<String>(), field.name, ann);
|
||||
}
|
||||
|
||||
Set<String> banList = new HashSet<String>();
|
||||
Set<String> banList = findAlreadyImplementedMethods(decl);
|
||||
for (BindingTuple excluded : methodsToExclude) banList.add(printSig(excluded.parameterized));
|
||||
|
||||
if (rawTypes.isEmpty()) {
|
||||
@@ -283,8 +287,8 @@ public class PatchDelegate {
|
||||
for (ClassLiteralAccess cla : excludedRawTypes) {
|
||||
addAllMethodBindings(methodsToExclude, cla.type.resolveType(decl.initializerScope), new HashSet<String>(), method.selector, ann);
|
||||
}
|
||||
|
||||
Set<String> banList = new HashSet<String>();
|
||||
|
||||
Set<String> banList = findAlreadyImplementedMethods(decl);
|
||||
for (BindingTuple excluded : methodsToExclude) banList.add(printSig(excluded.parameterized));
|
||||
|
||||
if (rawTypes.isEmpty()) {
|
||||
@@ -317,6 +321,8 @@ public class PatchDelegate {
|
||||
|
||||
private static boolean isDelegate(Annotation ann, TypeDeclaration decl) {
|
||||
if (ann.type == null) return false;
|
||||
if (!charArrayEquals("Delegate", ann.type.getLastToken())) return false;
|
||||
|
||||
TypeBinding tb = ann.type.resolveType(decl.initializerScope);
|
||||
if (tb == null) return false;
|
||||
if (!charArrayEquals("lombok", tb.qualifiedPackageName()) && !charArrayEquals("lombok.experimental", tb.qualifiedPackageName())) return false;
|
||||
@@ -764,6 +770,21 @@ public class PatchDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
private static Set<String> findAlreadyImplementedMethods(TypeDeclaration decl) {
|
||||
Set<String> sigs = new HashSet<String>();
|
||||
for (AbstractMethodDeclaration md : decl.methods) {
|
||||
if (md.isStatic()) continue;
|
||||
if ((md.modifiers & ClassFileConstants.AccBridge) != 0) continue;
|
||||
if (md.isConstructor()) continue;
|
||||
if ((md.modifiers & ExtraCompilerModifiers.AccDefaultAbstract) != 0) continue;
|
||||
if ((md.modifiers & ClassFileConstants.AccPublic) == 0) continue;
|
||||
if ((md.modifiers & ClassFileConstants.AccSynthetic) != 0) continue;
|
||||
|
||||
sigs.add(printSig(md, decl.scope));
|
||||
}
|
||||
return sigs;
|
||||
}
|
||||
|
||||
private static final char[] STRING_LOMBOK = new char[] {'l', 'o', 'm', 'b', 'o', 'k'};
|
||||
private static final char[] STRING_EXPERIMENTAL = new char[] {'e', 'x', 'p', 'e', 'r', 'i', 'm', 'e', 'n', 't', 'a', 'l'};
|
||||
private static final char[] STRING_DELEGATE = new char[] {'D', 'e', 'l', 'e', 'g', 'a', 't', 'e'};
|
||||
@@ -839,6 +860,54 @@ public class PatchDelegate {
|
||||
return signature.toString();
|
||||
}
|
||||
|
||||
private static String printSig(AbstractMethodDeclaration md, ClassScope scope) {
|
||||
StringBuilder signature = new StringBuilder();
|
||||
|
||||
signature.append(md.selector);
|
||||
signature.append("(");
|
||||
boolean first = true;
|
||||
if (md.arguments != null) {
|
||||
TypeParameter[] typeParameters = md.typeParameters();
|
||||
Map<String, TypeParameter> typeParametersMap = new HashMap<String, TypeParameter>();
|
||||
if (typeParameters != null) {
|
||||
for (TypeParameter typeParameter : typeParameters) {
|
||||
typeParametersMap.put(new String(typeParameter.name), typeParameter);
|
||||
}
|
||||
}
|
||||
|
||||
for (Argument argument : md.arguments) {
|
||||
TypeBinding typeBinding = makeTypeBinding(argument.type, typeParametersMap, scope);
|
||||
|
||||
if (!first) signature.append(", ");
|
||||
first = false;
|
||||
signature.append(typeBindingToSignature(typeBinding));
|
||||
}
|
||||
}
|
||||
signature.append(")");
|
||||
|
||||
return signature.toString();
|
||||
}
|
||||
|
||||
private static TypeBinding makeTypeBinding(TypeReference typeReference, Map<String, TypeParameter> typeParametersMap, ClassScope scope) {
|
||||
char[][] typeName = typeReference.getTypeName();
|
||||
String typeNameString = Eclipse.toQualifiedName(typeName);
|
||||
|
||||
TypeParameter typeParameter = typeParametersMap.get(typeNameString);
|
||||
if (typeParameter != null) {
|
||||
if (typeParameter.type != null) {
|
||||
typeName = typeParameter.type.getTypeName();
|
||||
} else {
|
||||
typeName = TypeConstants.JAVA_LANG_OBJECT;
|
||||
}
|
||||
}
|
||||
|
||||
TypeBinding typeBinding = scope.getType(typeName, typeName.length);
|
||||
if (typeReference.dimensions() > 0) {
|
||||
typeBinding = scope.createArrayType(typeBinding, typeReference.dimensions());
|
||||
}
|
||||
return typeBinding;
|
||||
}
|
||||
|
||||
private static String typeBindingToSignature(TypeBinding binding) {
|
||||
binding = binding.erasure();
|
||||
if (binding != null && binding.isBaseType()) {
|
||||
|
||||
@@ -35,11 +35,13 @@ import org.eclipse.jdt.internal.compiler.ast.FunctionalExpression;
|
||||
import org.eclipse.jdt.internal.compiler.ast.ImportReference;
|
||||
import org.eclipse.jdt.internal.compiler.ast.LambdaExpression;
|
||||
import org.eclipse.jdt.internal.compiler.ast.LocalDeclaration;
|
||||
import org.eclipse.jdt.internal.compiler.ast.MessageSend;
|
||||
import org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference;
|
||||
import org.eclipse.jdt.internal.compiler.ast.SingleTypeReference;
|
||||
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
|
||||
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
|
||||
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
|
||||
import org.eclipse.jdt.internal.compiler.impl.Constant;
|
||||
import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
|
||||
import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding;
|
||||
import org.eclipse.jdt.internal.compiler.lookup.Binding;
|
||||
@@ -227,14 +229,16 @@ public class PatchVal {
|
||||
boolean var = isVar(local, scope);
|
||||
if (!(val || var)) return false;
|
||||
|
||||
StackTraceElement[] st = new Throwable().getStackTrace();
|
||||
for (int i = 0; i < st.length - 2 && i < 10; i++) {
|
||||
if (st[i].getClassName().equals("lombok.launch.PatchFixesHider$Val")) {
|
||||
boolean valInForStatement = val &&
|
||||
st[i + 1].getClassName().equals("org.eclipse.jdt.internal.compiler.ast.LocalDeclaration") &&
|
||||
st[i + 2].getClassName().equals("org.eclipse.jdt.internal.compiler.ast.ForStatement");
|
||||
if (valInForStatement) return false;
|
||||
break;
|
||||
if (val) {
|
||||
StackTraceElement[] st = new Throwable().getStackTrace();
|
||||
for (int i = 0; i < st.length - 2 && i < 10; i++) {
|
||||
if (st[i].getClassName().equals("lombok.launch.PatchFixesHider$Val")) {
|
||||
boolean valInForStatement =
|
||||
st[i + 1].getClassName().equals("org.eclipse.jdt.internal.compiler.ast.LocalDeclaration") &&
|
||||
st[i + 2].getClassName().equals("org.eclipse.jdt.internal.compiler.ast.ForStatement");
|
||||
if (valInForStatement) return false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -264,6 +268,7 @@ public class PatchVal {
|
||||
}
|
||||
|
||||
TypeBinding resolved = null;
|
||||
Constant oldConstant = init.constant;
|
||||
try {
|
||||
resolved = decomponent ? getForEachComponentType(init, scope) : resolveForExpression(init, scope);
|
||||
} catch (NullPointerException e) {
|
||||
@@ -280,6 +285,10 @@ public class PatchVal {
|
||||
} catch (Exception e) {
|
||||
// Some type thing failed.
|
||||
}
|
||||
} else {
|
||||
if (init instanceof MessageSend && ((MessageSend) init).actualReceiverType == null) {
|
||||
init.constant = oldConstant;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.eclipse.jdt.core.IField;
|
||||
import org.eclipse.jdt.core.IMethod;
|
||||
import org.eclipse.jdt.core.IType;
|
||||
import org.eclipse.jdt.core.JavaModelException;
|
||||
import org.eclipse.jdt.core.dom.ArrayType;
|
||||
import org.eclipse.jdt.core.dom.MethodDeclaration;
|
||||
import org.eclipse.jdt.core.dom.SimpleName;
|
||||
import org.eclipse.jdt.core.search.SearchMatch;
|
||||
@@ -517,6 +518,12 @@ final class PatchFixesHider {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static int fixRetrieveProperRightBracketPosition(int retVal, ArrayType arrayType) {
|
||||
if (retVal != -1 || arrayType == null) return retVal;
|
||||
if (isGenerated(arrayType)) return arrayType.getStartPosition() + arrayType.getLength() - 1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static final int ALREADY_PROCESSED_FLAG = 0x800000; //Bit 24
|
||||
|
||||
public static boolean checkBit24(Object node) throws Exception {
|
||||
|
||||
@@ -66,7 +66,7 @@ public abstract class IdeLocation {
|
||||
}
|
||||
|
||||
private static final String LEGAL_PATH_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_/";
|
||||
private static final String LEGAL_PATH_CHARS_WINDOWS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_/:\\ ";
|
||||
private static final String LEGAL_PATH_CHARS_WINDOWS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,/;'[]{}!@#$^&()-_+= :\\";
|
||||
public static String escapePath(String path) {
|
||||
StringBuilder out = new StringBuilder();
|
||||
String legalChars = OsUtils.getOS() == OsUtils.OS.UNIX ? LEGAL_PATH_CHARS : LEGAL_PATH_CHARS_WINDOWS;
|
||||
|
||||
@@ -321,8 +321,9 @@ class ShadowClassLoader extends ClassLoader {
|
||||
}
|
||||
|
||||
private static String urlDecode(String in) {
|
||||
final String plusFixed = in.replaceAll("\\+", "%2B");
|
||||
try {
|
||||
return URLDecoder.decode(in, "UTF-8");
|
||||
return URLDecoder.decode(plusFixed, "UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new InternalError("UTF-8 not supported");
|
||||
}
|
||||
|
||||
@@ -18,12 +18,13 @@ import javax.lang.model.element.TypeParameterElement;
|
||||
import javax.lang.model.element.VariableElement;
|
||||
import javax.lang.model.type.TypeMirror;
|
||||
|
||||
import com.sun.tools.javac.util.List;
|
||||
import com.sun.tools.javac.util.Name;
|
||||
|
||||
public abstract class Symbol implements Element {
|
||||
public Type type;
|
||||
public Name name;
|
||||
|
||||
|
||||
public long flags() { return 0; }
|
||||
public boolean isStatic() { return false; }
|
||||
public boolean isConstructor() { return false; }
|
||||
@@ -37,10 +38,13 @@ public abstract class Symbol implements Element {
|
||||
@Override public Name getSimpleName() { return null; }
|
||||
@Override public java.util.List<Symbol> getEnclosedElements() { return null; }
|
||||
@Override public Element getEnclosingElement() { return null; }
|
||||
|
||||
public void appendAttributes(List<Attribute.Compound> l) {
|
||||
}
|
||||
|
||||
public static abstract class TypeSymbol extends Symbol {}
|
||||
|
||||
public static class MethodSymbol extends Symbol implements ExecutableElement {
|
||||
public List<Symbol.VarSymbol> params = null;
|
||||
public MethodSymbol(long flags, Name name, Type type, Symbol owner) {}
|
||||
@Override public ElementKind getKind() { return null; }
|
||||
@Override public Set<Modifier> getModifiers() { return null; }
|
||||
@@ -58,6 +62,8 @@ public abstract class Symbol implements Element {
|
||||
|
||||
public static class VarSymbol extends Symbol implements VariableElement {
|
||||
public Type type;
|
||||
public VarSymbol(long flags, Name name, Type type, Symbol owner) {
|
||||
}
|
||||
@Override public ElementKind getKind() { return null; }
|
||||
@Override public Set<Modifier> getModifiers() { return null; }
|
||||
@Override public <R, P> R accept(ElementVisitor<R, P> v, P p) { return null; }
|
||||
|
||||
@@ -5,6 +5,7 @@ package com.sun.tools.javac.code;
|
||||
|
||||
import com.sun.tools.javac.code.Symbol.ClassSymbol;
|
||||
import com.sun.tools.javac.code.Symbol.ModuleSymbol;
|
||||
import com.sun.tools.javac.code.Symbol.TypeSymbol;
|
||||
import com.sun.tools.javac.util.Context;
|
||||
|
||||
public class Symtab {
|
||||
@@ -14,6 +15,7 @@ public class Symtab {
|
||||
public Type objectType;
|
||||
public static Symtab instance(Context context) {return null;}
|
||||
public Type unknownType;
|
||||
public TypeSymbol noSymbol;
|
||||
|
||||
// JDK 9
|
||||
public ModuleSymbol unnamedModule;
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package java.lang.annotation;
|
||||
|
||||
/**
|
||||
* The constants of this enumerated type provide a simple classification of the
|
||||
* syntactic locations where annotations may appear in a Java program. These
|
||||
* constants are used in {@link java.lang.annotation.Target Target}
|
||||
* meta-annotations to specify where it is legal to write annotations of a
|
||||
* given type.
|
||||
*
|
||||
* <p>The syntactic locations where annotations may appear are split into
|
||||
* <em>declaration contexts</em> , where annotations apply to declarations, and
|
||||
* <em>type contexts</em> , where annotations apply to types used in
|
||||
* declarations and expressions.
|
||||
*
|
||||
* <p>The constants {@link #ANNOTATION_TYPE}, {@link #CONSTRUCTOR}, {@link
|
||||
* #FIELD}, {@link #LOCAL_VARIABLE}, {@link #METHOD}, {@link #PACKAGE}, {@link
|
||||
* #MODULE}, {@link #PARAMETER}, {@link #TYPE}, and {@link #TYPE_PARAMETER}
|
||||
* correspond to the declaration contexts in JLS 9.6.4.1.
|
||||
*
|
||||
* <p>For example, an annotation whose type is meta-annotated with
|
||||
* {@code @Target(ElementType.FIELD)} may only be written as a modifier for a
|
||||
* field declaration.
|
||||
*
|
||||
* <p>The constant {@link #TYPE_USE} corresponds to the type contexts in JLS
|
||||
* 4.11, as well as to two declaration contexts: type declarations (including
|
||||
* annotation type declarations) and type parameter declarations.
|
||||
*
|
||||
* <p>For example, an annotation whose type is meta-annotated with
|
||||
* {@code @Target(ElementType.TYPE_USE)} may be written on the type of a field
|
||||
* (or within the type of the field, if it is a nested, parameterized, or array
|
||||
* type), and may also appear as a modifier for, say, a class declaration.
|
||||
*
|
||||
* <p>The {@code TYPE_USE} constant includes type declarations and type
|
||||
* parameter declarations as a convenience for designers of type checkers which
|
||||
* give semantics to annotation types. For example, if the annotation type
|
||||
* {@code NonNull} is meta-annotated with
|
||||
* {@code @Target(ElementType.TYPE_USE)}, then {@code @NonNull}
|
||||
* {@code class C {...}} could be treated by a type checker as indicating that
|
||||
* all variables of class {@code C} are non-null, while still allowing
|
||||
* variables of other classes to be non-null or not non-null based on whether
|
||||
* {@code @NonNull} appears at the variable's declaration.
|
||||
*
|
||||
* @author Joshua Bloch
|
||||
* @since 1.5
|
||||
* @jls 9.6.4.1 @Target
|
||||
* @jls 4.1 The Kinds of Types and Values
|
||||
*/
|
||||
public enum ElementType {
|
||||
/** Class, interface (including annotation type), or enum declaration */
|
||||
TYPE,
|
||||
|
||||
/** Field declaration (includes enum constants) */
|
||||
FIELD,
|
||||
|
||||
/** Method declaration */
|
||||
METHOD,
|
||||
|
||||
/** Formal parameter declaration */
|
||||
PARAMETER,
|
||||
|
||||
/** Constructor declaration */
|
||||
CONSTRUCTOR,
|
||||
|
||||
/** Local variable declaration */
|
||||
LOCAL_VARIABLE,
|
||||
|
||||
/** Annotation type declaration */
|
||||
ANNOTATION_TYPE,
|
||||
|
||||
/** Package declaration */
|
||||
PACKAGE,
|
||||
|
||||
/**
|
||||
* Type parameter declaration
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
TYPE_PARAMETER,
|
||||
|
||||
/**
|
||||
* Use of a type
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
TYPE_USE,
|
||||
|
||||
/**
|
||||
* Module declaration.
|
||||
*
|
||||
* @since 9
|
||||
*/
|
||||
MODULE
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package java.nio.file;
|
||||
|
||||
public class Path {
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
These classes are not part of lombok itself, but used during the build. For example:
|
||||
* Code to turn the changelog into HTML ready to ship to projectlombok.org
|
||||
* Code to create eclipse debug targets
|
||||
|
||||
File renamed without changes.
@@ -0,0 +1,194 @@
|
||||
package lombok.eclipseCreate;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class CreateEclipseDebugTarget {
|
||||
private Map<String, String> args;
|
||||
private StringBuilder launchContent = new StringBuilder();
|
||||
|
||||
private static class InvalidCommandLineException extends Exception {
|
||||
InvalidCommandLineException(String msg) {
|
||||
super(msg);
|
||||
|
||||
}
|
||||
InvalidCommandLineException(String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
CreateEclipseDebugTarget instance = new CreateEclipseDebugTarget();
|
||||
try {
|
||||
instance.args = parseArgs(args);
|
||||
if (instance.args.isEmpty()) throw new InvalidCommandLineException("");
|
||||
instance.go();
|
||||
} catch (InvalidCommandLineException e) {
|
||||
String msg = e.getMessage();
|
||||
if (!msg.isEmpty()) System.err.println("ERROR: " + msg);
|
||||
if (e.getCause() != null) {
|
||||
e.getCause().printStackTrace();
|
||||
}
|
||||
printCommandLineHelp();
|
||||
System.exit(1);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
private void go() throws InvalidCommandLineException, IOException {
|
||||
prologue();
|
||||
classpath();
|
||||
epilogue();
|
||||
String n = getArgString("name");
|
||||
File f = new File(n + ".launch").getCanonicalFile();
|
||||
|
||||
OutputStream out = new FileOutputStream(f);
|
||||
try {
|
||||
out.write(launchContent.toString().getBytes("UTF-8"));
|
||||
} finally {
|
||||
out.close();
|
||||
}
|
||||
|
||||
System.out.println("Debug target created: " + f);
|
||||
}
|
||||
|
||||
private void prologue() throws InvalidCommandLineException {
|
||||
String type = getArgString("testType");
|
||||
|
||||
launchContent.append("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n");
|
||||
launchContent.append("<launchConfiguration type=\"org.eclipse.jdt.junit.launchconfig\">\n");
|
||||
launchContent.append("\t<listAttribute key=\"org.eclipse.debug.core.MAPPED_RESOURCE_PATHS\">\n");
|
||||
launchContent.append("\t\t<listEntry value=\"/lombok/test/core/src/").append(type.replace(".", "/")).append(".java\"/>\n");
|
||||
launchContent.append("\t</listAttribute>\n");
|
||||
launchContent.append("\t<listAttribute key=\"org.eclipse.debug.core.MAPPED_RESOURCE_TYPES\">\n");
|
||||
launchContent.append("\t\t<listEntry value=\"1\"/>\n");
|
||||
launchContent.append("\t</listAttribute>\n");
|
||||
|
||||
if (getArgBoolean("favorite")) {
|
||||
launchContent.append("\t<listAttribute key=\"org.eclipse.debug.ui.favoriteGroups\">\n");
|
||||
launchContent.append("\t\t<listEntry value=\"org.eclipse.debug.ui.launchGroup.debug\"/>\n");
|
||||
launchContent.append("\t</listAttribute>\n");
|
||||
}
|
||||
|
||||
launchContent.append("\t<stringAttribute key=\"org.eclipse.jdt.junit.CONTAINER\" value=\"\"/>\n");
|
||||
launchContent.append("\t<booleanAttribute key=\"org.eclipse.jdt.junit.KEEPRUNNING_ATTR\" value=\"false\"/>\n");
|
||||
launchContent.append("\t<stringAttribute key=\"org.eclipse.jdt.junit.TESTNAME\" value=\"\"/>\n");
|
||||
launchContent.append("\t<stringAttribute key=\"org.eclipse.jdt.junit.TEST_KIND\" value=\"org.eclipse.jdt.junit.loader.junit4\"/>\n");
|
||||
launchContent.append("\t<booleanAttribute key=\"org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD\" value=\"true\"/>\n");
|
||||
}
|
||||
|
||||
private void classpath() throws InvalidCommandLineException {
|
||||
launchContent.append("\t<listAttribute key=\"org.eclipse.jdt.launching.CLASSPATH\">\n");
|
||||
|
||||
String self; try {
|
||||
self = new File("..").getCanonicalPath();
|
||||
} catch (IOException e) {
|
||||
throw new InvalidCommandLineException("Cannot obtain canonical path to parent directory", e);
|
||||
}
|
||||
|
||||
String bootpath = getBootPath();
|
||||
|
||||
launchContent.append("\t\t<listEntry value=\"<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/lombok/bin" path="3" type="2"/> \"/>\n");
|
||||
for (Map.Entry<String, String> entry : args.entrySet()) {
|
||||
if (!entry.getKey().startsWith("conf.")) continue;
|
||||
String[] files = entry.getValue().split(Pattern.quote(File.pathSeparator));
|
||||
for (String file : files) {
|
||||
String n;
|
||||
try {
|
||||
n = new File(file).getCanonicalPath();
|
||||
} catch (IOException e) {
|
||||
throw new InvalidCommandLineException("Cannot obtain canonical path to dependency " + file, e);
|
||||
}
|
||||
if (n.startsWith(self)) {
|
||||
launchContent.append("\t\t<listEntry value=\"<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="");
|
||||
launchContent.append(n.substring(self.length()));
|
||||
launchContent.append("" path="3" type="2"/> \"/>\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (bootpath != null) launchContent.append("\t\t<listEntry value=\"<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/lombok/" + bootpath + "" path="5" type="2"/> \"/>\n");
|
||||
launchContent.append("\t</listAttribute>\n");
|
||||
}
|
||||
|
||||
private void epilogue() throws InvalidCommandLineException {
|
||||
String type = getArgString("testType");
|
||||
|
||||
launchContent.append("\t<booleanAttribute key=\"org.eclipse.jdt.launching.DEFAULT_CLASSPATH\" value=\"false\"/>\n");
|
||||
String jvmTarget = getArgString("jvmTarget");
|
||||
String bootpath = getBootPath();
|
||||
launchContent.append("\t<stringAttribute key=\"org.eclipse.jdt.launching.JRE_CONTAINER\" value=\"org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-").append(jvmTarget).append("\"/>\n");
|
||||
launchContent.append("\t<stringAttribute key=\"org.eclipse.jdt.launching.MAIN_TYPE\" value=\"").append(type).append("\"/>\n");
|
||||
launchContent.append("\t<listAttribute key=\"org.eclipse.jdt.launching.MODULEPATH\"/>\n");
|
||||
launchContent.append("\t<stringAttribute key=\"org.eclipse.jdt.launching.PROJECT_ATTR\" value=\"lombok\"/>\n");
|
||||
if (getArgBoolean("shadowLoaderBased")) {
|
||||
launchContent.append("<stringAttribute key=\"org.eclipse.jdt.launching.VM_ARGUMENTS\" value=\"-javaagent:dist/lombok.jar -Dshadow.override.lombok=${project_loc:lombok}/bin");
|
||||
for (Map.Entry<String, String> entry : args.entrySet()) {
|
||||
if (!entry.getKey().startsWith("conf.")) continue;
|
||||
launchContent.append(File.pathSeparator).append(entry.getValue());
|
||||
}
|
||||
if (bootpath != null) launchContent.append(" -Ddelombok.bootclasspath=" + bootpath);
|
||||
}
|
||||
launchContent.append("\"/>\n</launchConfiguration>\n");
|
||||
}
|
||||
|
||||
private String getBootPath() {
|
||||
String bp = args.get("bootpath");
|
||||
if (bp == null || bp.isEmpty() || bp.equals("0")) return null;
|
||||
File f = new File(bp);
|
||||
if (!f.isAbsolute()) return bp;
|
||||
String r = new File(".").getAbsolutePath();
|
||||
if (r.endsWith(".")) r = r.substring(0, r.length() - 1);
|
||||
if (bp.startsWith(r)) return bp.substring(r.length());
|
||||
throw new IllegalStateException("Cannot reconstruct relative path; base: " + r + " is not a parent of " + bp);
|
||||
}
|
||||
|
||||
private String getArgString(String key) throws InvalidCommandLineException {
|
||||
String v = args.get(key);
|
||||
if (v == null) throw new InvalidCommandLineException("mandatory argument '" + key + "' missing");
|
||||
return v;
|
||||
}
|
||||
|
||||
private boolean getArgBoolean(String key) throws InvalidCommandLineException {
|
||||
String v = args.get(key);
|
||||
if (v == null) return false;
|
||||
if (v.equalsIgnoreCase("false") || v.equalsIgnoreCase("f")) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void printCommandLineHelp() {
|
||||
System.err.println("CreateEclipseDebugTarget\n" +
|
||||
" name=Lombok-test BaseJavac 11 # Sets the name of the debug target to make\n" +
|
||||
" testType=lombok.RunJavacAndBaseTests # The test class file that this debug target should run\n" +
|
||||
" shadowLoaderBased # Add the VM options to use lombok as an agent and pass the classpath to the shadow loader. Needed for ECJ/Eclipse.\n" +
|
||||
" conf.test=foo:bar:baz # Where 'test' is an ivy conf name, and 'foo' is a path to a jar, relativized vs. current directory.\n" +
|
||||
" favorite # Should the debug target be marked as favourite?\n" +
|
||||
"");
|
||||
}
|
||||
|
||||
private static Map<String, String> parseArgs(String[] args) throws IllegalArgumentException {
|
||||
Map<String, String> map = new LinkedHashMap<String, String>();
|
||||
|
||||
for (String arg : args) {
|
||||
int idx = arg.indexOf('=');
|
||||
String key = (idx == -1 ? arg : arg.substring(0, idx)).trim();
|
||||
String value = (idx == -1 ? "" : arg.substring(idx + 1)).trim();
|
||||
String existing = map.get(key);
|
||||
if (existing != null) {
|
||||
if (key.startsWith("conf.")) {
|
||||
value = existing + File.pathSeparator + value;
|
||||
} else {
|
||||
throw new IllegalArgumentException("Duplicate argument not allowed: " + key);
|
||||
}
|
||||
}
|
||||
map.put(key, value);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
}
|
||||
Loaded 100 of 217 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user