make.langtools.netbeans.nb-javac.build.xml Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nb-javac Show documentation
Show all versions of nb-javac Show documentation
"nb-javac" is a patched version of OpenJDK "javac", i.e., the Java compiler. This has long been part of NetBeans, providing a highly tuned Java compiler specifically for the Java editor i.e., parsing and lexing for features such as syntax coloring, code completion.
<?xml version="1.0" encoding="UTF-8"?> <!-- You may freely edit this file. See commented blocks below for --> <!-- some examples of how to customize the build. --> <!-- (If you delete it and reopen the project it will be recreated.) --> <project name="nb-javac" default="default" basedir="." xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" > <description>Builds, tests, and runs the project nb-javac.</description> <import file="nbproject/build-impl.xml"/> <!-- There exist several targets which are by default empty and which can be used for execution of your tasks. These targets are usually executed before and after some main targets. They are: -pre-init: called before initialization of project properties -post-init: called after initialization of project properties -pre-compile: called before javac compilation -post-compile: called after javac compilation -pre-compile-single: called before javac compilation of single file -post-compile-single: called after javac compilation of single file -pre-compile-test: called before javac compilation of JUnit tests -post-compile-test: called after javac compilation of JUnit tests -pre-compile-test-single: called before javac compilation of single JUnit test -post-compile-test-single: called after javac compilation of single JUunit test -pre-jar: called before JAR building -post-jar: called after JAR building -post-clean: called after cleaning build products (Targets beginning with '-' are not intended to be called on their own.) Example of inserting an obfuscator after compilation could look like this: <target name="-post-compile"> <obfuscate> <fileset dir="${build.classes.dir}"/> </obfuscate> </target> For list of available properties check the imported nbproject/build-impl.xml file. Another way to customize the build is by overriding existing main targets. The targets of interest are: -init-macrodef-javac: defines macro for javac compilation -init-macrodef-junit: defines macro for junit execution -init-macrodef-debug: defines macro for class debugging -init-macrodef-java: defines macro for class execution -do-jar-with-manifest: JAR building (if you are using a manifest) -do-jar-without-manifest: JAR building (if you are not using a manifest) run: execution of project -javadoc-build: Javadoc generation test-report: JUnit report generation An example of overriding the target for project execution could look like this: <target name="run" depends="nb-javac-impl.jar"> <exec dir="bin" executable="launcher.exe"> <arg file="${dist.jar}"/> </exec> </target> Notice that the overridden target depends on the jar target and not only on the compile target as the regular run target does. Again, for a list of available properties which you can use, check the target you are overriding in the nbproject/build-impl.xml file. --> <fail message="This build requires Ant version 1.9.9 at least!"> <condition> <not> <antversion atleast="1.9.9" /> </not> </condition> </fail> <property name="root" location="../../../.."/> <property name="jdk.repo" location="${root}/jdk"/> <property name="src.dir" location="${root}/src"/> <property name="tools.dir" location="${root}/lib"/> <target name="-check-jdk.is.available"> <available property="jdk.is.available" file="${jdk.repo}"/> </target> <target name="-check-jackpot.has.been.applied"> <available property="jackpot.has.been.applied" file="${src.dir}/jackpot-done"/> </target> <target name="-checkout-jdk" depends="-init-project,-check-jdk.is.available" unless="jdk.is.available"> <exec failonerror="true" executable="git" dir="${jdk.repo}/.."> <arg value="clone"/> <arg value="--depth=1"/> <arg value="--branch"/> <arg value="${jdk.git.commit}"/> <arg value="--single-branch"/> <arg value="${jdk.git.url}"/> <arg value="jdk"/> </exec> </target> <target name="-pre-init"> <mkdir dir="build/lib"/> <mkdir dir="${tools.dir}"/> <get dest="${tools.dir}/jackpot.jar" skipexisting="true" src="https://repo1.maven.org/maven2/org/apache/netbeans/modules/jackpot30/tool/12.5/tool-12.5.jar"/> <get dest="${tools.dir}/compiler.jar" skipexisting="true" src="https://repo1.maven.org/maven2/org/frgaal/compiler/19.0.0/compiler-19.0.0.jar"></get> <get dest="build/lib/junit-4.12.jar" skipexisting="true" src="https://repo1.maven.org/maven2/junit/junit/4.12/junit-4.12.jar"></get> <get dest="build/lib/hamcrest-core-1.3.jar" skipexisting="true" src="https://repo1.maven.org/maven2/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar"></get> </target> <target name="-post-init" depends="-checkout-jdk"> <available file="../../../../../nbbuild/netbeans/java/modules/ext" type="dir" property="modules.ext.exists"/> </target> <target name="propertiesparser" depends="jackpot"> <mkdir dir="${root}/lib/propertiesparser"/> <javac destdir="${root}/lib/propertiesparser" source="1.8" target="1.8" release="8" debug="true" srcdir="${jdk.repo}/make/langtools/tools/"> <include name="propertiesparser/**/*.java"/> </javac> <path id="propertiesparser"> <pathelement location="${root}/lib/propertiesparser"/> <pathelement location="${jdk.repo}/make/langtools/tools/"/> </path> <java failonerror="true" classpathref="propertiesparser" classname="propertiesparser.PropertiesParser"> <arg value="-compile"/> <arg value="${src.dir}/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties"/> <arg value="${src.dir}/jdk.compiler/share/classes/com/sun/tools/javac/resources/"/> </java> <java failonerror="true" classpathref="propertiesparser" classname="propertiesparser.PropertiesParser"> <arg value="-compile"/> <arg value="${src.dir}/jdk.compiler/share/classes/com/sun/tools/javac/resources/launcher.properties"/> <arg value="${src.dir}/jdk.compiler/share/classes/com/sun/tools/javac/resources/"/> </java> </target> <target name="-post-clean" unless="skip.jackpot.clean"> <delete dir="${src.dir}"/> </target> <target name="jackpot" depends="init,-check-jackpot.has.been.applied" unless="jackpot.has.been.applied"> <delete dir="${src.dir}"/> <mkdir dir="${src.dir}"/> <copy todir="${src.dir}"> <fileset dir="${jdk.repo}/src/"> <selector> <and> <or> <filename name="java.compiler/**"/> <filename name="jdk.compiler/**"/> <filename name="jdk.jdeps/share/classes/module-info.java"/> <filename name="jdk.jdeps/share/classes/com/sun/tools/classfile/**"/> <filename name="jdk.jdeps/share/classes/com/sun/tools/javap/**"/> </or> <containsregexp expression="particular *file *as *subject *to *the.*Classpath.*exception"/> </and> </selector> </fileset> </copy> <java fork="true" failonerror="true" classpath="${tools.dir}/jackpot.jar" classname="org.netbeans.modules.jackpot30.cmdline.Main"> <arg value="-hint-file"/> <arg value="${root}/make/langtools/netbeans/nb-javac/src/META-INF/upgrade/nbjavac.hint"/> <arg value="-sourcepath"/> <arg value="${root}/make/langtools/netbeans/nb-javac/src/:${src.dir}/jdk.compiler/share/classes/:${src.dir}/java.compiler/share/classes:${src.dir}/jdk.jdeps/share/classes"/> <arg value="-source"/> <arg value="8"/> <arg value="--apply"/> <arg value="${src.dir}/java.compiler/share/classes"/> <arg value="${src.dir}/jdk.compiler/share/classes"/> <arg value="${src.dir}/jdk.jdeps/share/classes"/> </java> <echo file="${src.dir}/jackpot-done">Jackpot done!</echo> </target> <target name="-pre-compile" depends="propertiesparser,jackpot"> <resources id="sun.reflect"> <javaresource name="sun/reflect/annotation/ExceptionProxy.class"/> <javaresource name="sun/reflect/annotation/AnnotationParser.class"/> <javaresource name="sun/reflect/annotation/AnnotationParser$1.class"/> <javaresource name="sun/reflect/annotation/AnnotationInvocationHandler.class"/> <javaresource name="sun/reflect/annotation/AnnotationType.class"/> <javaresource name="sun/reflect/annotation/EnumConstantNotPresentExceptionProxy.class"/> <javaresource name="sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.class"/> </resources> <mkdir dir="${tools.dir}/reflect/nbjavac/sun/annotation/"/> <copy todir="${tools.dir}/reflect/nbjavac/sun/annotation/" flatten="true" encoding="ISO-8859-1" outputencoding="ISO-8859-1" > <resources refid="sun.reflect"/> <filterchain> <replacestring from="sun/reflect/annotation/" to="nbjavac/sun/annotation/"/> </filterchain> </copy> <copy todir="${tools.dir}/reflect/"> <resources refid="sun.reflect"/> </copy> </target> <target name="-init-macrodef-javac"> <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3"> <attribute default="${src.src.dir}:${src.classes2.dir}:${src.classes3.dir}" name="srcdir"/> <attribute default="${build.classes.dir}" name="destdir"/> <attribute default="${javac.classpath}" name="classpath"/> <attribute default="${javac.modulepath}" name="modulepath"/> <attribute default="${javac.upgrademodulepath}" name="upgrademodulepath"/> <attribute default="${javac.processorpath}" name="processorpath"/> <attribute default="${build.generated.sources.dir}/ap-source-output" name="apgeneratedsrcdir"/> <attribute default="${includes}" name="includes"/> <attribute default="${excludes}" name="excludes"/> <attribute default="${javac.debug}" name="debug"/> <attribute default="${empty.dir}" name="sourcepath"/> <attribute default="${empty.dir}" name="gensrcdir"/> <element name="customize" optional="true"/> <sequential> <condition property="zdr.@{destdir}" value="test"> <equals arg1="build/test/classes" arg2="@{destdir}"/> </condition> <property name="zdr.@{destdir}" value="src,../../../../src/java.compiler/share/classes,../../../../src/jdk.compiler/share/classes,../../../../src/jdk.jdeps/share/classes"/> <property location="${build.dir}/empty" name="empty.dir"/> <mkdir dir="${empty.dir}"/> <multirootfileset id="zdr.@{destdir}" basedirs="${zdr.@{destdir}}"> <include name="**/*.java"/> <exclude name="**/module-info.java"/> <exclude name="com/sun/tools/javac/main/JavacToolProvider.java"/> <exclude name="com/sun/tools/sjavac/**"/> <exclude name="com/sun/tools/javap/Main.java"/> </multirootfileset> <pathconvert property="zdr.@{destdir}.list" refid="zdr.@{destdir}" pathsep=" "/> <exec failonerror="true" executable="${java.home}/bin/java"> <arg value="-jar"/> <arg value="${tools.dir}/compiler.jar"/> <arg line="${javac.compilerargs}"/> <arg value="-g"/> <arg value="-encoding"/> <arg value="UTF-8"/> <arg value="-cp"/> <arg value="${tools.dir}/reflect:@{classpath}"/> <arg value="-d"/> <arg value="@{destdir}"/> <arg value="--target"/> <arg value="1.8"/> <arg value="--source"/> <arg value="17"/> <arg value="--limit-modules"/> <arg value="java.base"/> <arg line="${zdr.@{destdir}.list}"/> </exec> </sequential> </macrodef> </target> <!-- suppress javadoc generation for this library, as its wrappers do it --> <target name="-javadoc-build"/> <target name="-separate-jars" depends="init"> <copy file="${build.classes.dir}/javax/lang/model/SourceVersion.class" tofile="${build.classes.dir}/META-INF/versions/11/javax/lang/model/SourceVersion.class" encoding="ISO-8859-1" outputencoding="ISO-8859-1" > <filterchain> <replacestring from="nbjavac/RuntimeWR$Version" to="java/lang/Runtime$Version"/> </filterchain> </copy> <jar destfile="${dist.dir}/nb-javac-${nb-javac-ver}-api.jar"> <manifest> <attribute name="Multi-Release" value="true"/> </manifest> <fileset dir="${build.classes.dir}"> <!-- <include name="com/sun/javadoc/**/*"/> --> <include name="com/sun/source/**/*"/> <include name="javax/lang/**/*"/> <include name="javax/tools/*"/> <include name="jdk/internal/PreviewFeature*"/> <include name="javax/annotation/**/*"/> <include name="META-INF/versions/**"/> </fileset> <fileset dir="${nb.javac.dir}"> <include name="README.md"/> <include name="LICENSE.tx"/> <include name="SECURITY.md"/> </fileset> </jar> <jar destfile="${dist.dir}/nb-javac-${nb-javac-ver}-impl.jar"> <fileset dir="${build.classes.dir}"> <include name="META-INF/services/**"/> <include name="com/sun/tools/**/*"/> <include name="jdk/internal/shellsupport/**/*"/> <include name="jdk/internal/PreviewFeature*"/> <include name="nbjavac/**"/> </fileset> <zipfileset src="${tools.dir}/compiler.jar" includes="META-INF/ct*/**"/> <fileset dir="${nb.javac.dir}"> <include name="README.md"/> <include name="LICENSE.tx"/> <include name="SECURITY.md"/> </fileset> <fileset dir="${tools.dir}/reflect/"> <include name="nbjavac/sun/annotation/*"/> </fileset> </jar> <delete file="${dist.jar}"/> </target> <available file="${java.home}/bin/javap" property="javap.exe" value="${java.home}/bin/javap"/> <available file="${java.home}/bin/javap.exe" property="javap.exe" value="${java.home}/bin/javap.exe"/> <target name="-verify-source-version-classes" depends="-separate-jars" if="javap.exe"> <exec executable="${javap.exe}" failonerror="true" outputproperty="javap.SourceVersion.old"> <arg value="-bootclasspath"></arg> <arg value="ignore"></arg> <arg value="-cp"></arg> <arg value="${dist.dir}/nb-javac-${nb-javac-ver}-api.jar"></arg> <arg value="javax.lang.model.SourceVersion"/> </exec> <exec executable="${javap.exe}" failonerror="true" outputproperty="javap.SourceVersion.new"> <arg value="-bootclasspath"></arg> <arg value="ignore"></arg> <arg value="--multi-release"></arg> <arg value="17"></arg> <arg value="-cp"></arg> <arg value="${dist.dir}/nb-javac-${nb-javac-ver}-api.jar"></arg> <arg value="javax.lang.model.SourceVersion"/> </exec> <fail message="Patched version of SourceVersion should be different!"> <condition> <equals arg1="${javap.SourceVersion.old}" arg2="${javap.SourceVersion.new}"/> </condition> </fail> <fail message="Patched version of SourceVersion shall contain Runtime.Version: ${javap.SourceVersion.new}"> <condition> <not> <contains string="${javap.SourceVersion.new}" substring="java.lang.Runtime$Version"/> </not> </condition> </fail> <echo message="JDK8 and JDK11 versions of javax.lang.model.SourceVersion verified successfully"/> </target> <target name="-copy-jars-to-build" if="modules.ext.exists"> <copy file="${dist.dir}/nb-javac-${nb-javac-ver}-api.jar" tofile="../../../../../nbbuild/netbeans/java/modules/ext/nb-javac-api.jar" /> <copy file="${dist.dir}/nb-javac-${nb-javac-ver}-impl.jar" tofile="../../../../../nbbuild/netbeans/java/modules/ext/nb-javac-impl.jar" /> <touch file="../../../../../nbbuild/netbeans/java/.lastModified" /> </target> <target name="-post-jar" depends="-post-init,-separate-jars,-verify-source-version-classes,-copy-jars-to-build"> </target> <target name="-pre-compile-test" depends="jar"/> <target name="zip-nb-javac-sources" depends="init"> <zip basedir="../../../../" destfile="dist/nb-javac-${nb-javac-ver}-sources.zip"> <exclude name="**/build/"/> <exclude name="**/dist/"/> <exclude name="**/nbproject/private/"/> <exclude name="**/nb-javac-sources.zip"/> <include name="src/jdk.compiler/**"/> <include name="src/java.compiler/**"/> <include name="src/jdk.jdeps/**"/> <include name="make/langtools/netbeans/nb-javac/**"/> <include name="README.md"/> <include name="SECURITY.md"/> <include name="LICENSE.txt"/> <include name=".hgignore"/> <include name=".hgtags"/> <include name="CONTRIBUTING.md"/> <include name="make/langtools/tools/**"/> <include name="make/langtools/build.xml"/> <include name="make/langtools/build.properties"/> </zip> </target> <!-- Publishing to maven central / OSSRH requires an account from sonatype. The credentials for this account need to be made available to maven using the configured id below. With the credentials configured, running ant publish-to-ossrh-snapshots will publish to the snapshot repository. ant publish-to-maven-central will publish into a staging repository, that needs to be manually released. --> <property name="maven-snapshots-repository-id" value="oss.sonatype.org" /> <property name="maven-snapshots-repository-url" value="https://oss.sonatype.org/content/repositories/snapshots/" /> <property name="maven-staging-repository-id" value="oss.sonatype.org" /> <property name="maven-staging-repository-url" value="https://oss.sonatype.org/service/local/staging/deploy/maven2/" /> <target name="-prepare-maven-version" depends="clean,jar"> <property name="maven.version" value="${nb-javac-ver}"/> </target> <target name="-prepare-maven-snapshot-version" depends="clean,jar"> <property name="maven.version" value="${nb-javac-ver}-SNAPSHOT"/> </target> <target name="-prepare-maven" depends="clean,jar,zip-nb-javac-sources"> <fail message="Version must be specified!" unless="maven.version"></fail> <fail message="Specify -Dmaven.groupId=..." unless="maven.groupId"></fail> <property name="mvn.exec" value="mvn"/> <property name="mvn.exec.args" value="-Dignore=true"/> <zip basedir="../../../../" destfile="dist/nb-javac-${nb-javac-ver}-doc.zip"> <include name="README.md"/> <include name="SECURITY.md"/> <include name="LICENSE.txt"/> <include name="CONTRIBUTING.md"/> </zip> <copy file="pom-nb-javac.xml" todir="build" /> <replaceregexp match="(<version>).*(</version>)" replace="\1${maven.version}\2" file="build/pom-nb-javac.xml"/> <replaceregexp match="(<groupId>).*(</groupId>)" replace="\1${maven.groupId}\2" file="build/pom-nb-javac.xml"/> </target> <target name="publish-to-ossrh-snapshots" description="Build nb-javac and publish to Snapshot Repository of OSSRH" depends="-prepare-maven-snapshot-version,-prepare-maven"> <property name="mvn.exec.output" location="build/maven-publish.log"/> <exec executable="${mvn.exec}" output="${mvn.exec.output}" resultproperty="mvn.exec.result" failonerror="false"> <arg value="org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy-file"/> <arg value="-Durl=${maven-snapshots-repository-url}"/> <arg value="-DrepositoryId=${maven-snapshots-repository-id}"/> <arg value="-DpomFile=build/pom-nb-javac.xml"/> <arg value="-Dfile=dist/nb-javac-${nb-javac-ver}-impl.jar"/> <arg value="-Dfiles=dist/nb-javac-${nb-javac-ver}-api.jar,dist/nb-javac-${nb-javac-ver}-sources.zip,dist/nb-javac-${nb-javac-ver}-doc.zip"/> <arg value="-Dtypes=jar,jar,jar" /> <arg value="-Dclassifiers=api,sources,javadoc" /> <arg value="-Dgpg.useagent=true"/> <arg line="${mvn.exec.args}" /> </exec> <fail message="Publishing to Maven failed with exec code ${mvn.exec.result}, see log at ${mvn.exec.output}"> <condition> <not> <equals arg1="0" arg2="${mvn.exec.result}"/> </not> </condition> </fail> </target> <target name="publish-to-maven-central" description="Build nb-javac and stage for maven central" depends="-prepare-maven-version,-prepare-maven"> <exec executable="${mvn.exec}" output="build/maven-publish.log" failonerror="true"> <arg value="org.apache.maven.plugins:maven-gpg-plugin:1.4:sign-and-deploy-file"/> <arg value="-Durl=${maven-staging-repository-url}"/> <arg value="-DrepositoryId=${maven-staging-repository-id}"/> <arg value="-DpomFile=build/pom-nb-javac.xml"/> <arg value="-Dfile=dist/nb-javac-${nb-javac-ver}-impl.jar"/> <arg value="-Dfiles=dist/nb-javac-${nb-javac-ver}-api.jar,dist/nb-javac-${nb-javac-ver}-sources.zip,dist/nb-javac-${nb-javac-ver}-doc.zip"/> <arg value="-Dtypes=jar,jar,jar" /> <arg value="-Dclassifiers=api,sources,javadoc" /> <arg value="-Dgpg.useagent=true"/> <arg line="${mvn.exec.args}" /> </exec> </target> </project>
© 2015 - 2025 Weber Informatics LLC | Privacy Policy