小编Dav*_* W.的帖子

如何在Ant build.xml文件中包含外部库?

在我的Java源代码中,我想使用存储在我的应用程序的"lib"目录中的java archives(.jar)中的不同类.但是,如果我做"蚂蚁运行",那么我总是得到一个"java.lang.NoClassDefFoundError"消息.我尝试了几件事来解决它,但没有任何效果......也许有人在这里可以帮助我吗?

这是我的build.properties文件:

app.name=MyApplication
app.version=1.0
main.class=mypackage.MyMain
build.dir=build
classes.dir=${build.dir}/classes
jar.dir=${build.dir}/jar
dist.dir=dist
src.dir=src
test.dir=test
lib.dir=lib
Run Code Online (Sandbox Code Playgroud)

这是我的build.xml:

<?xml version="1.0" encoding="UTF-8" ?>
<project name="My Project" default="run" basedir=".">
  <description>My description.</description>

  <property file="build.properties" />
  <path id="classpath">
    <fileset dir="${lib.dir}" includes="*.jar"/>
  </path>

    <!-- Initialization -->
  <target name="init" description="Prepare needed directories.">
    <mkdir dir="${build.dir}" />
    <mkdir dir="${classes.dir}" />
    <mkdir dir="${jar.dir}" />
    <mkdir dir="${dist.dir}" />
    <mkdir dir="${lib.dir}" />
  </target>

    <!-- Cleanup -->
  <target name="clean" description="Remove all files created by the build/test process.">
    <delete dir="${classes.dir}" />
    <delete dir="${dist.dir}" …
Run Code Online (Sandbox Code Playgroud)

apache ant build.xml properties libraries

6
推荐指数
1
解决办法
4万
查看次数

BMC补救整合

我在哪里可以找到BMC Remedy第三方集成列表?我在他们的网站上什么都没找到,他们的销售部门让我联系了我不打电话的客户服务,因为我没有客户编号.

我的公司正在考虑使用BMC Remedy作为客户事件系统,如果我能将它与某些软件集成,那将会很好.例如,我们可以有一个内部开发跟踪系统,如Jira,Redmine,MantisBT,Trak等,它们将与Remedy集成.或者,让Rememdy本身与Hudson或CruiseControl等集成.

到目前为止,我发现似乎没有任何东西可以与Remedy集成 - 即使是与Hudson和Jira等大量集成的软件包也是如此.我真的不在乎是否有第三方专有集成,但我想确保它们已经存在而不是所有你需要做的就是雇佣400美元来为你编程.我想,以确保有一些现在和不答应是可以做到的,然后找出你真的无法做到这一点.

integration remedy

6
推荐指数
2
解决办法
2万
查看次数

GNU Make.为什么这种复杂的语法生成依赖?

我正在阅读使用GNU Make管理项目,并在第2.7章 - 自动依赖关系生成中找到了这个例子.作者从GNU手册中说出了他们:

%.d: %c
        $(CC) -M $(CPPFLAGS $< > $@.$$$$; \
              sed s',\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
              rm -f $@.$$$$
Run Code Online (Sandbox Code Playgroud)

但是,我能够用这个做同样的事情(注意sed):

-include $(subst .c,.d,$(SOURCES))

%.d: %.c
          @$(CC) -M $(CPPFLAGS) $<  | sed 's|:| $*.d : |'  > $@;
Run Code Online (Sandbox Code Playgroud)

所有这些行都是生成依赖项,然后添加*.d名称.他们不得不改变第一行:

  foo.o: bar.h foo.h fubar.h
Run Code Online (Sandbox Code Playgroud)

to foo.o foo.d:bar.h foo.h fubar.h

我更简单,似乎工作得很好,但我认为GNU伙伴有他们sed命令的理由.也:

  • 为什么要将文件重定向到sed?为什么不简单地将它作为commond line参数
  • 为什么不完全跳过中间文件?

我知道GNU的人也可以想到这些,但出于某种原因,选择了更复杂的设置.我只是想了解他们的推理,所以我可以动态地做这些.

makefile gnu-make

6
推荐指数
2
解决办法
3953
查看次数

如何使用Test :: More测试STDERR?

我正在编写一些测试Test::More,并且我正在测试打印的功能之一STDERR.我想测试输出STDERR,但有点不确定如何做到这一点.我知道我很亲密.这有效:

use strict;
use warnings;
use feature qw(say);

close STDERR;
open STDERR, ">", \my $error_string;

say STDERR "This is my message";
say qq(The \$error_string is equal to "$error_string");
Run Code Online (Sandbox Code Playgroud)

打印出:

The $error_string is equal to "This is my message
"
Run Code Online (Sandbox Code Playgroud)

但是,我不想关闭STDERR.我只是想重复它.

我试过这个:

use strict;
use warnings;
use feature qw(say);

open my $error_fh, ">", my $error_string;
open STDERR, ">&", $error_fh;

say STDERR "This is my message";
close $error_fh;
say qq(The \$error_string is equal to "$error_string");
Run Code Online (Sandbox Code Playgroud)

但是, …

perl file-io dup

6
推荐指数
2
解决办法
486
查看次数

是否有可能获得特定Perl类的所有有效方法?

是否有可能获得特定Perl类的所有有效方法?

我试图操纵类的符号表并获取其所有方法.我发现我可以通过它从非子程序中分离出子程序$obj->can($method),但这并不完全符合我的想法.

以下返回:

subroutine, Property, croak, Group, confess, carp, File
Run Code Online (Sandbox Code Playgroud)

但是,subroutine是不是方法,(只是一个子程序),并且croak,confesscarp全部导入到我的包.

我真正想要打印的是:

Property,Group, File
Run Code Online (Sandbox Code Playgroud)

但我会接受:

subroutine, Property,Group, File
Run Code Online (Sandbox Code Playgroud)

以下是我的计划:

#! /usr/bin/env perl

use strict;
use warnings;
use feature qw(say);

my $sections = Section_group->new;
say join ", ", $sections->Sections;

package Section_group;
use Carp;

sub new     {
    return bless {}, shift;
}

sub Add {
    my $self                = shift;
    my $section             = shift;
}

sub Sections {
    my $self                = shift;

    my …
Run Code Online (Sandbox Code Playgroud)

oop methods perl class

6
推荐指数
2
解决办法
158
查看次数

Ant if:true.将property设置为true不会导致任务执行

在Ant 1.9.1中,您可以在大多数任务中使用if和unless属性.

我有一个我定义的宏,我正在尝试运行这些任务:

<property name="test.templates"     value="true"/>
....
<target name="test.templates"
    description="Test the autoconfiguration templates and answers">
    <test.templates
        if:true="test.templates"
        template.root.dir="${main.dir}"
        answers.dir="${main.config.dir}"/>
</target>
Run Code Online (Sandbox Code Playgroud)

但是,这不会运行我的宏 - 即使该属性test.templates设置为true.如果我删除该行,我的test.template宏将起作用.

if:true在用户定义的宏中使用是否有问题?解决这个问题的最佳方法是什么?

ant macros

6
推荐指数
1
解决办法
2729
查看次数

Perl用字符串中的"x"替换数字,但仅在一个特定位置

我正在解析填充各种错误的日志文件.这些是网络错误,这意味着客户在格式化我们网站的日期时蠢蠢欲动.日志看起来像这样:

Error 123: Customer 2: Bad Date [17/12/2014]
Error 123: Customer 2: Bad Date [19/12/2014]
Error 123: Customer 1: Bad Date [123/23/222]
Error 123: Customer 2: Bad Date [null]
Error 123: Customer 6: Bad Date [12/14:]
Error 123: Customer 6: Bad Date [12/16:]
Run Code Online (Sandbox Code Playgroud)

现在,前两个对同一个客户来说真的是同一个错误.这两行,报告日期DD/MM/YYYY而不是YYYY/MM/DD,所以我不需要两次报告此错误.最后两行对于同一客户也是同样的错误.使用MM/DD和离开一年.null即使我之前报告过客户#2的错误日期错误,该日期也是另一个错误.在某个地方,他们正在通过一个空日期.

我想做的是用这种方式比较线条:

Error 123: Customer 2: Bad Date [xx/xx/xxxx]
Error 123: Customer 2: Bad Date [xx/xx/xxxx]
Error 123: Customer 1: Bad Date [xxx/xx/xxx]
Error 123: Customer 2: …
Run Code Online (Sandbox Code Playgroud)

regex perl

6
推荐指数
1
解决办法
725
查看次数

在大会中包括一个解压缩的战争

我有一个建立战争的项目(没问题).并且,该战争需要与一些shell脚本打包在一起.因为该战争包含不同站点之间的属性文件,我们不能简单地按原样安装战争,而是将其中的属性文件移除.这就是shell脚本的功能.

我想把我的战争包装在我的集会中作为一个解包的战争.我<unpacked>在大会描述符中看到,但我无法让它工作.

这是我第一次bin.xml把战争打包成现实.这很好用:

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
    <id>bin</id>
    <formats>
        <format>zip</format>
    </formats>
    <includeBaseDirectory>false</includeBaseDirectory>
    <fileSets>
        <fileSet>
            <directory>${project.basedir}/src/assembly/scripts</directory>
            <includes>
                <include>deploy.sh</include>
                <include>lock_build.sh</include>
                <include>description.sh</include>
                <include>url-encode.pl</include>
            </includes>
            <outputDirectory>/</outputDirectory>
        </fileSet>
        <fileSet>
            <directory>${project.build.directory}/${project.artifactId}-${project.version}</directory>
            <outputDirectory>${project.artifactId}</outputDirectory>
        </fileSet>
    </fileSets>
</assembly>
Run Code Online (Sandbox Code Playgroud)

这是我第一次尝试解压缩:

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
    <id>bin</id>
    <formats>
        <format>zip</format>
    </formats>
    <includeBaseDirectory>false</includeBaseDirectory>
    <fileSets>
        <fileSet>
            <directory>${project.basedir}/src/assembly/scripts</directory>
            <includes>
                <include>deploy.sh</include>
                <include>lock_build.sh</include>
                <include>description.sh</include>
                <include>url-encode.pl</include>
            </includes>
            <outputDirectory>/</outputDirectory>
       </fileSet>
    </fileSets>
    <moduleSets>
        <moduleSet>
            <includes>
                <include>{$project.groupId}:${project.artifactId}:war</include>
            </includes>
            <binaries>
                <includes>
                    <include>${project.build.directory}-${project.artifactId}-${project.version}.${project.packaging}</include>
                </includes>
                <outputDirectory>${project.artifactId}</outputDirectory>
                <unpack>true</unpack>
            </binaries>
        </moduleSet>
    </moduleSets>
</assembly>
Run Code Online (Sandbox Code Playgroud)

这是我最后一次尝试获得解压缩的战争:

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
    <id>bin</id>
    <formats> …
Run Code Online (Sandbox Code Playgroud)

unpack maven maven-assembly-plugin

6
推荐指数
1
解决办法
4705
查看次数

Perl IO :: File是否可以与Autodie配合使用?

我试图理解为什么IO::File似乎不适用use autodie:

示例#1:测试程序使用open:

#! /usr/bin/env perl
#
use strict;
use warnings;
use feature qw(say);
use autodie;
use IO::File;

open( my $fh, "<", "bogus_file" );
# my $fh = IO::File->new( "bogus_file", "r" );
while ( my $line = $fh->getline )  {
    chomp $line;
    say qq(Line = "$line");
}
Run Code Online (Sandbox Code Playgroud)

这失败了:

Can't open 'bogus_file' for reading: 'No such file or directory' at ./test.pl line 9
Run Code Online (Sandbox Code Playgroud)

它看起来像是autodie在工作.

示例#2:相同的测试程序,但现在使用IO::File:

#! /usr/bin/env perl
# …
Run Code Online (Sandbox Code Playgroud)

io perl

6
推荐指数
1
解决办法
229
查看次数

Jenkins多管道构建未检测到存储库中的更改

我们在这个庄园中设置了Subversion存储库:

  • http://svn.vegicorp.net/svn/toast/api/trunk
  • http://svn.vegicorp.net/svn/toast/api/1.0
  • http://svn.vegicorp.net/svn/toast/data/trunk
  • http://svn.vegicorp.net/svn/toast/data/branches/1.2
  • http://svn.vegicorp.net/svn/toast/data/branches/1.3

我为整个toast项目设置了Jenkins Multi-Pipeline构建,包括所有子项目 - 每个子项目都是一个jar文件.我想要的是Jenkins每次在一个toast项目中更改任何文件时都会触发一个新的构建.那个项目应该重建.这样,如果我们在Toast中创建一个新的子项目或在其中一个toast子项目中创建一个新的分支,Jenkins将自动为它创建一个新的构建.

这是我的Jenkins Multi-Branch设置:

分支来源

颠覆

  • 项目存储库基础:http://svn.vegicorp.net/svn/toast
  • 证书:builder/*****
  • 包括分支:*/trunk, */branches/*
  • 排除分支:*/private
  • 物业策略:所有分行都拥有相同的物业

构建配置

  • 模式:Jenkinsfile

构建触发器(未选中)

  • 触发器远程构建(例如,从脚本)构建功能帮助:触发器*远程构建(例如,从脚本)
  • 定期构建功能帮助:定期构建
  • 在推广另一个项目时构建
  • Maven依赖关系更新触发器功能帮助:Maven依赖关系更新触发器
  • 如果没有另外运行,则定期

请注意," 构建触发器"列表列表不包括" 轮询SCM".存储库中的更改不会触发任何构建.Jenkinsfiles位于每个子项目的根目录.如果我强制重新索引,则会构建所有已更改的子项目并找到所有新分支.我最初定期检查并每分钟重新编制索引以获取更改,但这是klutzy,它似乎导致Jenkins消耗内存.

触发SCM更改的构建应该是非常基本的,但我没有看到这样的配置参数,就像我使用标准作业一样.我似乎也无法进入子项目并将其设置为触发构建.

必须有一些真正,非常简单的东西,我想念.

组态:

  • 詹金斯2.19
  • 管道2.3
  • 管道API:2.3
  • Pipeline Groovy:2.17
  • 管道工作:2.6
  • Pipeline REST API插件:2.0
  • 管道共享Groovy库:2.3
  • 管道:Stage View插件:1.7
  • 管道:支持API 2.2
  • SCM API插件:1.2

jenkins-pipeline jenkins-2

5
推荐指数
1
解决办法
5200
查看次数