I don't use intellij, but many of my colleagues do.I wonder is: https://github.com/bazelbuild/bazel/blob/master/scripts/setup-intellij.sh usable?
--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/c1af965c-96ae-4fff-a345-830637fb8fca%40googlegroups.com.
We are using a similar solution to Paul on my team. We also forked the official script from the bazel repository (https://github.com/bazelbuild/bazel/blob/master/scripts/setup-intellij.sh). Ours hacky script is posted below.
We are finding this solution workable but suboptimal. The main issue is that work needs to be manually mirrored in both bazel and IntelliJ (e.g. jvm_flags, working directories, generated sources).
We would love to see the development of an IntelliJ plugin. Based on these docs (http://www.jetbrains.org/intellij/sdk/docs/index.html), it seems possible. I also do see that a plugin has been development for facebook's similar tool, buck (https://github.com/wangyanxing/Buck-IntelliJ-Plugin).
Is anyone else interested in collaborating on such a plugin?
---
scripts/setup_intellij.sh (slightly redacted)
#!/bin/bash
# Copyright 2015 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Generates an IntelliJ project in Bazel.
set -o errexit
cd $(dirname "$0")
cd ..
bazel build //...
echo "Generating a bunch of xml files for intellij...very, very slowly :("
mkdir -p .idea/
# these directories contain manually managed .idea xml files, including shared runConfigurations, compiler.xml, encodings.xml, misc.xml and vcs.xml
cp -R scripts/resources/idea/* .idea/
cp -R scripts/resources/idea/*.* .idea/
cp -R scripts/resources/idea/.* .idea/
readonly compiler_file=.idea/compiler.xml
cat >$compiler_file <<'EOH'
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<excludeFromCompile>
EOH
cat >>$compiler_file <<'EOF'
</excludeFromCompile>
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
<entry name="!?*.aj" />
</wildcardResourcePatterns>
</component>
</project>
EOF
mkdir -p .idea/libraries
for jar in $(find -L bazel-bin -name '*.jar' | grep external); do
jarname=$(basename $jar)
library_xml=".idea/libraries/${jarname%.*}.xml"
cat > $library_xml <<EOF
<component name="libraryTable">
<library name="${jarname%.*}">
<CLASSES>
<root url="jar://\$PROJECT_DIR$/$jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>
EOF
done
cat > projectname.iml <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<content url="file://\$MODULE_DIR$">
<excludeFolder url="file://\$MODULE_DIR$/bazel-bin" />
<excludeFolder url="file://\$MODULE_DIR$/bazel-genfiles/external" />
<excludeFolder url="file://\$MODULE_DIR$/bazel-<projectname>-java" />
<excludeFolder url="file://\$MODULE_DIR$/bazel-out" />
<excludeFolder url="file://\$MODULE_DIR$/bazel-testlogs" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
EOF
# Start modules.xml
cat > .idea/modules.xml <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://\$PROJECT_DIR\$/<projectname>.iml" filepath="\$PROJECT_DIR\$/bazel.iml" />
EOF
# Note: these module names are managed manually
for module in <module names>; do
module_iml="${module}/${module}.iml"
cat > $module_iml <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<content url="file://\$MODULE_DIR$">
EOF
[[ -d $module/src/main/java ]] && cat >> $module_iml <<EOF
<sourceFolder url="file://\$MODULE_DIR$/src/main/java" isTestSource="false" />
EOF
[[ -d $module/src/test/java ]] && cat >> $module_iml <<EOF
<sourceFolder url="file://\$MODULE_DIR$/src/test/java" isTestSource="true" />
EOF
[[ -d $module/src/jooq/java ]] && cat >> $module_iml <<EOF
<sourceFolder url="file://\$MODULE_DIR$/src/jooq/java" isTestSource="false" />
EOF
[[ -d $module/src/main/resources ]] && cat >> $module_iml <<EOF
<sourceFolder url="file://\$MODULE_DIR$/src/main/resources" type="java-resource" />
EOF
[[ -d $module/src/test/resources ]] && cat >> $module_iml <<EOF
<sourceFolder url="file://\$MODULE_DIR$/src/test/resources" type="java-test-resource "/>
EOF
cat >> $module_iml <<EOF
</content>
EOF
if [[ -d bazel-genfiles/$module/src/main/java ]]; then
cat >> $module_iml <<EOF
<content url="file://\$MODULE_DIR$/../bazel-genfiles/$module">
<sourceFolder url="file://\$MODULE_DIR$/../bazel-genfiles/protos/src/main/java" isTestSource="false" generated="true" />
</content>
EOF
fi
cat >> $module_iml <<EOF
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
EOF
for module_dependency in $(bazel query "kind(\"java_library\", deps(//$module)) - //third-party:*" 2> /dev/null | cut -f2 -d:); do
cat >> $module_iml <<EOF
<orderEntry type="module" module-name="$module_dependency" />
EOF
done
for dependency in $(find -L bazel-bin -name '*.jar' | grep external); do
jarname=$(basename $dependency)
cat >> $module_iml <<EOF
<orderEntry type="library" name="${jarname%.*}" level="project" />
EOF
done
cat >> $module_iml <<EOF
</component>
</module>
EOF
cat >> .idea/modules.xml <<EOF
<module fileurl="file://\$PROJECT_DIR\$/$module/$module.iml" filepath="\$PROJECT_DIR\$/$module/$module.iml" />
EOF
done
# Finish modules.xml
cat >> .idea/modules.xml <<EOF
</modules>
</component>
</project>
EOF
--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/6d18ec9d-e5a5-420b-a8a6-8b247abaecc7%40googlegroups.com.
Also, intellij won't let you add the bazel generated srcjars as source jars. I've tried a few things to work around these two issues, but haven't had much luck (partially due to the fact that we ignore most of the bazel-* directories in intellij to reduce noise).
Does this work in the official plugin?
--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discuss+unsubscribe@googlegroups.com.To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/3ab23883-46fd-43f3-b363-75e2fbcaa0e4%40googlegroups.com.
On May 23, 2017 12:23 AM, "ittai zeidman" <itt...@gmail.com> wrote:Does this work in the official plugin?
I'd like to know as well. I don't use intellij myself by my coworkers will definitely want access to generated sources. We're not really looking for a gui to run bazel actions atm.
--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/3ab23883-46fd-43f3-b363-75e2fbcaa0e4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/CAJ2WPXhGbDY0ymLj4z7ELG7g42borQ84MUKOEqa2Pm-Cb4nZqQ%40mail.gmail.com.
It certainly should. If there are any issues, we have a separate bug tracker for the IntelliJ Bazel plugin at: https://github.com/bazelbuild/intellij/issues