Scriptlet and rules to replace bundled jars
authorLubomir Rintel <lkundrak@v3.sk>
Sat, 31 Oct 2009 11:02:57 +0000 (31 12:02 +0100)
committerLubomir Rintel <lkundrak@v3.sk>
Sun, 14 Mar 2010 00:20:12 +0000 (14 01:20 +0100)
This is kept separate from RPM to ease package development.
This is in a separate file and not in RPM scriptlet to ease the package
development.

replacedeps.sh [new file with mode: 0644]
replacerules.txt [new file with mode: 0644]

diff --git a/replacedeps.sh b/replacedeps.sh
new file mode 100644 (file)
index 0000000..8153a76
--- /dev/null
@@ -0,0 +1,40 @@
+set -e
+
+IMLS="$(find -name '*.iml')"
+
+awk '/^[^ \t#]/ {jar=$0} /^\t[^#]/ {print jar; print $0}' |
+while read ORIG
+do
+       read LINE
+       LINE="$(eval "echo $LINE")"
+
+       NEW=
+       for ENTRY in $LINE
+       do
+               if [ "$ENTRY" != :erase ]
+               then
+                       echo $ENTRY |grep -q ^/ || ENTRY=$(build-classpath $ENTRY)
+                       [ -f "$ENTRY" ] || echo "Replacement for $ORIG not found"
+                       [ -f "$ENTRY" ]
+                       NEW="$NEW $ENTRY"
+               fi
+       done
+
+       [ "$1" = -v ] && echo "$ORIG ==> $NEW" >/dev/stderr
+
+       #OPATH='jar://$PROJECT_DIR$/lib/'$ORIG'!/'
+       ORIG_BASE="$(echo "$ORIG" |sed 's,plugins/[^/]*/,,')"
+       OPATH='jar://[^"]*/'$ORIG_BASE'!/'
+       for FILE in $(grep -l "$OPATH" .idea/libraries/* $IMLS)
+       do
+               NEWCONTENT=;
+               for NEWFILE in $NEW
+               do
+                       NEWCONTENT="$NEWCONTENT $(sed -n "s|$OPATH|jar://$NEWFILE!/|p" $FILE |head -1)"
+               done
+               sed "s|.*$OPATH.*|$NEWCONTENT|" -i $FILE
+               sed '/:erase/d' -i $FILE
+       done
+
+       rm -rf $ORIG
+done
diff --git a/replacerules.txt b/replacerules.txt
new file mode 100644 (file)
index 0000000..7145f92
--- /dev/null
@@ -0,0 +1,294 @@
+# Rules for replacing bundled jars in IntelliJ IDEA source
+# Consumed by replacedeps.sh
+#
+# Entry format is:
+#
+# <original.jar>       (as referenced in .idea/libraries/*.xml)
+# <tab># <comment>     (ignored)
+# <tab>:erase          (the reference is just removed)
+# <tab><replacement>   (first expanded by shell. If it does not expand
+#                       to an absolute path, it is fed to build-classpath)
+
+lib/commons-codec-1.3.jar
+       commons-codec
+
+lib/commons-collections.jar
+       commons-collections
+
+lib/commons-lang-2.4.jar
+       commons-lang
+
+lib/commons-net-1.4.1.jar
+       jakarta-commons-net
+
+lib/jaxen-1.1.1.jar
+       jaxen
+
+lib/jdom.jar
+       jdom
+
+lib/jgoodies-forms.jar
+       jgoodies-forms
+
+lib/jna.jar
+       jna
+
+lib/velocity.jar
+       velocity
+
+lib/xerces.jar
+       xerces-j2
+
+lib/xmlrpc-2.0.jar
+       xmlrpc
+
+lib/junit.jar
+       junit
+
+lib/log4j.jar
+       log4j
+
+lib/looks-2.2.2.jar
+       jgoodies-looks
+
+lib/org.eclipse.jdt.core_3.4.4.v_894_R34x.jar
+       /usr/lib*/eclipse/dropins/jdt/plugins/org.eclipse.jdt.core_*.jar
+
+lib/asm.jar
+       objectweb-asm/asm
+
+lib/asm-commons.jar
+       objectweb-asm/asm-commons
+
+
+lib/groovy-all-1.6.3.jar
+       groovy
+
+lib/jh.jar
+       javahelp2
+
+lib/nanoxml-2.2.3.jar
+       nanoxml-2.2.3
+
+lib/picocontainer.jar
+       # https://bugzilla.redhat.com/show_bug.cgi?id=252119 dead review
+       # http://hany.sk/mirror/jpackage/1.7/generic/free/SRPMS/picocontainer-1.3-1jpp.src.rpm
+       # http://hany.sk/mirror/jpackage/1.7/generic/free/RPMS/picocontainer-1.3-1jpp.noarch.rpm
+       # proxytoys dependency
+       picocontainer
+
+lib/resolver.jar
+       xml-commons-resolver
+
+lib/trove4j.jar
+       # Locally patched 1.0.2 fork
+       # gnu-trove from jpackage is not sufficient
+       $PWD/trove4j/trove4j.jar
+
+lib/xbean.jar
+       xmlbeans/xbean
+
+lib/xstream.jar
+       xstream
+
+lib/junit-4.6.jar
+       # Need 4.6. 4.5, which is in rawhide is too old
+       junit4-4.6
+
+lib/cglib-nodep-2.1_3.jar
+       cglib objectweb-asm/asm
+
+lib/jsr173_1.0_api.jar
+       :erase
+
+lib/dev/easymockclassextension.jar
+       :erase
+
+lib/dev/easymock.jar
+       :erase
+
+lib/dev/jmock-1.0.1.jar
+       :erase
+
+lib/dev/jmock-cglib-1.0.1.jar
+       :erase
+
+lib/microba.jar
+       microba
+
+lib/oromatcher.jar
+       oro
+
+lib/eawtstub.jar
+       # http://netbeans.sourcearchive.com/documentation/6.1/dir_058efec17710427ed803a9cbd4a5c4fa.html
+       # Separately packaged
+       $PWD/eawtstub/dist/eawtstub.jar
+
+lib/jna-utils.jar
+       # The jna package needs to be patched!
+       jna-examples
+
+lib/serviceMessages.jar
+       # From jetbrains, soruce included
+       # XXX: needs idea jars to build, we need to bootstrap somehow!
+       
+lib/dev/compilerapi.jar
+       # Needs s/DefaultFileManager/JavacFileManager/ change in OpenJDK 1.6.0
+       ../jvm/java/lib/tools
+
+# Directories
+lib/src
+       :erase
+lib/ant
+       :erase
+lib/dev
+       :erase
+
+# ANT
+lib/ant/lib/ant-apache-oro.jar
+       ant/ant-apache-oro
+lib/ant/lib/ant-nodeps.jar
+       ant/ant-nodeps
+
+# These are in Fedora, but we don't seem to need them
+lib/ant/lib/ant-apache-resolver.jar
+       :erase
+lib/ant/lib/ant-commons-net.jar
+       :erase
+lib/ant/lib/ant.jar
+       :erase
+lib/ant/lib/ant-javamail.jar
+       :erase
+lib/ant/lib/ant-junit.jar
+       :erase
+lib/ant/lib/ant-antlr.jar
+       :erase
+lib/ant/lib/ant-jsch.jar
+       :erase
+lib/ant/lib/ant-jdepend.jar
+       :erase
+lib/ant/lib/ant-apache-bsf.jar
+       :erase
+lib/ant/lib/ant-swing.jar
+       :erase
+lib/ant/lib/ant-apache-log4j.jar
+       :erase
+lib/ant/lib/ant-apache-regexp.jar
+       :erase
+lib/ant/lib/ant-commons-logging.jar
+       :erase
+lib/ant/lib/ant-trax.jar
+       :erase
+lib/ant/lib/ant-apache-bcel.jar
+       :erase
+
+# These don't seem to be in Fedora
+lib/ant/lib/ant-jmf.jar
+       :erase
+lib/ant/lib/ant-jai.jar
+       :erase
+lib/ant/lib/ant-launcher.jar
+       :erase
+lib/ant/lib/libraries.properties
+       :erase
+lib/ant/lib/ant-testutil.jar
+       :erase
+lib/ant/lib/ant-starteam.jar
+       :erase
+lib/ant/lib/ant-weblogic.jar
+       :erase
+lib/ant/lib/xml-apis.jar
+       :erase
+lib/ant/lib/ant-stylebook.jar
+       :erase
+lib/ant/lib/xercesImpl.jar
+       :erase
+lib/ant/lib/ant-netrexx.jar
+       :erase
+
+# Modules
+
+# svn4idea
+
+# does this exist?
+lib/ganymed.jar
+       ganymed-ssh2
+
+plugins/svn4idea/lib/svnkit.jar
+       svnkit svnkit-javahl
+       
+plugins/svn4idea/lib/trilead.jar
+       trilead-ssh2
+
+plugins/svn4idea/lib/jna.jar
+       jna
+
+# testng
+
+plugins/testng/lib/testng-jdk14.jar
+       :erase
+
+plugins/testng/lib/testng-jdk15.jar
+       testng
+
+# maven (TODO!)
+
+plugins/maven/lib/archetype-common-2.0-alpha-4-SNAPSHOT.jar
+       :erase
+
+plugins/maven/lib/classworlds-1.1.jar
+       classworlds
+
+plugins/maven/lib/commons-beanutils.jar
+       commons-beanutils
+
+plugins/maven/lib/commons-logging-1.1.1.jar
+       commons-logging
+
+plugins/maven/lib/lucene-core-2.3.0.jar
+       lucene
+
+plugins/maven/lib/maven-2.2.0-uber.jar
+       :erase
+
+plugins/maven/lib/maven-embedder-idea-2.1.jar
+       :erase
+
+plugins/maven/lib/mercury-artifact-1.0-alpha-6.jar
+       mercury/artifact
+       
+plugins/maven/lib/nexus-indexer-1.0.0-SNAPSHOT.jar
+       :erase
+
+plugins/maven/lib/nexus-indexer-1.2.3.jar
+       :erase
+
+plugins/maven/lib/plexus-digest-1.1.jar
+       plexus/digest
+
+plugins/maven/lib/plexus-utils-1.5.1.jar
+       plexus/utils
+
+plugins/maven/lib/plexus-utils-1.5.5.jar
+       plexus/utils
+
+# cvs
+
+plugins/cvs/lib/trilead-ssh2-build213.jar
+       trilead-ssh2
+
+# git4idea
+
+plugins/git4idea/lib/trilead-ssh2.jar
+       trilead-ssh2
+
+# groovy
+
+plugins/groovy/lib/gradle-open-api-0.8.jar
+       gradle-open-api
+
+plugins/spellchecker/lib/patricia-trie-0.1.jar
+       patricia-trie
+
+plugins/spellchecker/lib/jazzy-core.jar
+       jazzy/jazzy-core